mirror of
https://github.com/YTVanced/VancedManager
synced 2024-11-23 11:45:11 +00:00
ObjectAnimator tests
This commit is contained in:
parent
7576b8bba8
commit
7f3c4a24bc
4 changed files with 41 additions and 6 deletions
|
@ -0,0 +1,33 @@
|
|||
package com.vanced.manager.ui.core
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import com.google.android.material.card.MaterialCardView
|
||||
|
||||
open class SlidingCardView: MaterialCardView {
|
||||
|
||||
constructor(context: Context?) : super(context)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(
|
||||
context,
|
||||
attrs
|
||||
)
|
||||
|
||||
var yFraction: Float
|
||||
get() {
|
||||
val height = height
|
||||
return if (height != 0)
|
||||
y / height
|
||||
else
|
||||
y
|
||||
}
|
||||
set(yFraction) {
|
||||
val height = height
|
||||
val newHeight =
|
||||
if (height > 0)
|
||||
yFraction * height
|
||||
else
|
||||
(-9999).toFloat()
|
||||
y = newHeight
|
||||
}
|
||||
|
||||
}
|
|
@ -5,6 +5,7 @@ import android.util.AttributeSet
|
|||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
open class SlidingConstraintLayout : ConstraintLayout {
|
||||
|
||||
constructor(context: Context?) : super(context)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(
|
||||
context,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.vanced.manager.ui.fragments
|
||||
|
||||
import android.animation.ObjectAnimator
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
|
@ -66,11 +67,11 @@ class HomeFragment : Home() {
|
|||
|
||||
activity?.runOnUiThread {
|
||||
|
||||
val animationShow: Animation = AnimationUtils.loadAnimation(requireContext(), R.anim.view_enter)
|
||||
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
|
||||
val oa = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", -1f, 0f)
|
||||
|
||||
networkErrorLayout?.visibility = View.VISIBLE
|
||||
networkErrorLayout?.startAnimation(animationShow)
|
||||
oa.start()
|
||||
|
||||
}
|
||||
|
||||
|
@ -93,10 +94,10 @@ class HomeFragment : Home() {
|
|||
|
||||
activity?.runOnUiThread {
|
||||
|
||||
val animationHide: Animation = AnimationUtils.loadAnimation(requireContext(), R.anim.view_exit)
|
||||
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
|
||||
val oa = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, -1f)
|
||||
|
||||
networkErrorLayout?.startAnimation(animationHide)
|
||||
oa.start()
|
||||
networkErrorLayout?.visibility = View.GONE
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.google.android.material.card.MaterialCardView
|
||||
<com.vanced.manager.ui.core.SlidingCardView
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -31,4 +31,4 @@
|
|||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
</com.google.android.material.card.MaterialCardView>
|
||||
</com.vanced.manager.ui.core.SlidingCardView>
|
Loading…
Reference in a new issue