Filters sheet can be hidden while active now

This commit is contained in:
Jay 2020-05-02 11:47:07 -04:00
parent 54a0c3fded
commit 44bb8de84f
2 changed files with 2 additions and 13 deletions

View File

@ -151,10 +151,10 @@ class LibraryController(
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) {
super.onScrolled(recyclerView, dx, dy)
val order = getCategoryOrder()
if (filter_bottom_sheet.canHide()) {
if (filter_bottom_sheet.sheetBehavior?.state != BottomSheetBehavior.STATE_HIDDEN) {
scrollDistance += abs(dy)
if (scrollDistance > scrollDistanceTilHidden) {
filter_bottom_sheet.hideIfPossible()
filter_bottom_sheet.sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
scrollDistance = 0f
}
} else scrollDistance = 0f

View File

@ -103,7 +103,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
}
val activeFilters = hasActiveFiltersFromPref()
sheetBehavior?.isHideable = !activeFilters
if (activeFilters && sheetBehavior?.state == BottomSheetBehavior.STATE_HIDDEN &&
sheetBehavior?.skipCollapsed == false)
sheetBehavior?.state = BottomSheetBehavior.STATE_COLLAPSED
@ -285,21 +284,12 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
filterItems.remove(trackers!!)
}
val hasFilters = hasActiveFilters()
sheetBehavior?.isHideable = !hasFilters
if (hasFilters && clearButton.parent == null)
filter_layout.addView(clearButton, 0)
else if (!hasFilters && clearButton.parent != null)
filter_layout.removeView(clearButton)
}
fun hideIfPossible() {
if (!hasActiveFilters() && sheetBehavior?.isHideable == true)
sheetBehavior?.state = BottomSheetBehavior.STATE_HIDDEN
}
fun canHide(): Boolean = sheetBehavior?.isHideable == true && sheetBehavior?.state !=
BottomSheetBehavior.STATE_HIDDEN
private fun clearFilters() {
preferences.filterDownloaded().set(0)
preferences.filterUnread().set(0)
@ -318,7 +308,6 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri
filterItems.remove(trackers!!)
reSortViews()
onGroupClicked(ACTION_FILTER)
sheetBehavior?.isHideable = true
}
private fun reSortViews() {