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

Commit 568ccd88 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 5073637 - Market apps crashing FastScroller

It seems that some popular Market apps do not properly implement
SectionIndexer#getSectionForPosition and the framework did not
previously call it. Revert to more simplistic scrollbar behavior for
apps targeting sdk < Honeycomb.

Change-Id: If0b1f2b4db540de4bb8ba45798e498c09cddb42f
parent cf27a3ec
Loading
Loading
Loading
Loading
+7 −2
Original line number Original line Diff line number Diff line
@@ -116,6 +116,8 @@ class FastScroller {


    private int mOverlayPosition;
    private int mOverlayPosition;


    private boolean mMatchDragPosition;

    private static final int FADE_TIMEOUT = 1500;
    private static final int FADE_TIMEOUT = 1500;


    private final Rect mTmpRect = new Rect();
    private final Rect mTmpRect = new Rect();
@@ -262,6 +264,9 @@ class FastScroller {


        ta.recycle();
        ta.recycle();


        mMatchDragPosition = context.getApplicationInfo().targetSdkVersion >=
                android.os.Build.VERSION_CODES.HONEYCOMB;

        setScrollbarPosition(mList.getVerticalScrollbarPosition());
        setScrollbarPosition(mList.getVerticalScrollbarPosition());
    }
    }
    
    
@@ -595,7 +600,7 @@ class FastScroller {
        if (mSectionIndexer == null) {
        if (mSectionIndexer == null) {
            getSectionsFromIndexer();
            getSectionsFromIndexer();
        }
        }
        if (mSectionIndexer == null) {
        if (mSectionIndexer == null || !mMatchDragPosition) {
            return ((mList.getHeight() - mThumbH) * firstVisibleItem)
            return ((mList.getHeight() - mThumbH) * firstVisibleItem)
                    / (totalItemCount - visibleItemCount);
                    / (totalItemCount - visibleItemCount);
        }
        }