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

Commit d3859fa8 authored by Sam Blitzstein's avatar Sam Blitzstein
Browse files

Fix alarm expanding issues (correctly).

Use expandAlarm() directly instead of getView().
If alarm is not in view, no need to expand it explicitly, it'll
happen on its own when getView is called.

Bug: 10695073
Bug: 10840150
Change-Id: Ica8816b9770791b83c94f2c5dc349569f46d8e14
parent 991cb4d2
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -609,8 +609,20 @@ public class AlarmClockFragment extends DeskClockFragment implements
            final int firstPositionId = mAlarmsList.getFirstVisiblePosition();
            final int childId = alarmPosition - firstPositionId;

            // We need to expand the first view item because bindView may have been called
            // before setNewAlarm took effect. In that case, the newly created alarm will not be
            // expanded.
            final View view = mAlarmsList.getChildAt(childId);
            mAdapter.getView(alarmPosition, view, mAlarmsList);
            if (view != null) {
                // The view may be null if it isn't visible yet. In that case, the above call to
                // setNewAlarm() will make sure it's expanded when it comes into view.
                Object tag = view.getTag();
                if (tag != null && tag instanceof AlarmItemAdapter.ItemHolder) {
                    mAdapter.expandAlarm((AlarmItemAdapter.ItemHolder) tag, true);
                } else {
                    Log.e("Unable to get ItemHolder for view at id "+childId);
                }
            }
        } else {
            // Trying to display a deleted alarm should only happen from a missed notification for
            // an alarm that has been marked deleted after use.
@@ -1760,12 +1772,6 @@ public class AlarmClockFragment extends DeskClockFragment implements
                }
                mAdapter.setNewAlarm(alarm.id);
                scrollToAlarm(alarm.id);

                // We need to refresh the first view item because bindView may have been called
                // before setNewAlarm took effect. In that case, the newly created alarm will not be
                // expanded.
                View view = mAlarmsList.getChildAt(0);
                mAdapter.getView(0, view, mAlarmsList);
            }
        };
        updateTask.execute();