ソースを参照

GalleryFragment: fix crash when scrolling slowly until the end of the list

Signed-off-by: Álvaro Brey <alvaro.brey@nextcloud.com>
Álvaro Brey 2 年 前
コミット
c1ce254692

+ 4 - 0
app/src/main/java/com/owncloud/android/ui/fragment/GalleryFragment.java

@@ -340,6 +340,10 @@ public class GalleryFragment extends OCFileListFragment implements GalleryFragme
                 int totalItemCount = gridLayoutManager.getItemCount();
                 int lastVisibleItem = gridLayoutManager.findLastCompletelyVisibleItemPosition();
 
+                if (lastVisibleItem == RecyclerView.NO_POSITION) {
+                    return;
+                }
+
                 if ((totalItemCount - visibleItemCount) <= (lastVisibleItem + MAX_ITEMS_PER_ROW)
                     && (totalItemCount - visibleItemCount) > 0) {
                     // Almost reached the end, continue to load new photos