我有一个基于网络更改通知程序的类ConnectivityManager.NetworkCallback
,我想在网络可用时更新一些字段;
override fun onAvailable(network: Network?) {
super.onAvailable(network)
val db = StoreDatabase.getInstance(context)
val stores = db.createStores()
val disposable = stores.insertStore(Stores(storeName = "testOnAvailableNetInsertions", status
= AppConstants.Database.SYNC_FAIL))
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io()).subscribeWith(object : DisposableCompletableObserver() {
override fun onComplete() {
if (!isDisposed)
dispose()
}
override fun onError(e: Throwable) {
if (!isDisposed)
dispose()
}
}).dispose()
是否可以在方法结束时调用 dispose,或者我必须在其他地方处理该变量,这就是我的道;
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertStore(stores: Stores): Completable