mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-23 04:33:54 -04:00
#2159 deletion now works from the library fragment destination
This commit is contained in:
parent
5cc306a558
commit
6153e68aff
@ -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.core.zim_manager.fileselect_view.adapter.BookOnDiskDelegate
|
||||||
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
import org.kiwix.kiwixmobile.kiwixActivityComponent
|
||||||
import org.kiwix.kiwixmobile.local_file_transfer.LocalFileTransferActivity
|
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
|
import org.kiwix.kiwixmobile.zim_manager.fileselect_view.ZimFileSelectFragment
|
||||||
|
|
||||||
class LocalLibraryFragment : 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 {
|
override val bookDelegate: BookOnDiskDelegate.BookDelegate by lazy {
|
||||||
BookOnDiskDelegate.BookDelegate(sharedPreferenceUtil,
|
BookOnDiskDelegate.BookDelegate(sharedPreferenceUtil,
|
||||||
{ offerAction(ZimManageViewModel.FileSelectActions.RequestNavigateTo(it)) },
|
{ offerAction(RequestNavigateTo(it)) },
|
||||||
{ offerAction(ZimManageViewModel.FileSelectActions.RequestMultiSelection(it)) },
|
{ offerAction(RequestMultiSelection(it)) },
|
||||||
{ offerAction(ZimManageViewModel.FileSelectActions.RequestSelect(it)) })
|
{ offerAction(RequestSelect(it)) })
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun offerAction(action: ZimManageViewModel.FileSelectActions) {
|
private fun offerAction(action: FileSelectActions) {
|
||||||
zimManageViewModel.fileSelectActions.offer(action)
|
zimManageViewModel.fileSelectActions.offer(action)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,11 +59,10 @@ class LocalLibraryFragment : ZimFileSelectFragment() {
|
|||||||
|
|
||||||
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
||||||
inflater.inflate(R.menu.menu_zim_manager, menu)
|
inflater.inflate(R.menu.menu_zim_manager, menu)
|
||||||
searchItem = menu.findItem(R.id.action_search)
|
val searchItem = menu.findItem(R.id.action_search)
|
||||||
languageItem = menu.findItem(R.id.select_language)
|
val languageItem = menu.findItem(R.id.select_language)
|
||||||
getZimItem = menu.findItem(R.id.get_zim_nearby_device)
|
languageItem.isVisible = false
|
||||||
languageItem?.isVisible = false
|
searchItem.isVisible = false
|
||||||
searchItem?.isVisible = false
|
|
||||||
super.onCreateOptionsMenu(menu, inflater)
|
super.onCreateOptionsMenu(menu, inflater)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.zim_manager.fileselect_view.effects
|
|||||||
|
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import org.kiwix.kiwixmobile.R
|
import org.kiwix.kiwixmobile.R
|
||||||
|
import org.kiwix.kiwixmobile.core.base.BaseActivity
|
||||||
import org.kiwix.kiwixmobile.core.base.SideEffect
|
import org.kiwix.kiwixmobile.core.base.SideEffect
|
||||||
import org.kiwix.kiwixmobile.core.dao.NewBookDao
|
import org.kiwix.kiwixmobile.core.dao.NewBookDao
|
||||||
import org.kiwix.kiwixmobile.core.extensions.toast
|
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.KiwixDialog.DeleteZims
|
||||||
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
|
import org.kiwix.kiwixmobile.core.utils.files.FileUtils
|
||||||
import org.kiwix.kiwixmobile.core.zim_manager.fileselect_view.adapter.BooksOnDiskListItem.BookOnDisk
|
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
|
import javax.inject.Inject
|
||||||
|
|
||||||
data class DeleteFiles(private val booksOnDiskListItems: List<BookOnDisk>) :
|
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
|
@Inject lateinit var zimReaderContainer: ZimReaderContainer
|
||||||
|
|
||||||
override fun invokeWith(activity: AppCompatActivity) {
|
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 }
|
val name = booksOnDiskListItems.joinToString(separator = "\n") { it.book.title }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user