Skip to content

Commit

Permalink
- got source chooser working better and will now actually show which …
Browse files Browse the repository at this point in the history
…source is currently selected
  • Loading branch information
jakepurple13 committed Apr 8, 2021
1 parent 65c2b9d commit 1c2c444
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ abstract class BaseMainActivity : AppCompatActivity(), GenericInfo {
genericInfo = this
setContentView(R.layout.base_main_activity)

currentService?.let { sourcePublish.onNext(it) }
toSource(currentService.orEmpty())?.let { sourcePublish.onNext(it) }

if (savedInstanceState == null) {
setupBottomNavBar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,19 @@ class SettingsFragment : PreferenceFragmentCompat() {
findPreference<Preference>("current_source")?.let { p ->
val list = genericInfo.sourceList().toTypedArray()
p.setOnPreferenceClickListener {
val service = requireContext().currentService
MaterialAlertDialogBuilder(requireContext())
.setTitle("Choose a source")
.setSingleChoiceItems(
list.map { it.serviceName }.toTypedArray(),
list.indexOfFirst { it.serviceName == requireContext().currentService?.serviceName }
list.indexOfFirst {
println(it)
println(service)
it.serviceName == service
}.also { println(it) }
) { d, i ->
sourcePublish.onNext(list[i])
requireContext().currentService = list[i]
requireContext().currentService = list[i].serviceName
d.dismiss()
}
.setPositiveButton("Done") { d, _ -> d.dismiss() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import com.programmersbox.gsonutils.sharedPrefNotNullObjectDelegate
import com.programmersbox.gsonutils.sharedPrefObjectDelegate
import com.programmersbox.helpfulutils.sharedPrefDelegate
import com.programmersbox.helpfulutils.sharedPrefNotNullDelegate
import com.programmersbox.models.ApiService
import com.programmersbox.models.ChapterModel
import com.programmersbox.uiviews.GenericInfo
import io.reactivex.subjects.BehaviorSubject
import java.lang.reflect.Type

var Context.currentService: ApiService? by sharedPrefObjectDelegate(null)
var Context.currentService: String? by sharedPrefObjectDelegate(null)

var Context.shouldCheck: Boolean by sharedPrefNotNullObjectDelegate(true)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class MainActivity : BaseMainActivity() {

if (currentService == null) {
sourcePublish.onNext(Sources.GOGOANIME)
currentService = Sources.GOGOANIME
currentService = Sources.GOGOANIME.serviceName
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MainActivity : BaseMainActivity() {

if (currentService == null) {
sourcePublish.onNext(Sources.NINE_ANIME)
currentService = Sources.NINE_ANIME
currentService = Sources.NINE_ANIME.serviceName
}
}

Expand Down

0 comments on commit 1c2c444

Please sign in to comment.