OSDN Git Service

Fix bug #8629386 FastScroller is on the wrong side when switching to Hebrew in a...
authorFabrice Di Meglio <fdimeglio@google.com>
Tue, 16 Apr 2013 22:40:18 +0000 (15:40 -0700)
committerFabrice Di Meglio <fdimeglio@google.com>
Tue, 16 Apr 2013 22:40:18 +0000 (15:40 -0700)
- in AbsListView, force setScrollbarPosition() when RTL properties change
- in FastScroller, invalidate the correct rectangle when in RTL mode and in STATE_EXIT

Change-Id: Ie9fe4f826e179eb993e443d10e171b9dda3b6f3f

core/java/android/widget/AbsListView.java
core/java/android/widget/FastScroller.java

index 94dadb4..c72853f 100644 (file)
@@ -2699,6 +2699,15 @@ public abstract class AbsListView extends AdapterView<ListAdapter> implements Te
         mLastTouchMode = touchMode;
     }
 
+    @Override
+    public void onRtlPropertiesChanged(int layoutDirection) {
+        super.onRtlPropertiesChanged(layoutDirection);
+
+        if (mFastScroller != null) {
+           mFastScroller.setScrollbarPosition(getVerticalScrollbarPosition());
+        }
+    }
+
     /**
      * Creates the ContextMenuInfo returned from {@link #getContextMenuInfo()}. This
      * methods knows the view, position and ID of the item that received the
index d2139af..fc9c000 100644 (file)
@@ -216,8 +216,22 @@ class FastScroller {
                 mHandler.removeCallbacks(mScrollFade);
                 break;
             case STATE_EXIT:
-                int viewWidth = mList.getWidth();
-                mList.invalidate(viewWidth - mThumbW, mThumbY, viewWidth, mThumbY + mThumbH);
+                final int viewWidth = mList.getWidth();
+                final int top = mThumbY;
+                final int bottom = mThumbY + mThumbH;
+                final int left;
+                final int right;
+                switch (mList.getLayoutDirection()) {
+                    case View.LAYOUT_DIRECTION_RTL:
+                        left = 0;
+                        right = mThumbW;
+                        break;
+                    case View.LAYOUT_DIRECTION_LTR:
+                    default:
+                        left = viewWidth - mThumbW;
+                        right = viewWidth;
+                }
+                mList.invalidate(left, top, right, bottom);
                 break;
         }
         mState = state;
@@ -398,10 +412,26 @@ class FastScroller {
         } else if (mState == STATE_EXIT) {
             if (alpha == 0) { // Done with exit
                 setState(STATE_NONE);
-            } else if (mTrackDrawable != null) {
-                mList.invalidate(viewWidth - mThumbW, 0, viewWidth, mList.getHeight());
             } else {
-                mList.invalidate(viewWidth - mThumbW, y, viewWidth, y + mThumbH);
+                final int left, right, top, bottom;
+                if (mTrackDrawable != null) {
+                    top = 0;
+                    bottom = mList.getHeight();
+                } else {
+                    top = y;
+                    bottom = y + mThumbH;
+                }
+                switch (mList.getLayoutDirection()) {
+                    case View.LAYOUT_DIRECTION_RTL:
+                        left = 0;
+                        right = mThumbW;
+                        break;
+                    case View.LAYOUT_DIRECTION_LTR:
+                    default:
+                        left = viewWidth - mThumbW;
+                        right = viewWidth;
+                }
+                mList.invalidate(left, top, right, bottom);
             }
         }
     }