More Fab work + Checks for duplicate snackbars
This commit is contained in:
parent
62af86c77a
commit
744b0a3f58
4 changed files with 37 additions and 3 deletions
|
@ -121,7 +121,7 @@ class ChaptersController : NucleusController<ChaptersPresenter>(),
|
|||
if (!reveal_view.showRevealEffect(coordinates.x, coordinates.y, revealAnimationListener)) {
|
||||
openChapter(item.chapter)
|
||||
}
|
||||
} else {
|
||||
} else if (snack == null || snack?.getText() != view.context.getString(R.string.no_next_chapter)) {
|
||||
snack = view.snack(R.string.no_next_chapter, Snackbar.LENGTH_LONG) {
|
||||
addCallback(object : BaseTransientBottomBar.BaseCallback<Snackbar>() {
|
||||
override fun onDismissed(transientBottomBar: Snackbar?, event: Int) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import androidx.interpolator.view.animation.FastOutSlowInInterpolator
|
|||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import eu.kanade.tachiyomi.R
|
||||
import timber.log.Timber
|
||||
import kotlin.math.min
|
||||
|
||||
@Suppress("unused", "UNUSED_PARAMETER")
|
||||
|
@ -68,7 +67,6 @@ class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: Attribut
|
|||
for (i in 0 until dependencies.size) {
|
||||
val view = dependencies[i]
|
||||
if (view is Snackbar.SnackbarLayout) {
|
||||
Timber.d("snack y: ${view.translationY}")
|
||||
minOffset = min(minOffset, view.translationY - view.height)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import kotlin.math.min
|
||||
|
||||
class FABMoveBehaviour(context: Context, attrs: AttributeSet) :
|
||||
CoordinatorLayout.Behavior<FloatingActionButton>(context, attrs) {
|
||||
|
||||
override fun layoutDependsOn(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
||||
return dependency is Snackbar.SnackbarLayout
|
||||
}
|
||||
override fun onDependentViewChanged(parent: CoordinatorLayout, child: FloatingActionButton, dependency: View): Boolean {
|
||||
val translationY = getFabTranslationYForSnackbar(parent, child)
|
||||
child.translationY = translationY
|
||||
return true
|
||||
}
|
||||
|
||||
private fun getFabTranslationYForSnackbar(parent: CoordinatorLayout, fab: FloatingActionButton): Float {
|
||||
var minOffset = 0f
|
||||
val dependencies = parent.getDependencies(fab)
|
||||
for (i in 0 until dependencies.size) {
|
||||
val view = dependencies[i]
|
||||
if (view is Snackbar.SnackbarLayout) {
|
||||
minOffset = min(minOffset, view.translationY - view.height)
|
||||
}
|
||||
}
|
||||
return minOffset
|
||||
}
|
||||
}
|
|
@ -152,7 +152,9 @@
|
|||
<item name="android:layout_gravity">bottom|end</item>
|
||||
<item name="android:layout_margin">@dimen/fab_margin</item>
|
||||
<item name="android:scaleType">fitCenter</item>
|
||||
<item name="layout_anchorGravity">bottom|right|end</item>
|
||||
<item name="android:tint">@color/md_white_1000</item>
|
||||
<item name="layout_behavior">eu.kanade.tachiyomi.widget.FABMoveBehaviour</item>
|
||||
</style>
|
||||
|
||||
<style name="Theme.Widget.CardView" parent="CardView">
|
||||
|
|
Reference in a new issue