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

Commit bbaccb4f authored by Michael Chan's avatar Michael Chan Committed by Android (Google) Code Review
Browse files

Merge "Agenda:Smooth scroll to position instead of jumping." into jb-dev

parents ad096b3f 2ea6e0ee
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -131,6 +131,8 @@ public class AgendaWindowAdapter extends BaseAdapter
    private static final int MAX_QUERY_DURATION = 60; // days
    private static final int PREFETCH_BOUNDARY = 1;

    private static final int MAX_SMOOTH_DISTANCE = 20;

    /** Times to auto-expand/retry query after getting no data */
    private static final int RETRIES_ON_NO_DATA = 1;

@@ -658,11 +660,20 @@ public class AgendaWindowAdapter extends BaseAdapter
            if (!mAgendaListView.isEventVisible(goToTime, id)) {
                int gotoPosition = findEventPositionNearestTime(goToTime, id);
                if (gotoPosition > 0) {
                    mAgendaListView.setSelectionFromTop(gotoPosition +
                            OFF_BY_ONE_BUG, mStickyHeaderSize);
                    if (mListViewScrollState == OnScrollListener.SCROLL_STATE_FLING) {
                        mAgendaListView.smoothScrollBy(0, 0);
                    }

                    if (MAX_SMOOTH_DISTANCE < Math.abs(gotoPosition
                            - mAgendaListView.getFirstVisiblePosition())) {
                        // Too many items to scroll through. Jump straight to it.
                        mAgendaListView.setSelectionFromTop(gotoPosition + OFF_BY_ONE_BUG,
                                mStickyHeaderSize);
                    } else {
                        mAgendaListView.smoothScrollToPositionFromTop(
                                gotoPosition + OFF_BY_ONE_BUG, mStickyHeaderSize);
                    }

                    if (refreshEventInfo) {
                        long newInstanceId = findInstanceIdFromPosition(gotoPosition);
                        if (newInstanceId != getSelectedInstanceId()) {