Use a publish processor for finishing action mode

Use a publish processor for finishing action mode
This commit is contained in:
Yash Khare 2020-04-10 15:27:59 +05:30
parent 35d793756c
commit 78214dd255
3 changed files with 3 additions and 11 deletions

View File

@ -75,7 +75,7 @@ class ZimManageActivity : BaseActivity() {
}
private fun updatePage(position: Int) {
zimManageViewModel.currentTabIndex(position)
zimManageViewModel.currentPage.offer(position)
}
override fun onNewIntent(intent: Intent?) {

View File

@ -103,12 +103,12 @@ class ZimManageViewModel @Inject constructor(
val deviceListIsRefreshing = MutableLiveData<Boolean>()
val libraryListIsRefreshing = MutableLiveData<Boolean>()
val networkStates = MutableLiveData<NetworkState>()
val currentPage = MutableLiveData<Int>()
val requestFileSystemCheck = PublishProcessor.create<Unit>()
val fileSelectActions = PublishProcessor.create<FileSelectActions>()
val requestDownloadLibrary = BehaviorProcessor.createDefault<Unit>(Unit)
val requestFiltering = BehaviorProcessor.createDefault<String>("")
val currentPage = PublishProcessor.create<Int>()
private val compositeDisposable = CompositeDisposable()
@ -158,10 +158,6 @@ class ZimManageViewModel @Inject constructor(
)
}, Throwable::printStackTrace)
fun currentTabIndex(position: Int) {
currentPage.value = position
}
private fun startMultiSelectionAndSelectBook(
bookOnDisk: BookOnDisk
): StartMultiSelection {

View File

@ -112,11 +112,7 @@ class ZimFileSelectFragment : BaseFragment() {
zimManageViewModel.fileSelectActions.offer(FileSelectActions.RestartActionMode)
}
zimManageViewModel.currentPage.observe(viewLifecycleOwner, Observer<Int> { currentPage ->
if (currentPage == 1) {
finishActionMode()
}
})
zimManageViewModel.currentPage.map { it == 1 }.subscribe { if (it) finishActionMode() }
}
private fun finishActionMode() {