mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-27 09:44:55 +03:00
Complete RxBindings to FlowBinding migration
This commit is contained in:
parent
c9a727594e
commit
3d10dad780
4 changed files with 9 additions and 20 deletions
|
@ -232,16 +232,13 @@ dependencies {
|
|||
}
|
||||
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
|
||||
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-appcompat:$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-viewpager:$flowbinding_version"
|
||||
|
||||
// Tests
|
||||
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.RxSharedPreferences
|
||||
import com.tfcporciuncula.flow.FlowSharedPreferences
|
||||
import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceKeys as Keys
|
||||
import eu.kanade.tachiyomi.data.preference.PreferenceValues as Values
|
||||
|
@ -19,16 +18,9 @@ import java.text.DateFormat
|
|||
import java.text.SimpleDateFormat
|
||||
import java.util.Locale
|
||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import reactivecircus.flowbinding.common.startWithCurrentValue
|
||||
|
||||
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> {
|
||||
override fun get(key: String, preferences: SharedPreferences): DateFormat {
|
||||
val dateFormat = preferences.getString(Keys.dateFormat, "")!!
|
||||
|
|
|
@ -19,7 +19,6 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
|
|||
import com.bluelinelabs.conductor.ControllerChangeType
|
||||
import com.f2prateek.rx.preferences.Preference
|
||||
import com.google.android.material.tabs.TabLayout
|
||||
import com.jakewharton.rxbinding.support.v4.view.pageSelections
|
||||
import com.jakewharton.rxrelay.BehaviorRelay
|
||||
import com.jakewharton.rxrelay.PublishRelay
|
||||
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.onEach
|
||||
import reactivecircus.flowbinding.appcompat.queryTextChanges
|
||||
import reactivecircus.flowbinding.viewpager.pageSelections
|
||||
import rx.Subscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.Injekt
|
||||
|
@ -149,10 +149,12 @@ class LibraryController(
|
|||
|
||||
adapter = LibraryAdapter(this)
|
||||
binding.libraryPager.adapter = adapter
|
||||
binding.libraryPager.pageSelections().skip(1).subscribeUntilDestroy {
|
||||
preferences.lastUsedCategory().set(it)
|
||||
activeCategory = it
|
||||
}
|
||||
binding.libraryPager.pageSelections()
|
||||
.onEach {
|
||||
preferences.lastUsedCategory().set(it)
|
||||
activeCategory = it
|
||||
}
|
||||
.launchInUI()
|
||||
|
||||
getColumnsPreferenceForCurrentOrientation().asObservable()
|
||||
.doOnNext { mangaPerRow = it }
|
||||
|
|
|
@ -3,7 +3,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer
|
|||
import com.tfcporciuncula.flow.Preference
|
||||
import eu.kanade.tachiyomi.util.lang.launchInUI
|
||||
import kotlinx.coroutines.flow.distinctUntilChanged
|
||||
import kotlinx.coroutines.flow.drop
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
||||
abstract class ViewerConfig {
|
||||
|
@ -16,7 +15,6 @@ abstract class ViewerConfig {
|
|||
) {
|
||||
asFlow()
|
||||
.onEach { valueAssignment(it) }
|
||||
.drop(1)
|
||||
.distinctUntilChanged()
|
||||
.onEach { onChanged(it) }
|
||||
.launchInUI()
|
||||
|
|
Loading…
Reference in a new issue