mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-19 04:16:27 -04:00
#1990 lint fixes
This commit is contained in:
parent
f9cfda759b
commit
e304aabcab
@ -30,6 +30,7 @@ import org.kiwix.kiwixmobile.core.dao.NewLanguagesDao
|
||||
import org.kiwix.kiwixmobile.core.dao.NewRecentSearchDao
|
||||
import org.kiwix.kiwixmobile.core.di.qualifiers.IO
|
||||
import org.kiwix.kiwixmobile.core.di.qualifiers.MainThread
|
||||
import org.kiwix.kiwixmobile.core.extensions.HeaderizableList
|
||||
import org.kiwix.kiwixmobile.core.extensions.foldOverAddingHeaders
|
||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem
|
||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem.DateItem
|
||||
@ -67,7 +68,7 @@ class Repository @Inject internal constructor(
|
||||
override fun booksOnDiskAsListItems(): Flowable<List<BooksOnDiskListItem>> = bookDao.books()
|
||||
.map { it.sortedBy { bookOnDisk -> bookOnDisk.book.language + bookOnDisk.book.title } }
|
||||
.map {
|
||||
it.foldOverAddingHeaders(
|
||||
(it as HeaderizableList).foldOverAddingHeaders(
|
||||
{ bookOnDisk -> LanguageItem(bookOnDisk.locale) },
|
||||
{ current, next -> current.locale.displayName != next.locale.displayName })
|
||||
}
|
||||
@ -93,7 +94,7 @@ class Repository @Inject internal constructor(
|
||||
)
|
||||
)
|
||||
.map {
|
||||
it.foldOverAddingHeaders(
|
||||
(it as HeaderizableList).foldOverAddingHeaders(
|
||||
{ historyItem -> DateItem(historyItem.dateString) },
|
||||
{ current, next -> current.dateString != next.dateString })
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
package org.kiwix.kiwixmobile.core.extensions
|
||||
|
||||
|
||||
typealias HeaderizableList<T> = List<T>
|
||||
|
||||
fun <SUPERTYPE, ITEM : SUPERTYPE, HEADER : SUPERTYPE> HeaderizableList<ITEM>.foldOverAddingHeaders(
|
||||
@ -20,4 +19,3 @@ fun <SUPERTYPE, ITEM : SUPERTYPE, HEADER : SUPERTYPE> HeaderizableList<ITEM>.fol
|
||||
}
|
||||
acc
|
||||
})
|
||||
|
||||
|
@ -14,6 +14,7 @@ import io.reactivex.processors.BehaviorProcessor
|
||||
import io.reactivex.processors.PublishProcessor
|
||||
import org.kiwix.kiwixmobile.core.base.SideEffect
|
||||
import org.kiwix.kiwixmobile.core.dao.HistoryDao
|
||||
import org.kiwix.kiwixmobile.core.extensions.HeaderizableList
|
||||
import org.kiwix.kiwixmobile.core.extensions.foldOverAddingHeaders
|
||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem
|
||||
import org.kiwix.kiwixmobile.core.history.adapter.HistoryListItem.DateItem
|
||||
@ -34,9 +35,6 @@ import org.kiwix.kiwixmobile.core.history.viewmodel.State.SelectionResults
|
||||
import org.kiwix.kiwixmobile.core.history.viewmodel.effects.OpenDialogToRequestDeletionOfSelectedHistoryItems
|
||||
import org.kiwix.kiwixmobile.core.reader.ZimReaderContainer
|
||||
import org.kiwix.kiwixmobile.core.search.viewmodel.effects.Finish
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.DeleteAllHistory
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.DeleteSelectedHistory
|
||||
import org.kiwix.kiwixmobile.core.utils.SharedPreferenceUtil
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -103,13 +101,13 @@ class HistoryViewModel @Inject constructor(
|
||||
private fun searchResults(
|
||||
searchString: String,
|
||||
showAllToggle: Boolean,
|
||||
historyList: List<HistoryListItem>
|
||||
historyList: HeaderizableList<HistoryListItem>
|
||||
): List<HistoryListItem> = (historyList
|
||||
.filterIsInstance<HistoryItem>()
|
||||
.filter { h ->
|
||||
h.historyTitle.contains(searchString, true) &&
|
||||
(h.zimName == zimReaderContainer.name || showAllToggle)
|
||||
} as List<HistoryListItem>).foldOverAddingHeaders(
|
||||
} as HeaderizableList<HistoryListItem>).foldOverAddingHeaders(
|
||||
{ historyItem -> DateItem((historyItem as HistoryItem).dateString) },
|
||||
{ current, next -> (current as HistoryItem).dateString != (next as HistoryItem).dateString }
|
||||
)
|
||||
|
@ -17,17 +17,12 @@
|
||||
*/
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.reactivex.processors.PublishProcessor
|
||||
import org.kiwix.kiwixmobile.core.base.SideEffect
|
||||
import org.kiwix.kiwixmobile.core.dao.HistoryDao
|
||||
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.DeleteHistoryItems
|
||||
import org.kiwix.kiwixmobile.core.history.viewmodel.State
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.DeleteAllHistory
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.DeleteSelectedHistory
|
||||
|
||||
data class OpenDialogToRequestDeletionOfAllHistoryItems(
|
||||
private val dialogShower: DialogShower,
|
||||
|
@ -19,14 +19,10 @@ package org.kiwix.kiwixmobile.core.history.viewmodel.effects
|
||||
*/
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.MutableLiveData
|
||||
import io.reactivex.processors.PublishProcessor
|
||||
import org.kiwix.kiwixmobile.core.base.SideEffect
|
||||
import org.kiwix.kiwixmobile.core.dao.HistoryDao
|
||||
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.DeleteHistoryItems
|
||||
import org.kiwix.kiwixmobile.core.history.viewmodel.State
|
||||
import org.kiwix.kiwixmobile.core.utils.DialogShower
|
||||
import org.kiwix.kiwixmobile.core.utils.KiwixDialog.DeleteSelectedHistory
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user