aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Chen <ajchen@google.com>2018-06-04 13:09:13 -0700
committerAnthony Chen <ajchen@google.com>2018-06-04 13:27:44 -0700
commit169bb62f840ab9177e8c186ce5f7299b362b7e2b (patch)
tree22a4c6491778df75e3c678aacd6833e512005e51
parent2289451962a820aed6ce37de5935b713897d0abd (diff)
downloadsupport-169bb62f840ab9177e8c186ce5f7299b362b7e2b.tar.gz
Expose pageUp() and pageDown() as public methods.
Fixes: 80555397 Test: test on sample app and attempt to call the method from an outside class. Ensure no errors. Change-Id: I426d605a77eb41eca84c505f4e97a776f1089957
-rw-r--r--car/api/current.txt3
-rw-r--r--car/src/main/java/androidx/car/widget/PagedListView.java29
2 files changed, 22 insertions, 10 deletions
diff --git a/car/api/current.txt b/car/api/current.txt
index 760b5b93443..d9a9e7fd438 100644
--- a/car/api/current.txt
+++ b/car/api/current.txt
@@ -296,6 +296,8 @@ package androidx.car.widget {
method public void onLayout(boolean, int, int, int, int);
method public void onRestoreInstanceState(android.os.Parcelable);
method public android.os.Parcelable onSaveInstanceState();
+ method public void pageDown();
+ method public void pageUp();
method public int positionOf(android.view.View);
method public void removeItemDecoration(androidx.recyclerview.widget.RecyclerView.ItemDecoration);
method public void removeOnItemTouchListener(androidx.recyclerview.widget.RecyclerView.OnItemTouchListener);
@@ -434,7 +436,6 @@ package androidx.car.widget {
method protected void resolveDirtyState();
method public void setText(java.lang.String);
method public void setTextStartMarginType(int);
- method public final boolean shouldHideDivider();
field public static final int TEXT_START_MARGIN_TYPE_LARGE = 2; // 0x2
field public static final int TEXT_START_MARGIN_TYPE_NONE = 0; // 0x0
field public static final int TEXT_START_MARGIN_TYPE_SMALL = 1; // 0x1
diff --git a/car/src/main/java/androidx/car/widget/PagedListView.java b/car/src/main/java/androidx/car/widget/PagedListView.java
index 1888b386a9a..95fc734eb53 100644
--- a/car/src/main/java/androidx/car/widget/PagedListView.java
+++ b/car/src/main/java/androidx/car/widget/PagedListView.java
@@ -16,8 +16,6 @@
package androidx.car.widget;
-import static androidx.annotation.RestrictTo.Scope.LIBRARY_GROUP;
-
import static java.lang.annotation.RetentionPolicy.SOURCE;
import android.content.Context;
@@ -43,7 +41,6 @@ import androidx.annotation.IdRes;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
-import androidx.annotation.RestrictTo;
import androidx.annotation.UiThread;
import androidx.annotation.VisibleForTesting;
import androidx.car.R;
@@ -818,11 +815,18 @@ public class PagedListView extends FrameLayout {
}
/**
- * Scrolls the contents of the RecyclerView up a page.
- * @hide
+ * Scrolls the contents of the RecyclerView up a page. A page is defined as the height of the
+ * {@code PagedListView}.
+ *
+ * <p>The resulting first item in the list will be snapped to so that it is completely visible.
+ * If this is not possible due to the first item being taller than the containing
+ * {@code PagedListView}, then the snapping will not occur.
*/
- @RestrictTo(LIBRARY_GROUP)
public void pageUp() {
+ if (mRecyclerView.getLayoutManager() == null || mRecyclerView.getChildCount() == 0) {
+ return;
+ }
+
// Use OrientationHelper to calculate scroll distance in order to match snapping behavior.
OrientationHelper orientationHelper =
getOrientationHelper(mRecyclerView.getLayoutManager());
@@ -858,11 +862,18 @@ public class PagedListView extends FrameLayout {
}
/**
- * Scrolls the contents of the RecyclerView down a page.
- * @hide
+ * Scrolls the contents of the RecyclerView down a page. A page is defined as the height of the
+ * {@code PagedListView}.
+ *
+ * <p>This method will attempt to bring the last item in the list as the first item. If the
+ * current first item in the list is taller than the {@code PagedListView}, then it will be
+ * scrolled the length of a page, but not snapped to.
*/
- @RestrictTo(LIBRARY_GROUP)
public void pageDown() {
+ if (mRecyclerView.getLayoutManager() == null || mRecyclerView.getChildCount() == 0) {
+ return;
+ }
+
OrientationHelper orientationHelper =
getOrientationHelper(mRecyclerView.getLayoutManager());
int screenSize = mRecyclerView.getHeight();