Updating for change of category pref

This commit is contained in:
Jay 2020-02-08 12:26:46 -08:00
parent 596597c910
commit a9a94d7654
3 changed files with 15 additions and 11 deletions

View File

@ -411,7 +411,7 @@ class LibraryPresenter(
private fun getLibraryFromDB(): Library { private fun getLibraryFromDB(): Library {
val categories = db.getCategories().executeAsBlocking().toMutableList() val categories = db.getCategories().executeAsBlocking().toMutableList()
val libraryAsList = preferences.libraryAsList() val libraryAsList = preferences.libraryAsList()
val showCategories = preferences.showCategories().getOrDefault() val showCategories = !preferences.hideCategories().getOrDefault()
var libraryManga = db.getLibraryMangas().executeAsBlocking() var libraryManga = db.getLibraryMangas().executeAsBlocking()
if (!showCategories) if (!showCategories)
libraryManga = libraryManga.distinctBy { it.id } libraryManga = libraryManga.distinctBy { it.id }
@ -424,7 +424,7 @@ class LibraryPresenter(
categories.add(0, createDefaultCategory()) categories.add(0, createDefaultCategory())
this.allCategories = categories this.allCategories = categories
this.categories = if (!preferences.showCategories().getOrDefault()) this.categories = if (preferences.hideCategories().getOrDefault())
arrayListOf(createDefaultCategory()) arrayListOf(createDefaultCategory())
else categories else categories
return Library(this.categories, libraryMap) return Library(this.categories, libraryMap)

View File

@ -231,7 +231,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
val sortingMode = preferences.librarySortingMode().getOrDefault() val sortingMode = preferences.librarySortingMode().getOrDefault()
return if (!trueSort && sortingMode == LibrarySort.DRAG_AND_DROP && return if (!trueSort && sortingMode == LibrarySort.DRAG_AND_DROP &&
lastCategory != null && lastCategory != null &&
preferences.showCategories().getOrDefault()) { !preferences.hideCategories().getOrDefault()) {
when (lastCategory?.mangaSort) { when (lastCategory?.mangaSort) {
'a', 'b' -> LibrarySort.ALPHA 'a', 'b' -> LibrarySort.ALPHA
'c', 'd' -> LibrarySort.LAST_UPDATED 'c', 'd' -> LibrarySort.LAST_UPDATED
@ -247,7 +247,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
private fun getFilters(): List<Int> { private fun getFilters(): List<Int> {
val filters = mutableListOf<Int>() val filters = mutableListOf<Int>()
val categoriesOn = preferences.showCategories().getOrDefault() val categoriesOn = !preferences.hideCategories().getOrDefault()
if (!categoriesOn) { if (!categoriesOn) {
filters.add(R.string.hiding_categories) filters.add(R.string.hiding_categories)
} }
@ -324,7 +324,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
} }
launchUI { launchUI {
categories.setState(!preferences.showCategories().getOrDefault()) categories.setState(preferences.hideCategories().getOrDefault())
downloaded.setState(preferences.filterDownloaded()) downloaded.setState(preferences.filterDownloaded())
completed.setState(preferences.filterCompleted()) completed.setState(preferences.filterCompleted())
unread.setState(preferences.filterUnread()) unread.setState(preferences.filterUnread())
@ -479,7 +479,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
private fun setCatSortText() { private fun setCatSortText() {
launchUI { launchUI {
if (preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP && preferences.showCategories().getOrDefault() && lastCategory != null) { if (preferences.librarySortingMode().getOrDefault() == LibrarySort.DRAG_AND_DROP &&
!preferences.hideCategories().getOrDefault() && lastCategory != null) {
val sortId = withContext(Dispatchers.IO) { sorting() } val sortId = withContext(Dispatchers.IO) { sorting() }
val drawable = withContext(Dispatchers.IO) { val drawable = withContext(Dispatchers.IO) {
tintVector( tintVector(
@ -536,7 +537,7 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference:Boolean) { override fun onFilterClicked(view: FilterTagGroup, index: Int, updatePreference:Boolean) {
if (updatePreference) { if (updatePreference) {
if (view == categories) { if (view == categories) {
preferences.showCategories().set(index != 0) preferences.hideCategories().set(index == 0)
onGroupClicked(ACTION_REFRESH) onGroupClicked(ACTION_REFRESH)
} else { } else {
when (view) { when (view) {
@ -559,10 +560,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
} }
private fun clearFilters() { private fun clearFilters() {
val action = if (preferences.showCategories().getOrDefault()) ACTION_REFRESH val action = if (preferences.hideCategories().getOrDefault()) ACTION_REFRESH
else ACTION_FILTER else ACTION_FILTER
preferences.showCategories().set(true) preferences.hideCategories().set(false)
preferences.filterDownloaded().set(0) preferences.filterDownloaded().set(0)
preferences.filterUnread().set(0) preferences.filterUnread().set(0)
preferences.filterCompleted().set(0) preferences.filterCompleted().set(0)

View File

@ -19,7 +19,10 @@
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:orientation="vertical"> android:orientation="vertical">
<HorizontalScrollView <HorizontalScrollView
@ -91,7 +94,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:clickable="true" android:clickable="true"
android:drawablePadding="16dp" android:drawablePadding="6dp"
android:background="@drawable/square_ripple" android:background="@drawable/square_ripple"
android:focusable="true" android:focusable="true"
android:gravity="center" android:gravity="center"