Skip to content

Commit

Permalink
Allow using object from input for Eclipse Finder
Browse files Browse the repository at this point in the history
  • Loading branch information
levinli303 committed Feb 14, 2021
1 parent f0be5d5 commit 057bc2b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="space.celestia.mobilecelestia"
android:versionCode="150"
android:versionCode="151"
android:versionName="1.2.4">

<uses-feature android:glEsVersion="0x00020000" android:required="true" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@ import androidx.recyclerview.widget.RecyclerView
import space.celestia.mobilecelestia.R
import space.celestia.mobilecelestia.common.NavigationFragment
import space.celestia.mobilecelestia.core.CelestiaAppCore
import space.celestia.mobilecelestia.utils.CelestiaString
import space.celestia.mobilecelestia.utils.showAlert
import space.celestia.mobilecelestia.utils.showDateInput
import space.celestia.mobilecelestia.utils.showSingleSelection
import space.celestia.mobilecelestia.utils.*
import java.util.*

class EventFinderInputFragment : NavigationFragment.SubFragment() {
Expand Down Expand Up @@ -57,8 +54,18 @@ class EventFinderInputFragment : NavigationFragment.SubFragment() {
}, { current ->
val ac = context as? Activity ?: return@EventFinderInputRecyclerViewAdapter
val objects = listOf("Earth", "Jupiter")
val other = CelestiaString("Other", "")
val currentIndex = 0.coerceAtLeast(objects.indexOf(current))
ac.showSingleSelection(CelestiaString("Please choose an object.", ""), objects.map { CelestiaAppCore.getLocalizedString(it, "celestia") }, currentIndex) { index ->
ac.showSingleSelection(CelestiaString("Please choose an object.", ""), objects.map { CelestiaAppCore.getLocalizedString(it, "celestia") } + other, currentIndex) { index ->
if (index >= objects.size) {
// User choose other, show text input for the object name
ac.showTextInput(CelestiaString("Please enter an object name.", "")) { objectName ->
adapter?.objectName = objectName
adapter?.reload()
adapter?.notifyDataSetChanged()
}
return@showSingleSelection
}
adapter?.objectName = objects[index]
adapter?.reload()
adapter?.notifyDataSetChanged()
Expand Down

0 comments on commit 057bc2b

Please sign in to comment.