mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-25 09:47:40 +00:00
Added refreshing upon connection restore
This commit is contained in:
parent
9dd272b357
commit
37fa227fb5
@ -1,6 +1,8 @@
|
||||
package com.topjohnwu.magisk.redesign.compat
|
||||
|
||||
import android.graphics.Insets
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.databinding.Observable
|
||||
import com.skoumal.teanity.util.KObservableField
|
||||
import com.topjohnwu.magisk.ui.base.MagiskViewModel
|
||||
import io.reactivex.disposables.Disposable
|
||||
@ -10,6 +12,15 @@ abstract class CompatViewModel : MagiskViewModel() {
|
||||
val insets = KObservableField(Insets.NONE)
|
||||
|
||||
private var runningTask: Disposable? = null
|
||||
private val refreshCallback = object : Observable.OnPropertyChangedCallback() {
|
||||
override fun onPropertyChanged(sender: Observable?, propertyId: Int) {
|
||||
requestRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
isConnected.addOnPropertyChangedCallback(refreshCallback)
|
||||
}
|
||||
|
||||
/** This should probably never be called manually, it's called manually via delegate. */
|
||||
@Synchronized
|
||||
@ -22,4 +33,10 @@ abstract class CompatViewModel : MagiskViewModel() {
|
||||
|
||||
protected open fun refresh(): Disposable? = null
|
||||
|
||||
@CallSuper
|
||||
override fun onCleared() {
|
||||
isConnected.removeOnPropertyChangedCallback(refreshCallback)
|
||||
super.onCleared()
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user