blob: 04b277fb4e41b1aef032a5720ec83184f64326d4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
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;
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_play_video_white : R.drawable.ic_pause_video_white);
} else if (!isShown()) {
setImageResource(showPlay ? R.drawable.ic_play_48dp : R.drawable.ic_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();
}
}
}
}
|