Fix divider not showing in catalog in RTL

PiperOrigin-RevId: 195878162
This commit is contained in:
marianomartin 2018-05-08 17:37:42 -04:00 committed by Daniel Nizri
parent f880fef926
commit c7e01de03d

View File

@ -22,6 +22,7 @@ import android.graphics.Paint.Style;
import android.graphics.Rect;
import android.support.annotation.ColorInt;
import android.support.annotation.Px;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.RecyclerView.ItemDecoration;
@ -77,6 +78,8 @@ public class GridDividerDecoration extends RecyclerView.ItemDecoration {
private void drawVertical(Canvas canvas, RecyclerView parent) {
final int childCount = parent.getChildCount();
final boolean isRTL =
ViewCompat.getLayoutDirection(parent) == ViewCompat.LAYOUT_DIRECTION_RTL;
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
@ -85,7 +88,7 @@ public class GridDividerDecoration extends RecyclerView.ItemDecoration {
}
parent.getDecoratedBoundsWithMargins(child, bounds);
final int x = bounds.right;
final int x = isRTL ? bounds.left : bounds.right;
final int startY = bounds.top;
final int stopY = bounds.bottom;
canvas.drawLine(x, startY, x, stopY, dividerPaint);