2016-05-27 07:21:21 -04:00
|
|
|
package eu.kanade.tachiyomi.widget
|
2016-02-22 16:36:44 -05:00
|
|
|
|
|
|
|
import android.content.Context
|
|
|
|
import android.support.design.widget.FloatingActionButton
|
|
|
|
import android.support.v4.view.animation.FastOutSlowInInterpolator
|
|
|
|
import android.util.AttributeSet
|
|
|
|
import android.view.View
|
|
|
|
import android.view.animation.Animation
|
|
|
|
import android.view.animation.AnimationUtils
|
|
|
|
import eu.kanade.tachiyomi.R
|
|
|
|
|
2016-04-28 15:51:50 -04:00
|
|
|
class FABAnimationUpDown @JvmOverloads constructor(ctx: Context, attrs: AttributeSet? = null) : FABAnimationBase() {
|
2016-02-22 16:36:44 -05:00
|
|
|
|
|
|
|
private val INTERPOLATOR = FastOutSlowInInterpolator()
|
|
|
|
|
2016-04-28 15:51:50 -04:00
|
|
|
private val outAnimation by lazy {
|
|
|
|
AnimationUtils.loadAnimation(ctx, R.anim.fab_hide_to_bottom).apply {
|
|
|
|
duration = 200
|
|
|
|
interpolator = INTERPOLATOR
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private val inAnimation by lazy {
|
|
|
|
AnimationUtils.loadAnimation(ctx, R.anim.fab_show_from_bottom).apply {
|
|
|
|
duration = 200
|
|
|
|
interpolator = INTERPOLATOR
|
|
|
|
}
|
|
|
|
}
|
2016-02-22 16:36:44 -05:00
|
|
|
|
|
|
|
override fun animateOut(button: FloatingActionButton) {
|
2016-04-28 15:51:50 -04:00
|
|
|
outAnimation.setAnimationListener(object : Animation.AnimationListener {
|
2016-02-22 16:36:44 -05:00
|
|
|
override fun onAnimationStart(animation: Animation) {
|
2016-04-28 15:51:50 -04:00
|
|
|
isAnimatingOut = true
|
2016-02-22 16:36:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onAnimationEnd(animation: Animation) {
|
2016-04-28 15:51:50 -04:00
|
|
|
isAnimatingOut = false
|
2017-02-02 10:48:18 -05:00
|
|
|
button.visibility = View.INVISIBLE
|
2016-02-22 16:36:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onAnimationRepeat(animation: Animation) {
|
|
|
|
}
|
|
|
|
})
|
2016-04-28 15:51:50 -04:00
|
|
|
button.startAnimation(outAnimation)
|
2016-02-22 16:36:44 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun animateIn(button: FloatingActionButton) {
|
|
|
|
button.visibility = View.VISIBLE
|
2016-04-28 15:51:50 -04:00
|
|
|
button.startAnimation(inAnimation)
|
2016-02-22 16:36:44 -05:00
|
|
|
}
|
|
|
|
}
|