Merge pull request #264 from lilcheti/master

Animation for arrows
This commit is contained in:
Farbod 2022-05-20 18:19:12 +04:30 committed by GitHub
commit 9cc65a58dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 54 additions and 8 deletions

View File

@ -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
@ -204,8 +207,27 @@ class PlayerFragment : Fragment() {
}
view.findViewById<RelativeLayout>(R.id.player_title_layout).setOnClickListener {
playerDescription.visibility =
if (playerDescription.isVisible) View.GONE else View.VISIBLE
if (playerDescription.isVisible){
val image = view.findViewById<ImageView>(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<ImageView>(R.id.player_description_arrow)
image.startAnimation(rotate)
playerDescription.visibility = View.VISIBLE
}
}
view.findViewById<com.google.android.material.card.MaterialCardView>(R.id.comments_toggle).setOnClickListener {

View File

@ -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<ImageView>(R.id.toggle)
image.startAnimation(rotate)
} else {
channelRecView.visibility = View.GONE
feedRecView.visibility = View.VISIBLE
//toggle button
val image = view.findViewById<ImageView>(R.id.toggle)
image.clearAnimation()
}
}

View File

@ -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" />
</RelativeLayout>
@ -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"/>
</LinearLayout>
<LinearLayout

View File

@ -68,6 +68,7 @@
/>
<ImageView
android:id="@+id/toggle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"