From 6f4101ba57047944cf3a9c7970e8fa2d39518f1e Mon Sep 17 00:00:00 2001 From: rimthekid Date: Fri, 20 May 2022 06:42:45 -0700 Subject: [PATCH] arrows animation --- .../com/github/libretube/PlayerFragment.kt | 26 ++++++++++++++++-- .../com/github/libretube/Subscriptions.kt | 27 +++++++++++++++++-- app/src/main/res/layout/fragment_player.xml | 8 +++--- .../res/layout/fragment_subscriptions.xml | 1 + 4 files changed, 54 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/github/libretube/PlayerFragment.kt b/app/src/main/java/com/github/libretube/PlayerFragment.kt index 3ddfe4fff..cbdc613af 100644 --- a/app/src/main/java/com/github/libretube/PlayerFragment.kt +++ b/app/src/main/java/com/github/libretube/PlayerFragment.kt @@ -19,6 +19,9 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.animation.Animation +import android.view.animation.LinearInterpolator +import android.view.animation.RotateAnimation import android.widget.* import androidx.appcompat.app.AlertDialog import androidx.constraintlayout.motion.widget.MotionLayout @@ -203,8 +206,27 @@ class PlayerFragment : Fragment() { } view.findViewById(R.id.player_title_layout).setOnClickListener { - playerDescription.visibility = - if (playerDescription.isVisible) View.GONE else View.VISIBLE + if (playerDescription.isVisible){ + val image = view.findViewById(R.id.player_description_arrow) + image.clearAnimation() + playerDescription.visibility = View.GONE + } else { + //toggle button + val rotate = RotateAnimation( + 0F, + 180F, + Animation.RELATIVE_TO_SELF, + 0.5f, + Animation.RELATIVE_TO_SELF, + 0.5f + ) + rotate.duration = 100 + rotate.interpolator = LinearInterpolator() + rotate.fillAfter = true + val image = view.findViewById(R.id.player_description_arrow) + image.startAnimation(rotate) + playerDescription.visibility = View.VISIBLE + } } view.findViewById(R.id.comments_toggle).setOnClickListener { diff --git a/app/src/main/java/com/github/libretube/Subscriptions.kt b/app/src/main/java/com/github/libretube/Subscriptions.kt index 86a989ff2..eec140e17 100644 --- a/app/src/main/java/com/github/libretube/Subscriptions.kt +++ b/app/src/main/java/com/github/libretube/Subscriptions.kt @@ -6,6 +6,9 @@ import android.util.Log import android.view.LayoutInflater import android.view.View import android.view.ViewGroup +import android.view.animation.Animation +import android.view.animation.LinearInterpolator +import android.view.animation.RotateAnimation import android.widget.* import androidx.core.view.isVisible import androidx.fragment.app.Fragment @@ -16,9 +19,9 @@ import androidx.recyclerview.widget.RecyclerView import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.github.libretube.adapters.SubscriptionAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter -import java.io.IOException -import org.chromium.base.ThreadUtils.runOnUiThread import retrofit2.HttpException +import java.io.IOException + class Subscriptions : Fragment() { val TAG = "SubFragment" @@ -78,9 +81,29 @@ class Subscriptions : Fragment() { } channelRecView.visibility = View.VISIBLE feedRecView.visibility = View.GONE + + //toggle button + val rotate = RotateAnimation( + 0F, + 180F, + Animation.RELATIVE_TO_SELF, + 0.5f, + Animation.RELATIVE_TO_SELF, + 0.5f + ) + rotate.duration = 100 + rotate.interpolator = LinearInterpolator() + rotate.fillAfter = true + val image = view.findViewById(R.id.toggle) + image.startAnimation(rotate) + } else { channelRecView.visibility = View.GONE feedRecView.visibility = View.VISIBLE + + //toggle button + val image = view.findViewById(R.id.toggle) + image.clearAnimation() } } diff --git a/app/src/main/res/layout/fragment_player.xml b/app/src/main/res/layout/fragment_player.xml index 404a23afd..96caeed6d 100644 --- a/app/src/main/res/layout/fragment_player.xml +++ b/app/src/main/res/layout/fragment_player.xml @@ -48,8 +48,8 @@ android:layout_height="wrap_content" android:layout_alignParentRight="true" android:layout_centerInParent="true" - android:layout_marginEnd="10dp" - android:paddingLeft="16dp" + android:layout_marginStart="8dp" + android:layout_marginEnd="8dp" android:src="@drawable/ic_arrow_down" /> @@ -147,8 +147,8 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" - android:text="@string/download" /> - > + android:text="@string/download" + android:maxLines="1"/>