diff --git a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt index 708419d1..1d5dadbf 100644 --- a/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt +++ b/app/src/main/java/com/vanced/manager/ui/fragments/HomeFragment.kt @@ -8,6 +8,7 @@ import android.net.NetworkCapabilities import android.net.NetworkRequest import android.os.Bundle import android.view.* +import androidx.core.animation.addListener import androidx.viewpager2.widget.ViewPager2 import com.google.android.material.card.MaterialCardView import com.google.android.material.tabs.TabLayout @@ -64,31 +65,23 @@ class HomeFragment : Home() { activity?.runOnUiThread { val networkErrorLayout = view?.findViewById(R.id.home_network_wrapper) - val oa0 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0f, -1f) val oa1 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", -1f, 0.3f) val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, 0f) - oa0.start() - networkErrorLayout?.visibility = View.VISIBLE - oa1.start() + + oa1.apply { + oa1.addListener(onStart = { + networkErrorLayout?.visibility = View.VISIBLE + } + ) + start() + } oa2.start() } } - override fun onUnavailable() { - super.onUnavailable() - - activity?.runOnUiThread { - - val networkErrorLayout = view?.findViewById(R.id.home_network_wrapper) - networkErrorLayout?.visibility = View.VISIBLE - - } - - } - override fun onAvailable(network: Network) { super.onAvailable(network) @@ -99,8 +92,14 @@ class HomeFragment : Home() { val oa2 = ObjectAnimator.ofFloat(networkErrorLayout, "yFraction", 0.3f, -1f) oa1.start() - oa2.start() - networkErrorLayout?.visibility = View.GONE + oa2.apply { + oa2.addListener(onEnd = { + networkErrorLayout?.visibility = View.GONE + } + ) + start() + } + } }