summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson <winsonc@google.com>2015-08-31 22:02:26 (GMT)
committerWinson <winsonc@google.com>2015-08-31 22:02:26 (GMT)
commit23c8f48f4334b0ac0752b320dad2c1fc5ef095f3 (patch)
treebab26817d44df9cf285df75a99467149309da9a2
parenta79b18ad36ca9025ac4862c492260a656f61c7cf (diff)
downloadandroid_packages_apps_Trebuchet-23c8f48f4334b0ac0752b320dad2c1fc5ef095f3.zip
android_packages_apps_Trebuchet-23c8f48f4334b0ac0752b320dad2c1fc5ef095f3.tar.gz
android_packages_apps_Trebuchet-23c8f48f4334b0ac0752b320dad2c1fc5ef095f3.tar.bz2
Fixing NPE in recycler view scroll bar.
- The regression was introduced in scroll bar changes ag/751628, but unlike AllApps, the WidgetsRecyclerView can have an unbound model. Bug: 23689784 Change-Id: Ibd3d5bcbafab0ada9a372fa00acaa45809ce720d
-rw-r--r--src/com/android/launcher3/widget/WidgetsRecyclerView.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/com/android/launcher3/widget/WidgetsRecyclerView.java b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
index 3dcb332..884bdc4 100644
--- a/src/com/android/launcher3/widget/WidgetsRecyclerView.java
+++ b/src/com/android/launcher3/widget/WidgetsRecyclerView.java
@@ -88,6 +88,12 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
*/
@Override
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();
if (rowCount == 0) {
return "";
@@ -112,9 +118,13 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
*/
@Override
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) {
mScrollbar.setThumbOffset(-1, -1);
return;
@@ -138,9 +148,13 @@ public class WidgetsRecyclerView extends BaseRecyclerView {
stateOut.rowTopOffset = -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
+ int rowCount = mWidgets.getPackageSize();
if (rowCount == 0) {
return;
}