release-request-ffeef8d5-ea8d-4e3e-9efa-ff171615a565-for-git_oc-dr1-release-3941039 snap-temp-L12800000057524396
Change-Id: I76f6da4c5b505ada0b7a4f7da0d238c20fc22b73
diff --git a/car-stream-ui-lib/res/layout/car_paged_recycler_view.xml b/car-stream-ui-lib/res/layout/car_paged_recycler_view.xml
index 36e99ed..c36ece3 100644
--- a/car-stream-ui-lib/res/layout/car_paged_recycler_view.xml
+++ b/car-stream-ui-lib/res/layout/car_paged_recycler_view.xml
@@ -27,8 +27,9 @@
android:layout_gravity="center_horizontal"
android:clipChildren="false"/>
</com.android.car.view.MaxWidthLayout>
- <!-- The scroll bar should be drawn ontop of the centered recycler view-->
+ <!-- The scroll bar should be drawn on top of the centered recycler view -->
<FrameLayout
+ android:id="@+id/scroll_container"
android:layout_width="@dimen/car_drawer_button_container_width"
android:layout_height="match_parent">
<com.android.car.view.PagedScrollBarView
diff --git a/car-stream-ui-lib/res/values/attrs.xml b/car-stream-ui-lib/res/values/attrs.xml
index f823183..b7db9df 100644
--- a/car-stream-ui-lib/res/values/attrs.xml
+++ b/car-stream-ui-lib/res/values/attrs.xml
@@ -22,6 +22,10 @@
<attr name="glowColor" format="color" />
<!-- Whether loading list view in drawer or not -->
<attr name="usedInDrawer" format="boolean" />
+ <!-- Whether show a divider line between each row or not -->
+ <attr name="showDivider" format="boolean" />
+ <!-- The width of the container for the scroll -->
+ <attr name="scrollbarContainerWidth" format="dimension" />
</declare-styleable>
<declare-styleable name="StreamCardView">
diff --git a/car-stream-ui-lib/src/com/android/car/view/PagedListView.java b/car-stream-ui-lib/src/com/android/car/view/PagedListView.java
index ddc357f..08a7a9e 100644
--- a/car-stream-ui-lib/src/com/android/car/view/PagedListView.java
+++ b/car-stream-ui-lib/src/com/android/car/view/PagedListView.java
@@ -53,7 +53,7 @@
private final CarLayoutManager mLayoutManager;
private final PagedScrollBarView mScrollBarView;
private final Handler mHandler = new Handler();
- private Decoration mDecor = new Decoration(getContext());
+ private DividerDecoration mDecor;
/** Maximum number of pages to show. Values < 0 show all pages. */
private int mMaxPages = -1;
@@ -106,19 +106,33 @@
super(context, attrs, defStyleAttrs, defStyleRes);
TypedArray a = context.obtainStyledAttributes(
attrs, R.styleable.PagedListView, defStyleAttrs, defStyleRes);
- boolean usedInDrawer = a.getBoolean(R.styleable.PagedListView_usedInDrawer, false);
LayoutInflater.from(context)
.inflate(R.layout.car_paged_recycler_view, this /*root*/, true /*attachToRoot*/);
+ int scrollContainerWidth = getResources().getDimensionPixelSize(
+ R.dimen.car_drawer_button_container_width);
+ if (a.hasValue(R.styleable.PagedListView_scrollbarContainerWidth)) {
+ scrollContainerWidth = a.getDimensionPixelSize(
+ R.styleable.PagedListView_scrollbarContainerWidth,
+ scrollContainerWidth);
+ FrameLayout scrollContainer = (FrameLayout) findViewById(R.id.scroll_container);
+ LayoutParams params = (LayoutParams) scrollContainer.getLayoutParams();
+ params.width = scrollContainerWidth;
+ scrollContainer.setLayoutParams(params);
+ }
+
+ boolean usedInDrawer = a.getBoolean(R.styleable.PagedListView_usedInDrawer, false);
if (usedInDrawer) {
FrameLayout maxWidthLayout = (FrameLayout) findViewById(R.id.max_width_layout);
- LayoutParams params =
- (LayoutParams) maxWidthLayout.getLayoutParams();
- params.leftMargin = getResources().getDimensionPixelSize(
- R.dimen.car_drawer_button_container_width);
+ LayoutParams params = (LayoutParams) maxWidthLayout.getLayoutParams();
+ params.leftMargin = scrollContainerWidth;
params.rightMargin = getResources().getDimensionPixelSize(
R.dimen.car_drawer_margin_right);
maxWidthLayout.setLayoutParams(params);
}
+ boolean showDivider = a.getBoolean(R.styleable.PagedListView_showDivider, true);
+ mDecor = showDivider
+ ? new DividerDecoration(getContext()) : new NoDividerDecoration(getContext());
+
mRecyclerView = (CarRecyclerView) findViewById(R.id.recycler_view);
boolean fadeLastItem = a.getBoolean(R.styleable.PagedListView_fadeLastItem, false);
mRecyclerView.setFadeLastItem(fadeLastItem);
@@ -239,7 +253,7 @@
mMaxPages = getDefaultMaxPages();
}
- public void setDefaultItemDecoration(Decoration decor) {
+ public void setDefaultItemDecoration(DividerDecoration decor) {
removeDefaultItemDecoration();
mDecor = decor;
addItemDecoration(mDecor);
@@ -460,13 +474,13 @@
public void onLeaveBottom() {}
}
- public static class Decoration extends RecyclerView.ItemDecoration {
+ public static class DividerDecoration extends RecyclerView.ItemDecoration {
protected final Paint mPaint;
protected final int mDividerHeight;
protected final Context mContext;
- public Decoration(Context context) {
+ public DividerDecoration(Context context) {
mContext = context;
mPaint = new Paint();
updateDividerColor();
@@ -543,4 +557,13 @@
return null;
}
}
+
+ public static class NoDividerDecoration extends DividerDecoration {
+ public NoDividerDecoration(Context context) {
+ super(context);
+ }
+
+ @Override
+ public void onDrawOver(Canvas c, RecyclerView parent, RecyclerView.State state) {}
+ }
}