0
0
Fork 0
mirror of https://github.com/YTVanced/VancedManager synced 2024-11-30 06:53:01 +00:00

ObjectAnimator tests vol.4

This commit is contained in:
X1nto 2020-05-10 18:01:38 +04:00
parent bdec6c9947
commit 87b563b891

View file

@ -8,6 +8,7 @@ import android.net.NetworkCapabilities
import android.net.NetworkRequest import android.net.NetworkRequest
import android.os.Bundle import android.os.Bundle
import android.view.* import android.view.*
import androidx.core.animation.addListener
import androidx.viewpager2.widget.ViewPager2 import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.card.MaterialCardView import com.google.android.material.card.MaterialCardView
import com.google.android.material.tabs.TabLayout import com.google.android.material.tabs.TabLayout
@ -64,31 +65,23 @@ class HomeFragment : Home() {
activity?.runOnUiThread { activity?.runOnUiThread {
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper) val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
val oa0 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, -1f)
val oa1 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", -1f, 0.3f) val oa1 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", -1f, 0.3f)
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, 0f) val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, 0f)
oa0.start()
oa1.apply {
oa1.addListener(onStart = {
networkErrorLayout?.visibility = View.VISIBLE networkErrorLayout?.visibility = View.VISIBLE
oa1.start() }
)
start()
}
oa2.start() oa2.start()
} }
} }
override fun onUnavailable() {
super.onUnavailable()
activity?.runOnUiThread {
val networkErrorLayout = view?.findViewById<MaterialCardView>(R.id.home_network_wrapper)
networkErrorLayout?.visibility = View.VISIBLE
}
}
override fun onAvailable(network: Network) { override fun onAvailable(network: Network) {
super.onAvailable(network) super.onAvailable(network)
@ -99,9 +92,15 @@ class HomeFragment : Home() {
val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f) val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f)
oa1.start() oa1.start()
oa2.start() oa2.apply {
oa2.addListener(onEnd = {
networkErrorLayout?.visibility = View.GONE networkErrorLayout?.visibility = View.GONE
} }
)
start()
}
}
} }