mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-18 03:45:33 -04:00
#1990 deletion of items works!
This commit is contained in:
parent
84f7fc0393
commit
5faa933c41
@ -28,6 +28,7 @@ import org.kiwix.kiwixmobile.core.history.adapter.HistoryAdapter2
|
|||||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryDelegate.HistoryItemDelegate
|
import org.kiwix.kiwixmobile.core.history.adapter.HistoryDelegate.HistoryItemDelegate
|
||||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem.HistoryItem
|
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem.HistoryItem
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action
|
||||||
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.DeleteHistoryItems
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.Filter
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.Filter
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.OnItemLongClick
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.OnItemLongClick
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ToggleShowHistoryFromAllBooks
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ToggleShowHistoryFromAllBooks
|
||||||
@ -78,15 +79,18 @@ class HistoryActivity : OnItemClickListener, BaseActivity() {
|
|||||||
mode: ActionMode,
|
mode: ActionMode,
|
||||||
item: MenuItem
|
item: MenuItem
|
||||||
): Boolean {
|
): Boolean {
|
||||||
historyViewModel.actions.offer(Action.ExitActionModeMenu)
|
|
||||||
if (item.itemId == id.menu_context_delete) {
|
if (item.itemId == id.menu_context_delete) {
|
||||||
dialogShower.show(DeleteHistory, {
|
dialogShower.show(DeleteHistory, {
|
||||||
val deleteList = historyAdapter.items.filterIsInstance<HistoryItem>().filter { it.isSelected }
|
historyViewModel.actions.offer(
|
||||||
// presenter.deleteHistory(deleteList)
|
DeleteHistoryItems(historyAdapter.items.filterIsInstance<HistoryItem>().filter { it.isSelected })
|
||||||
|
)
|
||||||
|
historyViewModel.actions.offer(Action.ExitActionModeMenu)
|
||||||
mode.finish()
|
mode.finish()
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
historyViewModel.actions.offer(Action.ExitActionModeMenu)
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ sealed class Action {
|
|||||||
data class OnItemLongClick(val historyItem: HistoryItem) : Action()
|
data class OnItemLongClick(val historyItem: HistoryItem) : Action()
|
||||||
data class ToggleShowHistoryFromAllBooks(val isChecked: Boolean) : Action()
|
data class ToggleShowHistoryFromAllBooks(val isChecked: Boolean) : Action()
|
||||||
data class Filter(val searchTerm: String) : Action()
|
data class Filter(val searchTerm: String) : Action()
|
||||||
|
data class DeleteHistoryItems(val itemsToDelete: List<HistoryItem>) : Action()
|
||||||
data class UserClickedItem(val historyItem: HistoryItem) : Action()
|
data class UserClickedItem(val historyItem: HistoryItem) : Action()
|
||||||
data class ShowAllSwitchToggled(val isToggled: Boolean) : Action()
|
data class ShowAllSwitchToggled(val isToggled: Boolean) : Action()
|
||||||
data class ConfirmedDelete(val historyListItems: List<HistoryListItem.HistoryItem>) : Action()
|
data class ConfirmedDelete(val historyListItems: List<HistoryListItem.HistoryItem>) : Action()
|
||||||
|
@ -19,6 +19,7 @@ import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem
|
|||||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem.HistoryItem
|
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem.HistoryItem
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ConfirmedDelete
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ConfirmedDelete
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.CreatedWithIntent
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.CreatedWithIntent
|
||||||
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.DeleteHistoryItems
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ExitActionModeMenu
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ExitActionModeMenu
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ExitHistory
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.ExitHistory
|
||||||
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.Filter
|
import org.kiwix.kiwixmobile.core.history.viewmodel.Action.Filter
|
||||||
@ -122,6 +123,7 @@ class HistoryViewModel @Inject constructor(
|
|||||||
is ConfirmedDelete -> deleteItemAndShowToast(it)
|
is ConfirmedDelete -> deleteItemAndShowToast(it)
|
||||||
is OnItemLongClick -> selectItemAndOpenSelectionMode(it.historyItem)
|
is OnItemLongClick -> selectItemAndOpenSelectionMode(it.historyItem)
|
||||||
is OnItemClick -> appendItemToSelectionOrOpenIt(it)
|
is OnItemClick -> appendItemToSelectionOrOpenIt(it)
|
||||||
|
is DeleteHistoryItems -> historyDao.deleteHistory(it.itemsToDelete)
|
||||||
ReceivedPromptForSpeechInput -> effects.offer(StartSpeechInput(actions))
|
ReceivedPromptForSpeechInput -> effects.offer(StartSpeechInput(actions))
|
||||||
ExitActionModeMenu -> unselectAllItems.offer(true)
|
ExitActionModeMenu -> unselectAllItems.offer(true)
|
||||||
StartSpeechInputFailed -> effects.offer(ShowToast(R.string.speech_not_supported))
|
StartSpeechInputFailed -> effects.offer(ShowToast(R.string.speech_not_supported))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user