diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt
index 1aff33fde..b4cffad72 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueDragCallback.kt
@@ -78,19 +78,7 @@ class QueueDragCallback(
)
)
- val result = clampedAbsVelocity * sign(viewSizeOutOfBounds.toDouble()).toInt()
-
- recyclerView.post {
- // CoordinatorLayout refuses to propagate a scroll event initiated by an item scroll,
- // so we do it ourselves.
- (appBar.layoutParams as CoordinatorLayout.LayoutParams).behavior
- ?.onNestedPreScroll(
- coordinator, appBar, recyclerView,
- 0, result, tConsumed, 0
- )
- }
-
- return result
+ return clampedAbsVelocity * sign(viewSizeOutOfBounds.toDouble()).toInt()
}
override fun onChildDraw(
diff --git a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt
index 576f726b7..9fd33286a 100644
--- a/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/playback/queue/QueueFragment.kt
@@ -107,7 +107,7 @@ class QueueFragment : Fragment() {
lastShuffle = isShuffling
binding.queueRecycler.scrollToPosition(0)
- binding.queueAppbar.isLifted = false // Make sure lifted state changes.
+ // binding.queueAppbar.isLifted = false // Make sure lifted state changes.
}
}
diff --git a/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt b/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt
index 15f20f787..1f2a880c8 100644
--- a/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt
+++ b/app/src/main/java/org/oxycblt/auxio/search/SearchFragment.kt
@@ -144,12 +144,11 @@ class SearchFragment : Fragment() {
// TODO: Maybe find a better way to keep scroll state when the search
// results didn't actually change.
binding.searchRecycler.scrollToPosition(0)
- binding.searchAppbar.isLifted = false
}
if (results.isEmpty()) {
binding.searchAppbar.setExpanded(true)
- binding.searchRecycler.visibility = View.GONE
+ binding.searchRecycler.visibility = View.INVISIBLE
} else {
binding.searchRecycler.visibility = View.VISIBLE
}
diff --git a/app/src/main/java/org/oxycblt/auxio/ui/LiftAppBarLayout.kt b/app/src/main/java/org/oxycblt/auxio/ui/LiftAppBarLayout.kt
new file mode 100644
index 000000000..02a7f9d79
--- /dev/null
+++ b/app/src/main/java/org/oxycblt/auxio/ui/LiftAppBarLayout.kt
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2021 Auxio Project
+ * CobaltCoordinatorLayout.kt is part of Auxio.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package org.oxycblt.auxio.ui
+
+import android.content.Context
+import android.util.AttributeSet
+import android.view.ViewGroup
+import android.view.ViewTreeObserver
+import androidx.annotation.StyleRes
+import androidx.coordinatorlayout.widget.CoordinatorLayout
+import androidx.core.view.children
+import androidx.recyclerview.widget.RecyclerView
+import com.google.android.material.appbar.AppBarLayout
+
+/**
+ * An [AppBarLayout] that fixes a bug with the default implementation where the lifted state
+ * will not properly respond to RecyclerView events.
+ * TODO: Find a way to get the lift animation to not animate on startup.
+ */
+class LiftAppBarLayout @JvmOverloads constructor(
+ context: Context,
+ attrs: AttributeSet? = null,
+ @StyleRes defStyleAttr: Int = -1
+) : AppBarLayout(context, attrs, defStyleAttr) {
+ private var recycler: RecyclerView? = null
+ private val tConsumed = IntArray(2)
+
+ private val onPreDraw = ViewTreeObserver.OnPreDrawListener {
+ recycler?.let { rec ->
+ val coordinator = (parent as CoordinatorLayout)
+
+ (layoutParams as CoordinatorLayout.LayoutParams).behavior?.onNestedPreScroll(
+ coordinator, this, rec, 0, 0, tConsumed, 0
+ )
+ }
+
+ true
+ }
+
+ init {
+ viewTreeObserver.addOnPreDrawListener(onPreDraw)
+ }
+
+ override fun onAttachedToWindow() {
+ super.onAttachedToWindow()
+
+ // Assume there is one RecyclerView [Because there is]
+ recycler = (parent as ViewGroup).children.firstOrNull { it is RecyclerView }
+ as RecyclerView?
+ }
+
+ override fun onDetachedFromWindow() {
+ super.onDetachedFromWindow()
+
+ viewTreeObserver.removeOnPreDrawListener(onPreDraw)
+ }
+}
diff --git a/app/src/main/res/layout/fragment_detail.xml b/app/src/main/res/layout/fragment_detail.xml
index f72e5427e..684e89073 100644
--- a/app/src/main/res/layout/fragment_detail.xml
+++ b/app/src/main/res/layout/fragment_detail.xml
@@ -8,7 +8,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent">
-
-
+
+ tools:listitem="@layout/item_artist_header"
+ tools:layout_marginTop="56dp"/>
\ No newline at end of file
diff --git a/app/src/main/res/layout/fragment_queue.xml b/app/src/main/res/layout/fragment_queue.xml
index f680fee93..a77f870b3 100644
--- a/app/src/main/res/layout/fragment_queue.xml
+++ b/app/src/main/res/layout/fragment_queue.xml
@@ -12,7 +12,7 @@
android:background="?attr/colorSurface"
android:orientation="vertical">
-
-
+
-
-
+
-
-
+