#2159 deletion now works from the library fragment destination

This commit is contained in:
HissPirat 2020-06-23 13:46:30 +02:00
parent 5cc306a558
commit 6153e68aff
2 changed files with 15 additions and 16 deletions

View File

@ -34,23 +34,22 @@ import org.kiwix.kiwixmobile.core.utils.LanguageUtils
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate
import org.kiwix.kiwixmobile.kiwixActivityComponent
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestMultiSelection
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestNavigateTo
import org.kiwix.kiwixmobile.zim_manager.ZimManageViewModel.FileSelectActions.RequestSelect
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment
class LocalLibraryFragment : ZimFileSelectFragment() {
private var searchItem: MenuItem? = null
private var languageItem: MenuItem? = null
private var getZimItem: MenuItem? = null
override val bookDelegate: BookOnDiskDelegate.BookDelegate by lazy {
BookOnDiskDelegate.BookDelegate(sharedPreferenceUtil,
{ offerAction(ZimManageViewModel.FileSelectActions.RequestNavigateTo(it)) },
{ offerAction(ZimManageViewModel.FileSelectActions.RequestMultiSelection(it)) },
{ offerAction(ZimManageViewModel.FileSelectActions.RequestSelect(it)) })
{ offerAction(RequestNavigateTo(it)) },
{ offerAction(RequestMultiSelection(it)) },
{ offerAction(RequestSelect(it)) })
}
private fun offerAction(action: ZimManageViewModel.FileSelectActions) {
private fun offerAction(action: FileSelectActions) {
zimManageViewModel.fileSelectActions.offer(action)
}
@ -60,11 +59,10 @@ class LocalLibraryFragment : ZimFileSelectFragment() {
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
inflater.inflate(R.menu.menu_zim_manager, menu)
searchItem = menu.findItem(R.id.action_search)
languageItem = menu.findItem(R.id.select_language)
getZimItem = menu.findItem(R.id.get_zim_nearby_device)
languageItem?.isVisible = false
searchItem?.isVisible = false
val searchItem = menu.findItem(R.id.action_search)
val languageItem = menu.findItem(R.id.select_language)
languageItem.isVisible = false
searchItem.isVisible = false
super.onCreateOptionsMenu(menu, inflater)
}

View File

@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects
import androidx.appcompat.app.AppCompatActivity
import org.kiwix.kiwixmobile.R
import org.kiwix.kiwixmobile.core.base.BaseActivity
import org.kiwix.kiwixmobile.core.base.SideEffect
import org.kiwix.kiwixmobile.core.dao.NewBookDao
import org.kiwix.kiwixmobile.core.extensions.toast
@ -28,7 +29,7 @@ import org.kiwix.kiwixmobile.core.utils.DialogShower
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.DeleteZims
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
import org.kiwix.kiwixmobile.zim_manager.ZimManageActivity
import org.kiwix.kiwixmobile.kiwixActivityComponent
import javax.inject.Inject
data class DeleteFiles(private val booksOnDiskListItems: List<BookOnDisk>) :
@ -39,7 +40,7 @@ data class DeleteFiles(private val booksOnDiskListItems: List<BookOnDisk>) :
@Inject lateinit var zimReaderContainer: ZimReaderContainer
override fun invokeWith(activity: AppCompatActivity) {
(activity as ZimManageActivity).cachedComponent.inject(this)
(activity as BaseActivity).kiwixActivityComponent.inject(this)
val name = booksOnDiskListItems.joinToString(separator = "\n") { it.book.title }