home: fix appbar issues
Fix two annoying appbar issues: - Appbar will collapse if the navigation sequence is too fast - Tab ripple would paint over the indicator unless the ripple was unbounded [???]
This commit is contained in:
parent
5fe01777d0
commit
9162246b8b
3 changed files with 25 additions and 22 deletions
|
@ -101,8 +101,6 @@ dependencies {
|
|||
// Material
|
||||
implementation "com.google.android.material:material:1.4.0"
|
||||
|
||||
implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
|
||||
|
||||
// --- DEBUG ---
|
||||
|
||||
// Lint
|
||||
|
|
|
@ -49,8 +49,6 @@ import org.oxycblt.auxio.util.logE
|
|||
* It will require a new SortMode to be made simply for compat. Migrate the old SortMode
|
||||
* eventually.
|
||||
* TODO: Add lift-on-scroll eventually [when I can file a bug report or hack it into working]
|
||||
* FIXME: Find a way to store the collapsed state so it stays consistent
|
||||
* TODO: Fix issue where TabLayout ripples will shove above the indicator
|
||||
* @author OxygenCobalt
|
||||
*/
|
||||
class HomeFragment : Fragment() {
|
||||
|
@ -69,9 +67,6 @@ class HomeFragment : Fragment() {
|
|||
|
||||
binding.lifecycleOwner = viewLifecycleOwner
|
||||
|
||||
// For some insane reason certain navigation actions will collapse the app bar
|
||||
binding.homeAppbar.setExpanded(true)
|
||||
|
||||
binding.homeToolbar.setOnMenuItemClickListener { item ->
|
||||
when (item.itemId) {
|
||||
R.id.action_settings -> {
|
||||
|
@ -128,24 +123,28 @@ class HomeFragment : Fragment() {
|
|||
// --- VIEWMODEL SETUP ---
|
||||
|
||||
detailModel.navToItem.observe(viewLifecycleOwner) { item ->
|
||||
when (item) {
|
||||
is Song -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowAlbum(item.album.id)
|
||||
)
|
||||
// Unless we wait for the AppBarLayout to be done setting up before we navigate,
|
||||
// it might result in the collapsed state being lost for...reasons.
|
||||
binding.homeAppbar.post {
|
||||
when (item) {
|
||||
is Song -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowAlbum(item.album.id)
|
||||
)
|
||||
|
||||
is Album -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowAlbum(item.id)
|
||||
)
|
||||
is Album -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowAlbum(item.id)
|
||||
)
|
||||
|
||||
is Artist -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowArtist(item.id)
|
||||
)
|
||||
is Artist -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowArtist(item.id)
|
||||
)
|
||||
|
||||
is Genre -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowGenre(item.id)
|
||||
)
|
||||
is Genre -> findNavController().navigate(
|
||||
HomeFragmentDirections.actionShowGenre(item.id)
|
||||
)
|
||||
|
||||
else -> {
|
||||
else -> {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
android:id="@+id/home_appbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:background="?attr/colorSurface"
|
||||
android:elevation="@dimen/elevation_normal">
|
||||
|
||||
|
@ -31,9 +33,13 @@
|
|||
android:id="@+id/home_tabs"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
app:tabUnboundedRipple="true"
|
||||
app:tabRippleColor="?attr/colorControlHighlight"
|
||||
app:tabTextAppearance="@style/TextAppearance.TabLayout.Label"
|
||||
app:tabMode="scrollable"
|
||||
app:tabContentStart="@dimen/spacing_medium"
|
||||
app:tabMode="scrollable"
|
||||
app:tabTextColor="?android:attr/textColorPrimary"
|
||||
app:tabIndicatorColor="?attr/colorAccent" />
|
||||
|
||||
|
|
Loading…
Reference in a new issue