Fix snackbar in feed screen for tablets

This commit is contained in:
Zakhar Timoshenko
2022-08-06 23:57:44 +03:00
parent e545c8b897
commit 8e08b5003e
7 changed files with 74 additions and 14 deletions

View File

@@ -245,8 +245,7 @@ class MainActivity :
}
private fun onError(e: Throwable) {
Snackbar.make(binding.container, e.getDisplayMessage(resources), Snackbar.LENGTH_SHORT).setAnchorView(bottomNav)
.show()
Snackbar.make(binding.container, e.getDisplayMessage(resources), Snackbar.LENGTH_SHORT).show()
}
private fun onCountersChanged(counters: SparseIntArray) {

View File

@@ -73,7 +73,7 @@ class FeedFragment :
addMenuProvider(
FeedMenuProvider(
binding.recyclerView,
(activity as? BottomNavOwner)?.bottomNav ?: binding.recyclerView,
(activity as? BottomNavOwner)?.bottomNav,
viewModel,
),
)

View File

@@ -14,7 +14,7 @@ import org.koitharu.kotatsu.tracker.work.TrackWorker
class FeedMenuProvider(
private val snackbarHost: View,
private val anchorView: View,
private val anchorView: View?,
private val viewModel: FeedViewModel,
) : MenuProvider {

View File

@@ -129,14 +129,6 @@ fun Context.getAnimationDuration(@IntegerRes resId: Int): Long {
return (resources.getInteger(resId) * animatorDurationScale).roundToLong()
}
inline fun <reified T> ViewGroup.findChild(): T? {
return children.find { it is T } as? T
}
inline fun <reified T> ViewGroup.findDescendant(): T? {
return descendants.find { it is T } as? T
}
fun isLowRamDevice(context: Context): Boolean {
return context.activityManager?.isLowRamDevice ?: false
}