mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-30 16:43:38 -04:00
Fixed all bookmarks automatically selected if we select only one bookmark
This commit is contained in:
parent
a7c4faddcb
commit
f0aebc1eaa
@ -20,6 +20,7 @@ package org.kiwix.kiwixmobile.core.page.viewmodel
|
|||||||
|
|
||||||
import org.kiwix.kiwixmobile.core.page.adapter.Page
|
import org.kiwix.kiwixmobile.core.page.adapter.Page
|
||||||
import org.kiwix.kiwixmobile.core.page.adapter.PageRelated
|
import org.kiwix.kiwixmobile.core.page.adapter.PageRelated
|
||||||
|
import org.kiwix.kiwixmobile.core.page.bookmark.adapter.LibkiwixBookmarkItem
|
||||||
|
|
||||||
abstract class PageState<T : Page> {
|
abstract class PageState<T : Page> {
|
||||||
abstract val pageItems: List<T>
|
abstract val pageItems: List<T>
|
||||||
@ -36,9 +37,18 @@ abstract class PageState<T : Page> {
|
|||||||
|
|
||||||
fun getItemsAfterToggleSelectionOfItem(page: Page): List<T> {
|
fun getItemsAfterToggleSelectionOfItem(page: Page): List<T> {
|
||||||
return pageItems.map {
|
return pageItems.map {
|
||||||
if (it.id == page.id) it.apply {
|
// check if the current item is `LibkiwixBookmarkItem` because we have not saving
|
||||||
isSelected = !isSelected
|
// the bookmarks in database so it does not have any unique value so to get the
|
||||||
} else it
|
// selected items we check for uri since url is unique for every bookmark.
|
||||||
|
if (it is LibkiwixBookmarkItem) {
|
||||||
|
if (it.url == page.url) it.apply {
|
||||||
|
isSelected = !isSelected
|
||||||
|
} else it
|
||||||
|
} else {
|
||||||
|
if (it.id == page.id) it.apply {
|
||||||
|
isSelected = !isSelected
|
||||||
|
} else it
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user