Bug 1337947 - Fix tab strip item offsets for RTL. r=maliu, a=gchang
authorTom Klein <twointofive@gmail.com>
Mon, 10 Apr 2017 09:16:14 -0500
changeset 393541 30801f76e945300a891b36408b9ee2fd113b18f6
parent 393540 6430228451e7fb677722a743b9a998ca188f7b43
child 393542 f3784c1c6bd45a7c4b8fddfa8670e3946527c7ab
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaliu, gchang
bugs1337947
milestone54.0a2
Bug 1337947 - Fix tab strip item offsets for RTL. r=maliu, a=gchang MozReview-Commit-ID: HrOETozOSfW
mobile/android/base/java/org/mozilla/gecko/tabs/TabStripDividerItem.java
--- a/mobile/android/base/java/org/mozilla/gecko/tabs/TabStripDividerItem.java
+++ b/mobile/android/base/java/org/mozilla/gecko/tabs/TabStripDividerItem.java
@@ -63,18 +63,26 @@ class TabStripDividerItem extends Recycl
         }
 
         return true;
     }
 
     @Override
     public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
         final int position = parent.getChildAdapterPosition(view);
-        final int leftOffset = position == 0 ? 0 : margin;
-        final int rightOffset = position == parent.getAdapter().getItemCount() - 1 ? 0 : margin;
+
+        // RTL positions start from the right, but offsets are still LTR since view is LTR.
+        final int leftOffset, rightOffset;
+        if (ViewUtils.isLayoutRtl(parent)) {
+            leftOffset = position == parent.getAdapter().getItemCount() - 1 ? 0 : margin;
+            rightOffset = position == 0 ? 0 : margin;
+        } else {
+            leftOffset = position == 0 ? 0 : margin;
+            rightOffset = position == parent.getAdapter().getItemCount() - 1 ? 0 : margin;
+        }
 
         outRect.set(leftOffset, 0, rightOffset, 0);
     }
 
     @Override
     public void onDraw(Canvas c, RecyclerView parent, RecyclerView.State state) {
         final int childCount = parent.getChildCount();
         if (childCount == 0) {