@Test public void testEdgeItemsCenteringOnAndOff() throws Throwable { mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); wrv.setEdgeItemsCenteringEnabled(true); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); View child = wrv.getChildAt(0); assertNotNull("child", child); assertEquals((wrv.getHeight() - child.getHeight()) / 2, child.getTop()); } }); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); wrv.setEdgeItemsCenteringEnabled(false); } }); InstrumentationRegistry.getInstrumentation().waitForIdleSync(); mActivityRule.runOnUiThread(new Runnable() { @Override public void run() { WearableRecyclerView wrv = (WearableRecyclerView) mActivityRule.getActivity().findViewById(R.id.wrv); View child = wrv.getChildAt(0); assertNotNull("child", child); assertEquals(0, child.getTop()); } }); }
public void setEdgeItemsCenteringEnabled(boolean isEnabled) { mEdgeItemsCenteringEnabled = isEnabled; if (mEdgeItemsCenteringEnabled) { if (getChildCount() > 0) { setupCenteredPadding(); } else { mCenterEdgeItemsWhenThereAreChildren = true; } } else { setupOriginalPadding(); mCenterEdgeItemsWhenThereAreChildren = false; } }
WearableRecyclerView extends RecyclerView { public void setEdgeItemsCenteringEnabled(boolean isEnabled) { mEdgeItemsCenteringEnabled = isEnabled; if (mEdgeItemsCenteringEnabled) { if (getChildCount() > 0) { setupCenteredPadding(); } else { mCenterEdgeItemsWhenThereAreChildren = true; } } else { setupOriginalPadding(); mCenterEdgeItemsWhenThereAreChildren = false; } } }
WearableRecyclerView extends RecyclerView { public void setEdgeItemsCenteringEnabled(boolean isEnabled) { mEdgeItemsCenteringEnabled = isEnabled; if (mEdgeItemsCenteringEnabled) { if (getChildCount() > 0) { setupCenteredPadding(); } else { mCenterEdgeItemsWhenThereAreChildren = true; } } else { setupOriginalPadding(); mCenterEdgeItemsWhenThereAreChildren = false; } } WearableRecyclerView(Context context);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle,
            int defStyleRes); }
WearableRecyclerView extends RecyclerView { public void setEdgeItemsCenteringEnabled(boolean isEnabled) { mEdgeItemsCenteringEnabled = isEnabled; if (mEdgeItemsCenteringEnabled) { if (getChildCount() > 0) { setupCenteredPadding(); } else { mCenterEdgeItemsWhenThereAreChildren = true; } } else { setupOriginalPadding(); mCenterEdgeItemsWhenThereAreChildren = false; } } WearableRecyclerView(Context context);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle,
            int defStyleRes); @Override boolean onTouchEvent(MotionEvent event); void setCircularScrollingGestureEnabled(boolean circularScrollingGestureEnabled); boolean isCircularScrollingGestureEnabled(); void setScrollDegreesPerScreen(float degreesPerScreen); float getScrollDegreesPerScreen(); void setBezelFraction(float fraction); float getBezelFraction(); void setEdgeItemsCenteringEnabled(boolean isEnabled); boolean isEdgeItemsCenteringEnabled(); }
WearableRecyclerView extends RecyclerView { public void setEdgeItemsCenteringEnabled(boolean isEnabled) { mEdgeItemsCenteringEnabled = isEnabled; if (mEdgeItemsCenteringEnabled) { if (getChildCount() > 0) { setupCenteredPadding(); } else { mCenterEdgeItemsWhenThereAreChildren = true; } } else { setupOriginalPadding(); mCenterEdgeItemsWhenThereAreChildren = false; } } WearableRecyclerView(Context context);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle);  WearableRecyclerView(Context context, @Nullable AttributeSet attrs, int defStyle,
            int defStyleRes); @Override boolean onTouchEvent(MotionEvent event); void setCircularScrollingGestureEnabled(boolean circularScrollingGestureEnabled); boolean isCircularScrollingGestureEnabled(); void setScrollDegreesPerScreen(float degreesPerScreen); float getScrollDegreesPerScreen(); void setBezelFraction(float fraction); float getBezelFraction(); void setEdgeItemsCenteringEnabled(boolean isEnabled); boolean isEdgeItemsCenteringEnabled();  }