mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-08 14:52:13 -04:00
Use also and fold to improve zim deletion
This commit is contained in:
parent
ce6ded65d2
commit
7ef0054dd1
@ -45,15 +45,11 @@ data class DeleteFiles(private val booksOnDiskListItems: List<BookOnDisk>) :
|
|||||||
|
|
||||||
dialogShower.show(DeleteZims(name), {
|
dialogShower.show(DeleteZims(name), {
|
||||||
val booksDeleted = booksOnDiskListItems.fold(true) { acc, book ->
|
val booksDeleted = booksOnDiskListItems.fold(true) { acc, book ->
|
||||||
acc &&
|
acc && deleteSpecificZimFile(book).also {
|
||||||
(if (deleteSpecificZimFile(book)) {
|
if (it && book.file.canonicalPath == zimReaderContainer.zimCanonicalPath) {
|
||||||
if (book.file.canonicalPath == zimReaderContainer.zimCanonicalPath) {
|
zimReaderContainer.setZimFile(null)
|
||||||
zimReaderContainer.setZimFile(null)
|
}
|
||||||
}
|
}
|
||||||
true
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
activity.toast(if (booksDeleted) R.string.delete_zims_toast else R.string.delete_zim_failed)
|
activity.toast(if (booksDeleted) R.string.delete_zims_toast else R.string.delete_zim_failed)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user