From e779698746a52c1d8576c9ef0ebd64b2dc75068c Mon Sep 17 00:00:00 2001 From: OxygenCobalt Date: Sat, 30 Oct 2021 18:31:57 -0600 Subject: [PATCH] home: remove appbar collapse behavior Remove the appbar collapse behavior. It's just causing too much bugs and phones are so big now that the lost space really doesn't matter. --- .../org/oxycblt/auxio/home/HomeFragment.kt | 43 ------------------- app/src/main/res/layout/fragment_home.xml | 1 - 2 files changed, 44 deletions(-) diff --git a/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt b/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt index 8b331f89a..db6b65d92 100644 --- a/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt +++ b/app/src/main/java/org/oxycblt/auxio/home/HomeFragment.kt @@ -23,16 +23,13 @@ import android.view.LayoutInflater import android.view.MenuItem import android.view.View import android.view.ViewGroup -import androidx.coordinatorlayout.widget.CoordinatorLayout import androidx.core.view.iterator -import androidx.core.view.updatePaddingRelative import androidx.fragment.app.Fragment import androidx.fragment.app.activityViewModels import androidx.navigation.fragment.findNavController import androidx.recyclerview.widget.RecyclerView import androidx.viewpager2.adapter.FragmentStateAdapter import androidx.viewpager2.widget.ViewPager2 -import com.google.android.material.appbar.AppBarLayout import com.google.android.material.tabs.TabLayoutMediator import org.oxycblt.auxio.MainFragmentDirections import org.oxycblt.auxio.R @@ -77,46 +74,6 @@ class HomeFragment : Fragment() { binding.lifecycleOwner = viewLifecycleOwner - binding.homeAppbar.apply { - // I have no idea how to clip the collapsing toolbar while still making the elevation - // overlay bleed into the status bar, so I take the easy way out and just fade the - // toolbar when the offset changes. - // Note: Don't merge this with the other OnOffsetChangedListener, as this one needs - // to be added pre-start to work correctly while the other one needs to be posted to - // work correctly - addOnOffsetChangedListener( - AppBarLayout.OnOffsetChangedListener { _, verticalOffset -> - binding.homeToolbar.alpha = (binding.homeToolbar.height + verticalOffset) / - binding.homeToolbar.height.toFloat() - } - ) - - // One issue that comes with using our fast scroller is that it allows scrolling - // without the AppBar actually being collapsed in the process. This results in - // the RecyclerView being clipped if you scroll down far enough. To fix this, we - // add another OnOffsetChangeListener that adds padding to the RecyclerView whenever - // the Toolbar is collapsed. This is not really ideal, as it forces a relayout and - // some edge-effect glitches whenever we scroll, but its the best we can do. - post { - val vOffset = ( - (layoutParams as CoordinatorLayout.LayoutParams) - .behavior as AppBarLayout.Behavior - ).topAndBottomOffset - - binding.homePager.updatePaddingRelative( - bottom = binding.homeAppbar.totalScrollRange + vOffset - ) - - binding.homeAppbar.addOnOffsetChangedListener( - AppBarLayout.OnOffsetChangedListener { _, verticalOffset -> - binding.homePager.updatePaddingRelative( - bottom = binding.homeAppbar.totalScrollRange + verticalOffset - ) - } - ) - } - } - binding.homeToolbar.apply { setOnMenuItemClickListener { item -> when (item.itemId) { diff --git a/app/src/main/res/layout/fragment_home.xml b/app/src/main/res/layout/fragment_home.xml index 52fbed9d8..cc8d524ef 100644 --- a/app/src/main/res/layout/fragment_home.xml +++ b/app/src/main/res/layout/fragment_home.xml @@ -23,7 +23,6 @@