Merge "Fixing NPE in recycler view scroll bar." into ub-launcher3-burnaby
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 @@
      */
     @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 @@
      */
     @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 @@
         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;
         }