From 6706af5bd7dc0d8460ec3d3de94c7278c7a2c802 Mon Sep 17 00:00:00 2001 From: Jay Date: Tue, 19 May 2020 01:05:17 -0400 Subject: [PATCH] Always expose the front view a little bit even when backdrop... (p2) Fixing the fact the filter sheet still moved the category recycler view --- .../tachiyomi/ui/library/LibraryController.kt | 2 +- .../library/category/CategoryRecyclerView.kt | 9 +++--- .../ui/library/filter/FilterBottomSheet.kt | 28 +++++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt index de4ab9a34a..3752c803ce 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/LibraryController.kt @@ -422,7 +422,7 @@ class LibraryController( createActionModeIfNeeded() } - filter_bottom_sheet.onCreate(recycler_layout) + filter_bottom_sheet.onCreate(this) filter_bottom_sheet.onGroupClicked = { when (it) { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/category/CategoryRecyclerView.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/category/CategoryRecyclerView.kt index 9c45c5e354..96b6b00938 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/category/CategoryRecyclerView.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/category/CategoryRecyclerView.kt @@ -2,16 +2,15 @@ package eu.kanade.tachiyomi.ui.library.category import android.content.Context import android.util.AttributeSet -import android.view.View import android.view.ViewGroup import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.RecyclerView import com.mikepenz.fastadapter.FastAdapter import com.mikepenz.fastadapter.adapters.ItemAdapter import com.mikepenz.fastadapter.listeners.OnBindViewHolderListenerImpl -import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.database.models.Category import eu.kanade.tachiyomi.util.system.dpToPx +import eu.kanade.tachiyomi.util.view.marginTop class CategoryRecyclerView @JvmOverloads constructor( context: Context, @@ -71,10 +70,10 @@ class CategoryRecyclerView @JvmOverloads constructor( } override fun onMeasure(widthSpec: Int, heightSpec: Int) { - val recyclerView = (parent.parent as ViewGroup).findViewById(R.id.recycler) + val recyclerView = (parent as ViewGroup) val mainView = (parent.parent.parent.parent as ViewGroup) - val top = recyclerView.paddingTop - val parent = mainView.measuredHeight - top - 50.dpToPx + val top = recyclerView.marginTop + val parent = mainView.measuredHeight - top - 100.dpToPx val heightS = if (parent > 0) { MeasureSpec.makeMeasureSpec(parent, MeasureSpec.AT_MOST) } else { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt index 2b8ec31082..3921403f46 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/library/filter/FilterBottomSheet.kt @@ -5,7 +5,6 @@ import android.content.res.Configuration import android.os.Parcelable import android.util.AttributeSet import android.view.View -import android.view.ViewGroup import android.widget.ImageView import android.widget.LinearLayout import androidx.recyclerview.widget.LinearLayoutManager @@ -20,7 +19,9 @@ import eu.kanade.tachiyomi.data.database.models.Manga import eu.kanade.tachiyomi.data.preference.PreferencesHelper import eu.kanade.tachiyomi.data.preference.getOrDefault import eu.kanade.tachiyomi.data.track.TrackManager +import eu.kanade.tachiyomi.ui.library.LibraryController import eu.kanade.tachiyomi.ui.library.LibraryGroup +import eu.kanade.tachiyomi.util.system.dpToPx import eu.kanade.tachiyomi.util.system.launchUI import eu.kanade.tachiyomi.util.view.collapse import eu.kanade.tachiyomi.util.view.gone @@ -31,6 +32,8 @@ import eu.kanade.tachiyomi.util.view.isHidden import eu.kanade.tachiyomi.util.view.updatePaddingRelative import eu.kanade.tachiyomi.util.view.visibleIf import kotlinx.android.synthetic.main.filter_bottom_sheet.view.* +import kotlinx.android.synthetic.main.library_grid_recycler.* +import kotlinx.android.synthetic.main.library_list_controller.* import kotlinx.coroutines.CoroutineStart import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -90,15 +93,17 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri var onGroupClicked: (Int) -> Unit = { _ -> } var pager: View? = null + var controller: LibraryController? = null - fun onCreate(pagerView: View) { + fun onCreate(controller: LibraryController) { clearButton = clear_button filter_layout.removeView(clearButton) sheetBehavior = BottomSheetBehavior.from(this) sheetBehavior?.isHideable = true - pager = pagerView - val shadow2: View = (pagerView.parent.parent as ViewGroup).findViewById(R.id.shadow2) - val shadow: View = (pagerView.parent.parent as ViewGroup).findViewById(R.id.shadow) + this.controller = controller + pager = controller.recycler + val shadow2: View = controller.shadow2 + val shadow: View = controller.shadow sheetBehavior?.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { override fun onSlide(bottomSheet: View, progress: Float) { pill.alpha = (1 - max(0f, progress)) * 0.25f @@ -173,10 +178,10 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri } private fun stateChanged(state: Int) { - val shadow = ((pager?.parent as? ViewGroup)?.findViewById(R.id.shadow) as? View) + val shadow = controller?.shadow ?: return if (state == BottomSheetBehavior.STATE_COLLAPSED) { - shadow?.alpha = 1f - pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0) + shadow.alpha = 1f + pager?.updatePaddingRelative(bottom = sheetBehavior?.peekHeight ?: 0 + 10.dpToPx) } if (state == BottomSheetBehavior.STATE_EXPANDED) { pill.alpha = 0f @@ -184,8 +189,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri if (state == BottomSheetBehavior.STATE_HIDDEN) { onGroupClicked(ACTION_HIDE_FILTER_TIP) reSortViews() - shadow?.alpha = 0f - pager?.updatePaddingRelative(bottom = 0) + shadow.alpha = 0f + pager?.updatePaddingRelative(bottom = 10.dpToPx) } } @@ -202,9 +207,8 @@ class FilterBottomSheet @JvmOverloads constructor(context: Context, attrs: Attri ?: if (sheetBehavior.isExpanded()) 1f else 0f val percent = (trueProgress * 100).roundToInt() val value = (percent * (maxHeight - minHeight) / 100) + minHeight - val height = context.resources.getDimensionPixelSize(R.dimen.rounder_radius) if (trueProgress >= 0) - pager?.updatePaddingRelative(bottom = value - height) + pager?.updatePaddingRelative(bottom = value + 10.dpToPx) else pager?.updatePaddingRelative(bottom = (minHeight * (1 + trueProgress)).toInt()) }