aboutsummaryrefslogtreecommitdiff
path: root/src/com/android/tv/menu/PlayControlsButton.java
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2017-11-29 00:20:48 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2017-11-29 00:20:48 +0000
commit7b32e8a67561a7989dbfc0f1d3480dca162c6769 (patch)
treed31e2adc1f9cce4f27ca07d30bee921032e33a3c /src/com/android/tv/menu/PlayControlsButton.java
parentbc7f430decab0bc34a533811efe457d4615f28aa (diff)
parentbb2e798ef4d546dd54cd9e95796403062b860c15 (diff)
downloadTV-7b32e8a67561a7989dbfc0f1d3480dca162c6769.tar.gz
Change-Id: I0aff16fbf430ba5e4dbba83b8e06e4a23b38060a
Diffstat (limited to 'src/com/android/tv/menu/PlayControlsButton.java')
-rw-r--r--src/com/android/tv/menu/PlayControlsButton.java24
1 files changed, 20 insertions, 4 deletions
diff --git a/src/com/android/tv/menu/PlayControlsButton.java b/src/com/android/tv/menu/PlayControlsButton.java
index aff39db3..77715f28 100644
--- a/src/com/android/tv/menu/PlayControlsButton.java
+++ b/src/com/android/tv/menu/PlayControlsButton.java
@@ -39,6 +39,9 @@ public class PlayControlsButton extends FrameLayout {
private final int mIconColor;
private int mIconFocusedColor;
+ private int mImageResourceId;
+ private int mTintColor;
+
public PlayControlsButton(Context context) {
this(context, null);
}
@@ -67,10 +70,21 @@ public class PlayControlsButton extends FrameLayout {
* Sets the resource ID of the image to be displayed in the center of this control.
*/
public void setImageResId(int imageResId) {
- mIcon.setImageResource(imageResId);
- // Since on foucus changing, icons' color should be switched with animation,
+ int newTintColor = hasFocus() ? mIconFocusedColor : mIconColor;
+ if (mImageResourceId != imageResId) {
+ mImageResourceId = imageResId;
+ mIcon.setImageResource(imageResId);
+ updateTint(newTintColor);
+ } else if (newTintColor != mTintColor) {
+ updateTint(newTintColor);
+ }
+ }
+
+ private void updateTint(int tintColor) {
+ mTintColor = tintColor;
+ // Since on focus changing, icons' color should be switched with animation,
// as a result, selectors cannot be used to switch colors in this case.
- mIcon.getDrawable().setTint(hasFocus() ? mIconFocusedColor : mIconColor);
+ mIcon.getDrawable().setTint(tintColor);
}
/**
@@ -117,7 +131,9 @@ public class PlayControlsButton extends FrameLayout {
} else {
mIcon.setVisibility(View.GONE);
mLabel.setVisibility(View.VISIBLE);
- mLabel.setText(label);
+ if (!TextUtils.equals(mLabel.getText(), label)) {
+ mLabel.setText(label);
+ }
}
}