mirror of
https://github.com/mihonapp/mihon.git
synced 2025-11-11 11:38:56 +01:00
Allow to update one category
This commit is contained in:
@@ -156,8 +156,8 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
searchView.clearFocus()
|
||||
}
|
||||
|
||||
filterDownloadedItem.isChecked = isFilterDownloaded;
|
||||
filterUnreadItem.isChecked = isFilterUnread;
|
||||
filterDownloadedItem.isChecked = isFilterDownloaded
|
||||
filterUnreadItem.isChecked = isFilterUnread
|
||||
|
||||
searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
|
||||
override fun onQueryTextSubmit(query: String): Boolean {
|
||||
@@ -200,7 +200,13 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
// Apply filter
|
||||
onFilterCheckboxChanged()
|
||||
}
|
||||
R.id.action_refresh -> LibraryUpdateService.start(activity, true) // Force refresh
|
||||
R.id.action_update_library -> {
|
||||
LibraryUpdateService.start(activity, true)
|
||||
}
|
||||
R.id.action_update_category -> {
|
||||
val category = presenter.categories[view_pager.currentItem]
|
||||
LibraryUpdateService.start(activity, true, category)
|
||||
}
|
||||
R.id.action_edit_categories -> {
|
||||
val intent = CategoryActivity.newIntent(activity)
|
||||
startActivity(intent)
|
||||
@@ -218,7 +224,7 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
presenter.updateLibrary()
|
||||
adapter.notifyDataSetChanged()
|
||||
adapter.refreshRegisteredAdapters()
|
||||
activity.supportInvalidateOptionsMenu();
|
||||
activity.supportInvalidateOptionsMenu()
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,12 +255,10 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
// Get the current active category.
|
||||
val activeCat = if (adapter.categories != null) view_pager.currentItem else activeCategory
|
||||
|
||||
// Add the default category if it contains manga.
|
||||
if (mangaMap[0] != null) {
|
||||
setCategories(arrayListOf(Category.createDefault()) + categories)
|
||||
} else {
|
||||
setCategories(categories)
|
||||
}
|
||||
// Set the categories
|
||||
adapter.categories = categories
|
||||
tabs.setupWithViewPager(view_pager)
|
||||
tabs.visibility = if (categories.size <= 1) View.GONE else View.VISIBLE
|
||||
|
||||
// Restore active category.
|
||||
view_pager.setCurrentItem(activeCat, false)
|
||||
@@ -270,17 +274,6 @@ class LibraryFragment : BaseRxFragment<LibraryPresenter>(), ActionMode.Callback
|
||||
presenter.libraryMangaSubject.onNext(LibraryMangaEvent(mangaMap))
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the categories in the adapter and the tab layout.
|
||||
*
|
||||
* @param categories the categories to set.
|
||||
*/
|
||||
private fun setCategories(categories: List<Category>) {
|
||||
adapter.categories = categories
|
||||
tabs.setupWithViewPager(view_pager)
|
||||
tabs.visibility = if (categories.size <= 1) View.GONE else View.VISIBLE
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title of the action mode.
|
||||
*
|
||||
|
||||
@@ -98,7 +98,15 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||
*/
|
||||
fun getLibraryObservable(): Observable<Pair<List<Category>, Map<Int, List<Manga>>>> {
|
||||
return Observable.combineLatest(getCategoriesObservable(), getLibraryMangasObservable(),
|
||||
{ a, b -> Pair(a, b) })
|
||||
{ dbCategories, libraryManga ->
|
||||
val categories = if (libraryManga.containsKey(0))
|
||||
arrayListOf(Category.createDefault()) + dbCategories
|
||||
else
|
||||
dbCategories
|
||||
|
||||
this.categories = categories
|
||||
Pair(categories, libraryManga)
|
||||
})
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
}
|
||||
|
||||
@@ -109,7 +117,6 @@ class LibraryPresenter : BasePresenter<LibraryFragment>() {
|
||||
*/
|
||||
fun getCategoriesObservable(): Observable<List<Category>> {
|
||||
return db.getCategories().asRxObservable()
|
||||
.doOnNext { categories -> this.categories = categories }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user