summaryrefslogtreecommitdiff
path: root/java/com/android/dialer/widget
diff options
context:
space:
mode:
authorcalderwoodra <calderwoodra@google.com>2017-11-15 14:16:43 -0800
committerzachh <zachh@google.com>2017-11-18 07:30:22 +0000
commit8dab453962327e01c6f2e2a22d61540d1c3d6f47 (patch)
tree9e5f615daff70c09ac87f433ae16876f5b7d4079 /java/com/android/dialer/widget
parent43073477f2f737d02976c593548a1bfa87f7031f (diff)
Dialpad FAB no longer loses it's icon on fragment resume.
There must be a bug in FloatingActionButton because when you call setImageDrawable multiple times (possibly with the same drawable/icon), the FAB renders with no icon present. That's why the icon would disappear in Fragment#onResume. Bug: 69006360 Test: manual PiperOrigin-RevId: 175878924 Change-Id: I1c36be3f9aeb003410f0bdbb9d52b5a483262f03
Diffstat (limited to 'java/com/android/dialer/widget')
-rw-r--r--java/com/android/dialer/widget/FloatingActionButtonController.java12
1 files changed, 8 insertions, 4 deletions
diff --git a/java/com/android/dialer/widget/FloatingActionButtonController.java b/java/com/android/dialer/widget/FloatingActionButtonController.java
index a0c4e6ddd..dde4d44ce 100644
--- a/java/com/android/dialer/widget/FloatingActionButtonController.java
+++ b/java/com/android/dialer/widget/FloatingActionButtonController.java
@@ -18,7 +18,7 @@ package com.android.dialer.widget;
import android.app.Activity;
import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
+import android.support.annotation.DrawableRes;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.FloatingActionButton.OnVisibilityChangedListener;
import android.view.View;
@@ -39,6 +39,7 @@ public class FloatingActionButtonController {
private final int mFloatingActionButtonMarginRight;
private final FloatingActionButton mFab;
private final Interpolator mFabInterpolator;
+ private int mFabIconId = -1;
private int mScreenWidth;
public FloatingActionButtonController(Activity activity, FloatingActionButton fab) {
@@ -82,9 +83,12 @@ public class FloatingActionButtonController {
}
}
- public void changeIcon(Drawable icon, String description) {
- if (mFab.getDrawable() != icon || !mFab.getContentDescription().equals(description)) {
- mFab.setImageDrawable(icon);
+ public void changeIcon(@DrawableRes int iconId, String description) {
+ if (this.mFabIconId != iconId) {
+ mFab.setImageResource(iconId);
+ this.mFabIconId = iconId;
+ }
+ if (!mFab.getContentDescription().equals(description)) {
mFab.setContentDescription(description);
}
}