mirror of
https://github.com/kiwix/kiwix-android.git
synced 2025-09-07 22:31:17 -04:00
#1972 implemented some change requests
This commit is contained in:
parent
6d82885f3c
commit
8aed396a59
@ -40,25 +40,20 @@ internal class HistoryPresenter @Inject constructor(
|
|||||||
private var disposable: Disposable? = null
|
private var disposable: Disposable? = null
|
||||||
|
|
||||||
override fun loadHistory(showHistoryCurrentBook: Boolean) {
|
override fun loadHistory(showHistoryCurrentBook: Boolean) {
|
||||||
val d = dataSource.getDateCategorizedHistory(showHistoryCurrentBook).subscribe(
|
val immutableDisposable = dataSource.getDateCategorizedHistory(showHistoryCurrentBook).subscribe(
|
||||||
{ histories: List<HistoryListItem> -> view?.updateHistoryList(histories) },
|
{ histories: List<HistoryListItem> -> view?.updateHistoryList(histories) },
|
||||||
{ e: Throwable -> Log.e("HistoryPresenter", "Failed to load history.", e) }
|
{ e: Throwable -> Log.e("HistoryPresenter", "Failed to load history.", e) }
|
||||||
)
|
)
|
||||||
disposable?.takeIf { !it.isDisposed }?.dispose()
|
disposable?.takeIf { !it.isDisposed }?.dispose()
|
||||||
disposable = d
|
compositeDisposable.add(immutableDisposable)
|
||||||
compositeDisposable.add(d)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun filterHistory(historyList: List<HistoryListItem>, newText: String) {
|
override fun filterHistory(historyList: List<HistoryListItem>, newText: String) {
|
||||||
compositeDisposable.add(Observable.just(historyList)
|
compositeDisposable.add(Observable.fromCallable{ historyList.filter { item ->
|
||||||
.flatMapIterable { flatHistoryList: List<HistoryListItem> ->
|
item is HistoryItem &&
|
||||||
flatHistoryList.filter { item ->
|
item.historyTitle.toLowerCase(Locale.getDefault())
|
||||||
item is HistoryItem &&
|
.contains(newText.toLowerCase(Locale.getDefault()))
|
||||||
item.historyTitle.toLowerCase(Locale.getDefault())
|
}}
|
||||||
.contains(newText.toLowerCase(Locale.getDefault()))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.toList()
|
|
||||||
.subscribeOn(computation)
|
.subscribeOn(computation)
|
||||||
.observeOn(mainThread)
|
.observeOn(mainThread)
|
||||||
.subscribe(
|
.subscribe(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user