summaryrefslogtreecommitdiff
path: root/app/src/main/java/de/danoeh/antennapod/view
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2021-04-15 21:25:14 +0200
committerGitHub <noreply@github.com>2021-04-15 21:25:14 +0200
commit58cdba45c52a4d71f583b91a6a8e6b43293130a6 (patch)
treeb414c08eaeb0825cdc688f624848f07cd54916ec /app/src/main/java/de/danoeh/antennapod/view
parent456470e68992b7482902e9138d7d4ee437d2c30c (diff)
parentf1cba8042f18c2a138ca3af6df1005b9983e491e (diff)
downloadAntennaPod-58cdba45c52a4d71f583b91a6a8e6b43293130a6.zip
Merge pull request #5113 from ByteHamster/play-button
Play button animation
Diffstat (limited to 'app/src/main/java/de/danoeh/antennapod/view')
-rw-r--r--app/src/main/java/de/danoeh/antennapod/view/PlayButton.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/app/src/main/java/de/danoeh/antennapod/view/PlayButton.java b/app/src/main/java/de/danoeh/antennapod/view/PlayButton.java
new file mode 100644
index 000000000..691a15ca2
--- /dev/null
+++ b/app/src/main/java/de/danoeh/antennapod/view/PlayButton.java
@@ -0,0 +1,54 @@
+package de.danoeh.antennapod.view;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.appcompat.widget.AppCompatImageButton;
+import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
+import de.danoeh.antennapod.R;
+import de.danoeh.antennapod.ui.common.ThemeUtils;
+
+public class PlayButton extends AppCompatImageButton {
+ private boolean isShowPlay = true;
+ private boolean isVideoScreen = false;
+
+ public PlayButton(@NonNull Context context) {
+ super(context);
+ }
+
+ public PlayButton(@NonNull Context context, @Nullable AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public PlayButton(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public void setIsVideoScreen(boolean isVideoScreen) {
+ this.isVideoScreen = isVideoScreen;
+ }
+
+ public void setIsShowPlay(boolean showPlay) {
+ if (this.isShowPlay != showPlay) {
+ this.isShowPlay = showPlay;
+ setContentDescription(getContext().getString(showPlay ? R.string.play_label : R.string.pause_label));
+ if (isVideoScreen) {
+ setImageResource(showPlay ? R.drawable.ic_av_play_white_80dp : R.drawable.ic_av_pause_white_80dp);
+ } else if (!isShown()) {
+ setImageResource(ThemeUtils.getDrawableFromAttr(getContext(),
+ showPlay ? R.attr.av_play : R.attr.av_pause));
+ } else if (showPlay) {
+ AnimatedVectorDrawableCompat drawable = AnimatedVectorDrawableCompat.create(
+ getContext(), R.drawable.ic_animate_pause_play);
+ setImageDrawable(drawable);
+ drawable.start();
+ } else {
+ AnimatedVectorDrawableCompat drawable = AnimatedVectorDrawableCompat.create(
+ getContext(), R.drawable.ic_animate_play_pause);
+ setImageDrawable(drawable);
+ drawable.start();
+ }
+ }
+ }
+}