Fixed folder fragment AppBarLayout
This commit is contained in:
parent
92635af1e0
commit
8422e5abbd
2 changed files with 49 additions and 69 deletions
|
@ -70,8 +70,8 @@ import com.afollestad.materialcab.attached.destroy
|
||||||
import com.afollestad.materialcab.attached.isActive
|
import com.afollestad.materialcab.attached.isActive
|
||||||
import com.afollestad.materialcab.createCab
|
import com.afollestad.materialcab.createCab
|
||||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||||
|
import com.google.android.material.shape.MaterialShapeDrawable
|
||||||
import com.google.android.material.snackbar.Snackbar
|
import com.google.android.material.snackbar.Snackbar
|
||||||
import com.google.android.material.transition.MaterialFadeThrough
|
|
||||||
import com.google.android.material.transition.MaterialSharedAxis
|
import com.google.android.material.transition.MaterialSharedAxis
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.lang.ref.WeakReference
|
import java.lang.ref.WeakReference
|
||||||
|
@ -103,13 +103,9 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
enterTransition = MaterialFadeThrough()
|
|
||||||
exitTransition = MaterialFadeThrough()
|
|
||||||
mainActivity.addMusicServiceEventListener(libraryViewModel)
|
mainActivity.addMusicServiceEventListener(libraryViewModel)
|
||||||
mainActivity.setSupportActionBar(binding.toolbar)
|
mainActivity.setSupportActionBar(binding.toolbar)
|
||||||
mainActivity.supportActionBar?.title = null
|
mainActivity.supportActionBar?.title = null
|
||||||
setStatusBarColorAuto(view)
|
|
||||||
setUpAppbarColor()
|
|
||||||
setUpBreadCrumbs()
|
setUpBreadCrumbs()
|
||||||
setUpRecyclerView()
|
setUpRecyclerView()
|
||||||
setUpAdapter()
|
setUpAdapter()
|
||||||
|
@ -125,6 +121,8 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
binding.toolbarContainer.drawNextToNavbar()
|
binding.toolbarContainer.drawNextToNavbar()
|
||||||
|
binding.appBarLayout.statusBarForeground =
|
||||||
|
MaterialShapeDrawable.createWithElevationOverlay(requireContext())
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpTitle() {
|
private fun setUpTitle() {
|
||||||
|
@ -308,7 +306,7 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
openQueue(songs, startIndex, true)
|
openQueue(songs, startIndex, true)
|
||||||
} else {
|
} else {
|
||||||
Snackbar.make(
|
Snackbar.make(
|
||||||
binding.coordinatorLayout,
|
binding.root,
|
||||||
Html.fromHtml(
|
Html.fromHtml(
|
||||||
String.format(
|
String.format(
|
||||||
getString(R.string.not_listed_in_media_store), file1.name
|
getString(R.string.not_listed_in_media_store), file1.name
|
||||||
|
@ -451,12 +449,12 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
private fun checkForPadding() {
|
private fun checkForPadding() {
|
||||||
val count = adapter?.itemCount ?: 0
|
val count = adapter?.itemCount ?: 0
|
||||||
if (_binding != null) {
|
if (_binding != null) {
|
||||||
val params = binding.coordinatorLayout.layoutParams as ViewGroup.MarginLayoutParams
|
val params = binding.root.layoutParams as ViewGroup.MarginLayoutParams
|
||||||
params.bottomMargin = if (count > 0 && playingQueue.isNotEmpty()) dip2px(
|
params.bottomMargin = if (count > 0 && playingQueue.isNotEmpty()) dip2px(
|
||||||
requireContext(),
|
requireContext(),
|
||||||
104f
|
104f
|
||||||
) else dip2px(requireContext(), 54f)
|
) else dip2px(requireContext(), 54f)
|
||||||
binding.coordinatorLayout.layoutParams = params
|
binding.root.layoutParams = params
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -522,16 +520,13 @@ class FoldersFragment : AbsMainActivityFragment(R.layout.fragment_folder),
|
||||||
switchToFileAdapter()
|
switchToFileAdapter()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun setUpAppbarColor() {
|
private fun setUpBreadCrumbs() {
|
||||||
binding.breadCrumbs.setActivatedContentColor(
|
binding.breadCrumbs.setActivatedContentColor(
|
||||||
resolveColor(requireContext(), android.R.attr.textColorPrimary)
|
resolveColor(requireContext(), android.R.attr.textColorPrimary)
|
||||||
)
|
)
|
||||||
binding.breadCrumbs.setDeactivatedContentColor(
|
binding.breadCrumbs.setDeactivatedContentColor(
|
||||||
resolveColor(requireContext(), android.R.attr.textColorSecondary)
|
resolveColor(requireContext(), android.R.attr.textColorSecondary)
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
private fun setUpBreadCrumbs() {
|
|
||||||
binding.breadCrumbs.setCallback(this)
|
binding.breadCrumbs.setCallback(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,8 @@
|
||||||
android:id="@+id/appBarLayout"
|
android:id="@+id/appBarLayout"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:liftOnScroll="true">
|
app:liftOnScroll="true"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
<FrameLayout
|
<FrameLayout
|
||||||
android:id="@+id/toolbar_container"
|
android:id="@+id/toolbar_container"
|
||||||
|
@ -23,7 +24,6 @@
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorSurface"
|
|
||||||
app:navigationIcon="@drawable/ic_search"
|
app:navigationIcon="@drawable/ic_search"
|
||||||
app:popupTheme="?attr/toolbarPopupTheme"
|
app:popupTheme="?attr/toolbarPopupTheme"
|
||||||
app:title="@null"
|
app:title="@null"
|
||||||
|
@ -38,66 +38,51 @@
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
</androidx.appcompat.widget.Toolbar>
|
</androidx.appcompat.widget.Toolbar>
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
|
<code.name.monkey.retromusic.views.BreadCrumbLayout
|
||||||
|
android:id="@+id/breadCrumbs"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/tab_height"
|
||||||
|
android:paddingStart="60dp"
|
||||||
|
android:paddingEnd="8dp"
|
||||||
|
app:layout_collapseMode="pin" />
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
</com.google.android.material.appbar.AppBarLayout>
|
||||||
|
|
||||||
<FrameLayout
|
<LinearLayout
|
||||||
android:id="@+id/coordinatorLayout"
|
android:id="@android:id/empty"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/colorSurface"
|
android:layout_gravity="center"
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior">
|
android:gravity="center"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible">
|
||||||
|
|
||||||
<LinearLayout
|
<com.google.android.material.textview.MaterialTextView
|
||||||
android:id="@android:id/empty"
|
android:id="@+id/emptyEmoji"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:text="@string/empty_text_emoji"
|
||||||
|
android:textAppearance="@style/TextViewHeadline3" />
|
||||||
|
|
||||||
|
<com.google.android.material.textview.MaterialTextView
|
||||||
|
android:id="@+id/emptyText"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:gravity="center"
|
android:text="@string/nothing_to_see"
|
||||||
android:orientation="vertical"
|
android:textAppearance="@style/TextViewHeadline5"
|
||||||
android:visibility="gone"
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<com.google.android.material.textview.MaterialTextView
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/emptyEmoji"
|
android:id="@+id/recyclerView"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginBottom="16dp"
|
android:clipToPadding="false"
|
||||||
android:text="@string/empty_text_emoji"
|
android:overScrollMode="never"
|
||||||
android:textAppearance="@style/TextViewHeadline3" />
|
android:scrollbars="none"
|
||||||
|
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
||||||
<com.google.android.material.textview.MaterialTextView
|
|
||||||
android:id="@+id/emptyText"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:text="@string/nothing_to_see"
|
|
||||||
android:textAppearance="@style/TextViewHeadline5"
|
|
||||||
android:textColor="?android:attr/textColorSecondary"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<code.name.monkey.retromusic.views.BreadCrumbLayout
|
|
||||||
android:id="@+id/breadCrumbs"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/tab_height"
|
|
||||||
android:paddingStart="60dp"
|
|
||||||
android:paddingEnd="8dp"
|
|
||||||
app:layout_collapseMode="pin" />
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recyclerView"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:clipToPadding="false"
|
|
||||||
android:overScrollMode="never"
|
|
||||||
android:scrollbars="none"
|
|
||||||
app:layout_behavior="com.google.android.material.appbar.AppBarLayout$ScrollingViewBehavior" />
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
</FrameLayout>
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
Loading…
Reference in a new issue