mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 10:46:53 -04:00
Subscribe to a field in view model to control action mode
This commit is contained in:
parent
30f40c829f
commit
15a0d9aae2
@ -19,9 +19,7 @@
|
||||
package org.kiwix.kiwixmobile.zim_manager
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import androidx.annotation.VisibleForTesting
|
||||
import androidx.appcompat.view.ActionMode
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import androidx.lifecycle.ViewModel
|
||||
import io.reactivex.Flowable
|
||||
@ -112,6 +110,8 @@ class ZimManageViewModel @Inject constructor(
|
||||
val requestFiltering = BehaviorProcessor.createDefault<String>("")
|
||||
val currentPage = PublishProcessor.create<Int>()
|
||||
|
||||
val libraryFragmentIsVisible = currentPage.filter { it == 1 }
|
||||
|
||||
private val compositeDisposable = CompositeDisposable()
|
||||
|
||||
init {
|
||||
@ -146,12 +146,6 @@ class ZimManageViewModel @Inject constructor(
|
||||
)
|
||||
}
|
||||
|
||||
fun actionMode(actionMode: ActionMode?) {
|
||||
currentPage.filter { it == 1 }.subscribe {
|
||||
actionMode?.finish()
|
||||
}
|
||||
}
|
||||
|
||||
private fun fileSelectActions() = fileSelectActions.subscribe({
|
||||
sideEffects.offer(
|
||||
when (it) {
|
||||
|
@ -112,9 +112,7 @@ class ZimFileSelectFragment : BaseFragment() {
|
||||
zimManageViewModel.fileSelectActions.offer(FileSelectActions.RestartActionMode)
|
||||
}
|
||||
|
||||
zimManageViewModel.currentPage.subscribe {
|
||||
zimManageViewModel.actionMode(actionMode)
|
||||
}
|
||||
disposable.add(zimManageViewModel.libraryFragmentIsVisible.subscribe { actionMode?.finish() })
|
||||
}
|
||||
|
||||
private fun sideEffects() = zimManageViewModel.sideEffects.subscribe(
|
||||
|
Loading…
x
Reference in New Issue
Block a user