mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Remove some unused rx references
This commit is contained in:
parent
436b0b673a
commit
34301e7e6d
4 changed files with 0 additions and 137 deletions
|
@ -1,91 +0,0 @@
|
|||
package eu.kanade.tachiyomi.ui.base.controller
|
||||
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.viewbinding.ViewBinding
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
|
||||
abstract class RxController<VB : ViewBinding>(bundle: Bundle? = null) : BaseController<VB>(bundle) {
|
||||
|
||||
var untilDetachSubscriptions = CompositeSubscription()
|
||||
private set
|
||||
|
||||
var untilDestroySubscriptions = CompositeSubscription()
|
||||
private set
|
||||
|
||||
@CallSuper
|
||||
override fun onAttach(view: View) {
|
||||
super.onAttach(view)
|
||||
if (untilDetachSubscriptions.isUnsubscribed) {
|
||||
untilDetachSubscriptions = CompositeSubscription()
|
||||
}
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onDetach(view: View) {
|
||||
super.onDetach(view)
|
||||
untilDetachSubscriptions.unsubscribe()
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onViewCreated(view: View) {
|
||||
if (untilDestroySubscriptions.isUnsubscribed) {
|
||||
untilDestroySubscriptions = CompositeSubscription()
|
||||
}
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
override fun onDestroyView(view: View) {
|
||||
super.onDestroyView(view)
|
||||
untilDestroySubscriptions.unsubscribe()
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDetach(): Subscription {
|
||||
return subscribe().also { untilDetachSubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDetach(onNext: (T) -> Unit): Subscription {
|
||||
return subscribe(onNext).also { untilDetachSubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDetach(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError).also { untilDetachSubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDetach(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onCompleted: () -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError, onCompleted).also { untilDetachSubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(): Subscription {
|
||||
return subscribe().also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(onNext: (T) -> Unit): Subscription {
|
||||
return subscribe(onNext).also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError).also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(
|
||||
onNext: (T) -> Unit,
|
||||
onError: (Throwable) -> Unit,
|
||||
onCompleted: () -> Unit,
|
||||
): Subscription {
|
||||
return subscribe(onNext, onError, onCompleted).also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
}
|
|
@ -4,7 +4,6 @@ import android.content.Context
|
|||
import android.view.View
|
||||
import android.view.ViewGroup.LayoutParams
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import rx.Subscription
|
||||
|
||||
abstract class WebtoonBaseHolder(
|
||||
view: View,
|
||||
|
@ -21,21 +20,6 @@ abstract class WebtoonBaseHolder(
|
|||
*/
|
||||
open fun recycle() {}
|
||||
|
||||
/**
|
||||
* Adds a subscription to a list of subscriptions that will automatically unsubscribe when the
|
||||
* activity or the reader is destroyed.
|
||||
*/
|
||||
protected fun addSubscription(subscription: Subscription?) {
|
||||
viewer.subscriptions.add(subscription)
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a subscription from the list of subscriptions.
|
||||
*/
|
||||
protected fun removeSubscription(subscription: Subscription?) {
|
||||
subscription?.let { viewer.subscriptions.remove(it) }
|
||||
}
|
||||
|
||||
/**
|
||||
* Extension method to set layout params to wrap content on this view.
|
||||
*/
|
||||
|
|
|
@ -20,9 +20,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.BaseViewer
|
|||
import eu.kanade.tachiyomi.ui.reader.viewer.ViewerNavigation
|
||||
import kotlinx.coroutines.MainScope
|
||||
import kotlinx.coroutines.cancel
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import timber.log.Timber
|
||||
import uy.kohesive.injekt.api.get
|
||||
import uy.kohesive.injekt.injectLazy
|
||||
import kotlin.math.max
|
||||
import kotlin.math.min
|
||||
|
@ -71,11 +69,6 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
|
|||
*/
|
||||
val config = WebtoonConfig(scope)
|
||||
|
||||
/**
|
||||
* Subscriptions to keep while this viewer is used.
|
||||
*/
|
||||
val subscriptions = CompositeSubscription()
|
||||
|
||||
init {
|
||||
recycler.setBackgroundColor(Color.BLACK)
|
||||
recycler.isVisible = false // Don't let the recycler layout yet
|
||||
|
@ -183,7 +176,6 @@ class WebtoonViewer(val activity: ReaderActivity, val hasMargins: Boolean = fals
|
|||
override fun destroy() {
|
||||
super.destroy()
|
||||
scope.cancel()
|
||||
subscriptions.unsubscribe()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -30,9 +30,6 @@ import eu.kanade.tachiyomi.util.view.activityBinding
|
|||
import eu.kanade.tachiyomi.util.view.scrollViewWith
|
||||
import eu.kanade.tachiyomi.widget.LinearLayoutManagerAccurateOffset
|
||||
import kotlinx.coroutines.MainScope
|
||||
import rx.Observable
|
||||
import rx.Subscription
|
||||
import rx.subscriptions.CompositeSubscription
|
||||
import uy.kohesive.injekt.Injekt
|
||||
import uy.kohesive.injekt.api.get
|
||||
import java.util.Locale
|
||||
|
@ -43,18 +40,12 @@ abstract class SettingsController : PreferenceController() {
|
|||
val preferences: PreferencesHelper = Injekt.get()
|
||||
val viewScope = MainScope()
|
||||
|
||||
var untilDestroySubscriptions = CompositeSubscription()
|
||||
private set
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
listView.layoutManager = LinearLayoutManagerAccurateOffset(view.context)
|
||||
}
|
||||
|
||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup, savedInstanceState: Bundle?): View {
|
||||
if (untilDestroySubscriptions.isUnsubscribed) {
|
||||
untilDestroySubscriptions = CompositeSubscription()
|
||||
}
|
||||
val view = super.onCreateView(inflater, container, savedInstanceState)
|
||||
scrollViewWith(listView, padBottom = true)
|
||||
return view
|
||||
|
@ -79,11 +70,6 @@ abstract class SettingsController : PreferenceController() {
|
|||
}
|
||||
}
|
||||
|
||||
override fun onDestroyView(view: View) {
|
||||
super.onDestroyView(view)
|
||||
untilDestroySubscriptions.unsubscribe()
|
||||
}
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
val screen = preferenceManager.createPreferenceScreen(getThemedContext())
|
||||
preferenceScreen = screen
|
||||
|
@ -144,14 +130,6 @@ abstract class SettingsController : PreferenceController() {
|
|||
super.onChangeStarted(handler, type)
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(): Subscription {
|
||||
return subscribe().also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
||||
fun <T> Observable<T>.subscribeUntilDestroy(onNext: (T) -> Unit): Subscription {
|
||||
return subscribe(onNext).also { untilDestroySubscriptions.add(it) }
|
||||
}
|
||||
|
||||
inline fun <T> Preference.visibleIf(preference: com.fredporciuncula.flow.preferences.Preference<T>, crossinline block: (T) -> Boolean) {
|
||||
preference.asImmediateFlowIn(viewScope) { isVisible = block(it) }
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue