Complete RxBindings to FlowBinding migration
This commit is contained in:
parent
c9a727594e
commit
3d10dad780
@ -232,16 +232,13 @@ dependencies {
|
|||||||
}
|
}
|
||||||
implementation 'com.github.inorichi:conductor-support-preference:a32c357'
|
implementation 'com.github.inorichi:conductor-support-preference:a32c357'
|
||||||
|
|
||||||
// RxBindings
|
|
||||||
final rxbindings_version = '1.0.1'
|
|
||||||
implementation "com.jakewharton.rxbinding:rxbinding-support-v4-kotlin:$rxbindings_version"
|
|
||||||
|
|
||||||
// FlowBinding
|
// FlowBinding
|
||||||
final flowbinding_version = '0.10.2'
|
final flowbinding_version = '0.11.1'
|
||||||
implementation "io.github.reactivecircus.flowbinding:flowbinding-android:$flowbinding_version"
|
implementation "io.github.reactivecircus.flowbinding:flowbinding-android:$flowbinding_version"
|
||||||
implementation "io.github.reactivecircus.flowbinding:flowbinding-appcompat:$flowbinding_version"
|
implementation "io.github.reactivecircus.flowbinding:flowbinding-appcompat:$flowbinding_version"
|
||||||
implementation "io.github.reactivecircus.flowbinding:flowbinding-recyclerview:$flowbinding_version"
|
implementation "io.github.reactivecircus.flowbinding:flowbinding-recyclerview:$flowbinding_version"
|
||||||
implementation "io.github.reactivecircus.flowbinding:flowbinding-swiperefreshlayout:$flowbinding_version"
|
implementation "io.github.reactivecircus.flowbinding:flowbinding-swiperefreshlayout:$flowbinding_version"
|
||||||
|
implementation "io.github.reactivecircus.flowbinding:flowbinding-viewpager:$flowbinding_version"
|
||||||
|
|
||||||
// Tests
|
// Tests
|
||||||
testImplementation 'junit:junit:4.13'
|
testImplementation 'junit:junit:4.13'
|
||||||
|
@ -8,7 +8,6 @@ import androidx.preference.PreferenceManager
|
|||||||
import com.f2prateek.rx.preferences.Preference as RxPreference
|
import com.f2prateek.rx.preferences.Preference as RxPreference
|
||||||
import com.f2prateek.rx.preferences.RxSharedPreferences
|
import com.f2prateek.rx.preferences.RxSharedPreferences
|
||||||
import com.tfcporciuncula.flow.FlowSharedPreferences
|
import com.tfcporciuncula.flow.FlowSharedPreferences
|
||||||
import com.tfcporciuncula.flow.Preference
|
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||||
@ -19,16 +18,9 @@ import java.text.DateFormat
|
|||||||
import java.text.SimpleDateFormat
|
import java.text.SimpleDateFormat
|
||||||
import java.util.Locale
|
import java.util.Locale
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
import kotlinx.coroutines.flow.Flow
|
|
||||||
import reactivecircus.flowbinding.common.startWithCurrentValue
|
|
||||||
|
|
||||||
fun <T> RxPreference<T>.getOrDefault(): T = get() ?: defaultValue()!!
|
fun <T> RxPreference<T>.getOrDefault(): T = get() ?: defaultValue()!!
|
||||||
|
|
||||||
fun <T> Preference<T>.asImmediateFlow(): Flow<T> {
|
|
||||||
return asFlow()
|
|
||||||
.startWithCurrentValue(true) { get() }
|
|
||||||
}
|
|
||||||
|
|
||||||
private class DateFormatConverter : RxPreference.Adapter<DateFormat> {
|
private class DateFormatConverter : RxPreference.Adapter<DateFormat> {
|
||||||
override fun get(key: String, preferences: SharedPreferences): DateFormat {
|
override fun get(key: String, preferences: SharedPreferences): DateFormat {
|
||||||
val dateFormat = preferences.getString(Keys.dateFormat, "")!!
|
val dateFormat = preferences.getString(Keys.dateFormat, "")!!
|
||||||
|
@ -19,7 +19,6 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
|
|||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.f2prateek.rx.preferences.Preference
|
import com.f2prateek.rx.preferences.Preference
|
||||||
import com.google.android.material.tabs.TabLayout
|
import com.google.android.material.tabs.TabLayout
|
||||||
import com.jakewharton.rxbinding.support.v4.view.pageSelections
|
|
||||||
import com.jakewharton.rxrelay.BehaviorRelay
|
import com.jakewharton.rxrelay.BehaviorRelay
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
@ -43,6 +42,7 @@ import kotlinx.android.synthetic.main.main_activity.tabs
|
|||||||
import kotlinx.coroutines.flow.filter
|
import kotlinx.coroutines.flow.filter
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
||||||
|
import reactivecircus.flowbinding.viewpager.pageSelections
|
||||||
import rx.Subscription
|
import rx.Subscription
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
@ -149,10 +149,12 @@ class LibraryController(
|
|||||||
|
|
||||||
adapter = LibraryAdapter(this)
|
adapter = LibraryAdapter(this)
|
||||||
binding.libraryPager.adapter = adapter
|
binding.libraryPager.adapter = adapter
|
||||||
binding.libraryPager.pageSelections().skip(1).subscribeUntilDestroy {
|
binding.libraryPager.pageSelections()
|
||||||
|
.onEach {
|
||||||
preferences.lastUsedCategory().set(it)
|
preferences.lastUsedCategory().set(it)
|
||||||
activeCategory = it
|
activeCategory = it
|
||||||
}
|
}
|
||||||
|
.launchInUI()
|
||||||
|
|
||||||
getColumnsPreferenceForCurrentOrientation().asObservable()
|
getColumnsPreferenceForCurrentOrientation().asObservable()
|
||||||
.doOnNext { mangaPerRow = it }
|
.doOnNext { mangaPerRow = it }
|
||||||
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer
|
|||||||
import com.tfcporciuncula.flow.Preference
|
import com.tfcporciuncula.flow.Preference
|
||||||
import eu.kanade.tachiyomi.util.lang.launchInUI
|
import eu.kanade.tachiyomi.util.lang.launchInUI
|
||||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||||
import kotlinx.coroutines.flow.drop
|
|
||||||
import kotlinx.coroutines.flow.onEach
|
import kotlinx.coroutines.flow.onEach
|
||||||
|
|
||||||
abstract class ViewerConfig {
|
abstract class ViewerConfig {
|
||||||
@ -16,7 +15,6 @@ abstract class ViewerConfig {
|
|||||||
) {
|
) {
|
||||||
asFlow()
|
asFlow()
|
||||||
.onEach { valueAssignment(it) }
|
.onEach { valueAssignment(it) }
|
||||||
.drop(1)
|
|
||||||
.distinctUntilChanged()
|
.distinctUntilChanged()
|
||||||
.onEach { onChanged(it) }
|
.onEach { onChanged(it) }
|
||||||
.launchInUI()
|
.launchInUI()
|
||||||
|
Loading…
Reference in New Issue
Block a user