forked from upstream-mirrors/quik
Replace usage of CompositeDisposable with AutoDispose in Activities and Views
This commit is contained in:
@@ -22,11 +22,11 @@ import android.content.Context
|
||||
import android.support.v7.widget.AppCompatTextView
|
||||
import android.util.AttributeSet
|
||||
import com.moez.QKSMS.R
|
||||
import com.uber.autodispose.android.scope
|
||||
import com.uber.autodispose.kotlin.autoDisposable
|
||||
import common.di.appComponent
|
||||
import common.util.Colors
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
import io.reactivex.rxkotlin.plusAssign
|
||||
import javax.inject.Inject
|
||||
|
||||
open class QkTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
|
||||
@@ -34,7 +34,6 @@ open class QkTextView @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
|
||||
@Inject lateinit var colors: Colors
|
||||
|
||||
private val disposables = CompositeDisposable()
|
||||
private var textColorObservable: Observable<Int>? = null
|
||||
|
||||
init {
|
||||
@@ -50,25 +49,19 @@ open class QkTextView @JvmOverloads constructor(context: Context, attrs: Attribu
|
||||
5 -> colors.textTertiaryOnTheme
|
||||
else -> null
|
||||
}
|
||||
|
||||
recycle()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
|
||||
textColorObservable?.let { observable ->
|
||||
disposables += observable.subscribe { color ->
|
||||
setTextColor(color)
|
||||
setLinkTextColor(color)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
|
||||
disposables.dispose()
|
||||
textColorObservable
|
||||
?.autoDisposable(scope())
|
||||
?.subscribe { color ->
|
||||
setTextColor(color)
|
||||
setLinkTextColor(color)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user