Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5fcdc17 authored by Justin Klaassen's avatar Justin Klaassen
Browse files

Workaround for SwitchCompat animation issue

Bug: 21143340

The SwitchCompat instance must be un-attached from its parent in order
to avoid running the checked animation, which may get stuck when
ListView calls View#jumpDrawablesToCurrentState() on a recycled view.

Change-Id: I0a46f55624d17130ba4a6950f1746fca3af13fe0
parent 80713393
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -710,7 +710,18 @@ public abstract class AlarmClockFragment extends DeskClockFragment implements
            // We must unset the listener first because this maybe a recycled view so changing the
            // state would affect the wrong alarm.
            itemHolder.onoff.setOnCheckedChangeListener(null);

            // Hack to workaround b/21459481: the SwitchCompat instance must be detached from
            // its parent in order to avoid running the checked animation, which may get stuck
            // when ListView calls View#jumpDrawablesToCurrentState() on a recycled view.
            if (itemHolder.onoff.isChecked() != alarm.enabled) {
                final ViewGroup onoffParent = (ViewGroup) itemHolder.onoff.getParent();
                final int onoffIndex = onoffParent.indexOfChild(itemHolder.onoff);

                onoffParent.removeView(itemHolder.onoff);
                itemHolder.onoff.setChecked(alarm.enabled);
                onoffParent.addView(itemHolder.onoff, onoffIndex);
            }

            if (mSelectedAlarms.contains(itemHolder.alarm.id)) {
                setAlarmItemBackgroundAndElevation(itemHolder.alarmItem, true /* expanded */);