Making sure display options don't display multiple times

This commit is contained in:
Jays2Kings 2021-04-16 02:25:20 -04:00
parent 650c3bc4f8
commit 8f2a5e1453

View File

@ -376,6 +376,13 @@ class LibraryController(
filterTooltip?.show() filterTooltip?.show()
} }
private fun showDisplayOptions() {
if (displaySheet == null) {
displaySheet = TabbedLibraryDisplaySheet(this)
displaySheet?.show()
}
}
private fun closeTip() { private fun closeTip() {
if (filterTooltip != null) { if (filterTooltip != null) {
filterTooltip?.close() filterTooltip?.close()
@ -392,7 +399,6 @@ class LibraryController(
adapter = LibraryCategoryAdapter(this) adapter = LibraryCategoryAdapter(this)
setRecyclerLayout() setRecyclerLayout()
binding.libraryGridRecycler.recycler.manager.spanSizeLookup = ( binding.libraryGridRecycler.recycler.manager.spanSizeLookup = (
object : GridLayoutManager.SpanSizeLookup() { object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int { override fun getSpanSize(position: Int): Int {
@ -515,10 +521,7 @@ class LibraryController(
FilterBottomSheet.ACTION_REFRESH -> onRefresh() FilterBottomSheet.ACTION_REFRESH -> onRefresh()
FilterBottomSheet.ACTION_FILTER -> onFilterChanged() FilterBottomSheet.ACTION_FILTER -> onFilterChanged()
FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> showFilterTip() FilterBottomSheet.ACTION_HIDE_FILTER_TIP -> showFilterTip()
FilterBottomSheet.ACTION_DISPLAY -> { FilterBottomSheet.ACTION_DISPLAY -> showDisplayOptions()
displaySheet = TabbedLibraryDisplaySheet(this)
displaySheet?.show()
}
FilterBottomSheet.ACTION_EXPAND_COLLAPSE_ALL -> presenter.toggleAllCategoryVisibility() FilterBottomSheet.ACTION_EXPAND_COLLAPSE_ALL -> presenter.toggleAllCategoryVisibility()
FilterBottomSheet.ACTION_GROUP_BY -> { FilterBottomSheet.ACTION_GROUP_BY -> {
val groupItems = mutableListOf(BY_DEFAULT, BY_TAG, BY_SOURCE, BY_STATUS) val groupItems = mutableListOf(BY_DEFAULT, BY_TAG, BY_SOURCE, BY_STATUS)
@ -826,7 +829,11 @@ class LibraryController(
override fun onDestroyView(view: View) { override fun onDestroyView(view: View) {
LibraryUpdateService.removeListener(this) LibraryUpdateService.removeListener(this)
destroyActionModeIfNeeded() destroyActionModeIfNeeded()
if (isBindingInitialized) {
binding.libraryGridRecycler.recycler.removeOnScrollListener(scrollListener) binding.libraryGridRecycler.recycler.removeOnScrollListener(scrollListener)
}
displaySheet?.dismiss()
displaySheet = null
super.onDestroyView(view) super.onDestroyView(view)
} }
@ -1364,7 +1371,7 @@ class LibraryController(
when { when {
binding.filterBottomSheet.filterBottomSheet.sheetBehavior.isHidden() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.collapse() binding.filterBottomSheet.filterBottomSheet.sheetBehavior.isHidden() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.collapse()
!binding.filterBottomSheet.filterBottomSheet.sheetBehavior.isExpanded() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.expand() !binding.filterBottomSheet.filterBottomSheet.sheetBehavior.isExpanded() -> binding.filterBottomSheet.filterBottomSheet.sheetBehavior?.expand()
else -> TabbedLibraryDisplaySheet(this).show() else -> showDisplayOptions()
} }
} }