mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-08-03 18:56:44 -04:00
Put the check in the view model
This commit is contained in:
parent
78214dd255
commit
30f40c829f
@ -19,7 +19,9 @@
|
||||
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
|
||||
@ -144,6 +146,12 @@ 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,11 +112,9 @@ class ZimFileSelectFragment : BaseFragment() {
|
||||
zimManageViewModel.fileSelectActions.offer(FileSelectActions.RestartActionMode)
|
||||
}
|
||||
|
||||
zimManageViewModel.currentPage.map { it == 1 }.subscribe { if (it) finishActionMode() }
|
||||
}
|
||||
|
||||
private fun finishActionMode() {
|
||||
actionMode?.finish()
|
||||
zimManageViewModel.currentPage.subscribe {
|
||||
zimManageViewModel.actionMode(actionMode)
|
||||
}
|
||||
}
|
||||
|
||||
private fun sideEffects() = zimManageViewModel.sideEffects.subscribe(
|
||||
|
Loading…
x
Reference in New Issue
Block a user