Sfoglia il codice sorgente

Merge pull request #11067 from nextcloud/fix/gallery-crash

GalleryFragment: fix crash when scrolling slowly until the end of the list
Álvaro Brey 2 anni fa
parent
commit
c938a929c1

+ 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