Merge "Fixing NPE in recycler view scroll bar." into ub-launcher3-burnaby

This commit is contained in:
Winson Chung
2015-08-31 22:08:41 +00:00
committed by Android (Google) Code Review
@@ -88,6 +88,12 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
*/ */
@Override @Override
public String scrollToPositionAtProgress(float touchFraction) { public String scrollToPositionAtProgress(float touchFraction) {
// Skip early if widgets are not bound.
if (mWidgets == null) {
return "";
}
// Skip early if there are no widgets.
int rowCount = mWidgets.getPackageSize(); int rowCount = mWidgets.getPackageSize();
if (rowCount == 0) { if (rowCount == 0) {
return ""; return "";
@@ -112,9 +118,13 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
*/ */
@Override @Override
public void onUpdateScrollbar(int dy) { public void onUpdateScrollbar(int dy) {
int rowCount = mWidgets.getPackageSize(); // Skip early if widgets are not bound.
if (mWidgets == null) {
return;
}
// Skip early if, there are no items. // Skip early if there are no widgets.
int rowCount = mWidgets.getPackageSize();
if (rowCount == 0) { if (rowCount == 0) {
mScrollbar.setThumbOffset(-1, -1); mScrollbar.setThumbOffset(-1, -1);
return; return;
@@ -138,9 +148,13 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
stateOut.rowTopOffset = -1; stateOut.rowTopOffset = -1;
stateOut.rowHeight = -1; stateOut.rowHeight = -1;
int rowCount = mWidgets.getPackageSize(); // Skip early if widgets are not bound.
if (mWidgets == null) {
return;
}
// Return early if there are no items // Return early if there are no items
int rowCount = mWidgets.getPackageSize();
if (rowCount == 0) { if (rowCount == 0) {
return; return;
} }