commit
70cf085df9
@ -0,0 +1,19 @@
|
||||
package eu.kanade.tachiyomi.util
|
||||
|
||||
import android.graphics.Point
|
||||
import android.view.View
|
||||
|
||||
/**
|
||||
* Returns coordinates of view.
|
||||
* Used for animation
|
||||
*
|
||||
* @return coordinates of view
|
||||
*/
|
||||
fun View.getCoordinates(): Point
|
||||
{
|
||||
var cx = (this.left + this.right) / 2;
|
||||
var cy = (this.top + this.bottom) / 2;
|
||||
|
||||
return Point(cx, cy)
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.AnimatorListenerAdapter
|
||||
import android.annotation.TargetApi
|
||||
import android.content.Context
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.view.ViewAnimationUtils
|
||||
|
||||
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
|
||||
class RevealAnimationView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
View(context, attrs) {
|
||||
|
||||
/**
|
||||
* Hides the animation view with a animation
|
||||
*
|
||||
* @param centerX x starting point
|
||||
* @param centerY y starting point
|
||||
* @param initialRadius size of radius of animation
|
||||
*/
|
||||
fun hideRevealEffect(centerX: Int, centerY: Int, initialRadius: Int) {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
|
||||
// Make the view visible.
|
||||
this.visibility = View.VISIBLE
|
||||
|
||||
// Create the animation (the final radius is zero).
|
||||
val anim = ViewAnimationUtils.createCircularReveal(
|
||||
this, centerX, centerY, initialRadius.toFloat(), 0f)
|
||||
|
||||
// Set duration of animation.
|
||||
anim.duration = 500
|
||||
|
||||
// make the view invisible when the animation is done
|
||||
anim.addListener(object : AnimatorListenerAdapter() {
|
||||
override fun onAnimationEnd(animation: Animator) {
|
||||
super.onAnimationEnd(animation)
|
||||
this@RevealAnimationView.visibility = View.INVISIBLE
|
||||
}
|
||||
})
|
||||
|
||||
anim.start()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Fills the animation view with a animation
|
||||
*
|
||||
* @param centerX x starting point
|
||||
* @param centerY y starting point
|
||||
* @param listener animation listener
|
||||
*
|
||||
* @return sdk version lower then 21
|
||||
*/
|
||||
fun showRevealEffect(centerX: Int, centerY: Int, listener: Animator.AnimatorListener): Boolean {
|
||||
if (Build.VERSION.SDK_INT >= 21) {
|
||||
|
||||
this.visibility = View.VISIBLE
|
||||
|
||||
val height = this.height
|
||||
|
||||
// Create animation
|
||||
val anim = ViewAnimationUtils.createCircularReveal(
|
||||
this, centerX, centerY, 0f, height.toFloat())
|
||||
|
||||
// Set duration of animation
|
||||
anim.duration = 350
|
||||
|
||||
anim.addListener(listener)
|
||||
anim.start()
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportHeight="24.0"
|
||||
android:viewportWidth="24.0">
|
||||
<path
|
||||
android:fillColor="#FFFFFFFF"
|
||||
android:pathData="M14.94,4.66h-4.72l2.36,-2.36zM10.25,19.37h4.66l-2.33,2.33zM6.1,6.27L1.6,17.73h1.84l0.92,-2.45h5.11l0.92,2.45h1.84L7.74,6.27L6.1,6.27zM4.97,13.64l1.94,-5.18 1.94,5.18L4.97,13.64zM15.73,16.14h6.12v1.59h-8.53v-1.29l5.92,-8.56h-5.88v-1.6h8.3v1.26l-5.93,8.6z"/>
|
||||
</vector>
|
Loading…
Reference in new issue