Minor code cleanup
This commit is contained in:
@@ -178,7 +178,7 @@ class LibraryController(
|
||||
override fun createSecondaryDrawer(drawer: DrawerLayout): ViewGroup {
|
||||
val view = drawer.inflate(R.layout.library_drawer) as LibraryNavigationView
|
||||
navView = view
|
||||
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, Gravity.END)
|
||||
drawer.setDrawerLockMode(DrawerLayout.LOCK_MODE_UNLOCKED, GravityCompat.END)
|
||||
|
||||
navView?.onGroupClicked = { group ->
|
||||
when (group) {
|
||||
|
||||
@@ -209,9 +209,9 @@ class LibraryNavigationView @JvmOverloads constructor(context: Context, attrs: A
|
||||
item.group.items.forEach { (it as Item.Radio).checked = false }
|
||||
item.checked = true
|
||||
|
||||
preferences.libraryAsList().set(if (item == list) true else false)
|
||||
preferences.libraryAsList().set(item == list)
|
||||
|
||||
item.group.items.forEach { adapter.notifyItemChanged(it) }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,12 +89,15 @@ class LibraryPresenter(
|
||||
fun subscribeLibrary() {
|
||||
if (librarySubscription.isNullOrUnsubscribed()) {
|
||||
librarySubscription = getLibraryObservable()
|
||||
.combineLatest(downloadTriggerRelay.observeOn(Schedulers.io()),
|
||||
{ lib, _ -> lib.apply { setDownloadCount(mangaMap) } })
|
||||
.combineLatest(filterTriggerRelay.observeOn(Schedulers.io()),
|
||||
{ lib, _ -> lib.copy(mangaMap = applyFilters(lib.mangaMap)) })
|
||||
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io()),
|
||||
{ lib, _ -> lib.copy(mangaMap = applySort(lib.mangaMap)) })
|
||||
.combineLatest(downloadTriggerRelay.observeOn(Schedulers.io())) {
|
||||
lib, _ -> lib.apply { setDownloadCount(mangaMap) }
|
||||
}
|
||||
.combineLatest(filterTriggerRelay.observeOn(Schedulers.io())) {
|
||||
lib, _ -> lib.copy(mangaMap = applyFilters(lib.mangaMap))
|
||||
}
|
||||
.combineLatest(sortTriggerRelay.observeOn(Schedulers.io())) {
|
||||
lib, _ -> lib.copy(mangaMap = applySort(lib.mangaMap))
|
||||
}
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribeLatestCache({ view, (categories, mangaMap) ->
|
||||
view.onNextLibraryUpdate(categories, mangaMap)
|
||||
@@ -222,16 +225,16 @@ class LibraryPresenter(
|
||||
* @return an observable of the categories and its manga.
|
||||
*/
|
||||
private fun getLibraryObservable(): Observable<Library> {
|
||||
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable(),
|
||||
{ dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.containsKey(0))
|
||||
arrayListOf(Category.createDefault()) + dbCategories
|
||||
else
|
||||
dbCategories
|
||||
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable()) {
|
||||
dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.containsKey(0))
|
||||
arrayListOf(Category.createDefault()) + dbCategories
|
||||
else
|
||||
dbCategories
|
||||
|
||||
this.categories = categories
|
||||
Library(categories, libraryManga)
|
||||
})
|
||||
this.categories = categories
|
||||
Library(categories, libraryManga)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user