Bug 1337947 - Fix tab strip item offsets for RTL. r=maliu

MozReview-Commit-ID: HrOETozOSfW

--HG--
extra : rebase_source : e051b92d9b3b5105fe9a054b667b2334180e938f
This commit is contained in:
Tom Klein 2017-04-10 09:16:14 -05:00
Родитель 6e7d85d68f
Коммит 0a9827ccd3
1 изменённых файлов: 10 добавлений и 2 удалений

Просмотреть файл

@ -68,8 +68,16 @@ class TabStripDividerItem extends RecyclerView.ItemDecoration {
@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);
}