Migrate to ExtendedFloatingActionButton
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
package org.koitharu.kotatsu.base.ui.util
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
||||
import androidx.coordinatorlayout.widget.CoordinatorLayout.Behavior
|
||||
import androidx.core.view.ViewCompat
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
|
||||
class ShrinkOnScrollBehavior : Behavior<ExtendedFloatingActionButton> {
|
||||
|
||||
@Suppress("unused") constructor() : super()
|
||||
@Suppress("unused") constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||
|
||||
override fun onStartNestedScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: ExtendedFloatingActionButton,
|
||||
directTargetChild: View,
|
||||
target: View,
|
||||
axes: Int,
|
||||
type: Int
|
||||
): Boolean {
|
||||
return axes == ViewCompat.SCROLL_AXIS_VERTICAL
|
||||
}
|
||||
|
||||
override fun onNestedScroll(
|
||||
coordinatorLayout: CoordinatorLayout,
|
||||
child: ExtendedFloatingActionButton,
|
||||
target: View,
|
||||
dxConsumed: Int,
|
||||
dyConsumed: Int,
|
||||
dxUnconsumed: Int,
|
||||
dyUnconsumed: Int,
|
||||
type: Int,
|
||||
consumed: IntArray
|
||||
) {
|
||||
if (dyConsumed > 0) {
|
||||
if (child.isExtended) {
|
||||
child.shrink()
|
||||
}
|
||||
} else if (dyConsumed < 0) {
|
||||
if (!child.isExtended) {
|
||||
child.extend()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -308,17 +308,6 @@ class MainActivity :
|
||||
|
||||
private fun onLoadingStateChanged(isLoading: Boolean) {
|
||||
binding.fab.isEnabled = !isLoading
|
||||
if (isLoading) {
|
||||
binding.fab.setImageDrawable(
|
||||
CircularProgressDrawable(this).also {
|
||||
it.setColorSchemeColors(R.color.kotatsu_onPrimaryContainer)
|
||||
it.strokeWidth = resources.resolveDp(3.5f)
|
||||
it.start()
|
||||
}
|
||||
)
|
||||
} else {
|
||||
binding.fab.setImageResource(R.drawable.ic_read_fill)
|
||||
}
|
||||
}
|
||||
|
||||
private fun updateSideMenu(remoteSources: List<MangaSource>) {
|
||||
|
||||
Reference in New Issue
Block a user