Fixed FAB enabled color not restoring correctly
This commit is contained in:
parent
07277163ae
commit
591bc6d680
@ -476,20 +476,26 @@ public class NumpadTimePicker extends GridLayoutNumpad {
|
|||||||
private void updateFabState() {
|
private void updateFabState() {
|
||||||
final boolean lastEnabled = mFab.isEnabled();
|
final boolean lastEnabled = mFab.isEnabled();
|
||||||
mFab.setEnabled(checkTimeValid());
|
mFab.setEnabled(checkTimeValid());
|
||||||
if (lastEnabled == mFab.isEnabled())
|
// If the fab was last enabled and we rotate, this check will prevent us from
|
||||||
return;
|
// restoring the color; it will instead show up opaque white with an eclipse.
|
||||||
|
// Why isn't the FAB initialized to enabled == false when it is recreated?
|
||||||
|
// The FAB class probably saves its own state.
|
||||||
|
// if (lastEnabled == mFab.isEnabled())
|
||||||
|
// return;
|
||||||
|
|
||||||
// Workaround for mFab.setBackgroundTintList() because I don't know how to reference the
|
// Workaround for mFab.setBackgroundTintList() because I don't know how to reference the
|
||||||
// correct accent color in XML. Also because I don't want to programmatically create a
|
// correct accent color in XML. Also because I don't want to programmatically create a
|
||||||
// ColorStateList.
|
// ColorStateList.
|
||||||
int color;
|
int color;
|
||||||
if (mFab.isEnabled()) {
|
if (mFab.isEnabled()) {
|
||||||
color = mAccentColor;
|
color = mAccentColor;
|
||||||
if (mElevationAnimator != null) {
|
// If FAB was last enabled, then don't run the anim again.
|
||||||
|
if (mElevationAnimator != null && !lastEnabled) {
|
||||||
mElevationAnimator.start();
|
mElevationAnimator.start();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
color = mThemeDark? mFabDisabledColorDark : mFabDisabledColorLight;
|
color = mThemeDark? mFabDisabledColorDark : mFabDisabledColorLight;
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
if (lastEnabled && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
if (mElevationAnimator != null && mElevationAnimator.isRunning()) {
|
if (mElevationAnimator != null && mElevationAnimator.isRunning()) {
|
||||||
// Otherwise, eclipse will show.
|
// Otherwise, eclipse will show.
|
||||||
mElevationAnimator.end();
|
mElevationAnimator.end();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user