浏览代码

images can be deleted thus no filepath, but are still in media store.
Failed images are substracted from the "real" count.

tobiasKaminsky 7 年之前
父节点
当前提交
7986682da6
共有 1 个文件被更改,包括 9 次插入3 次删除
  1. 9 3
      src/main/java/com/owncloud/android/datamodel/MediaProvider.java

+ 9 - 3
src/main/java/com/owncloud/android/datamodel/MediaProvider.java

@@ -119,11 +119,17 @@ public class MediaProvider {
 
                 if (cursorImages != null) {
                     String filePath;
+                    int failedImages = 0;
                     while (cursorImages.moveToNext()) {
                         filePath = cursorImages.getString(cursorImages.getColumnIndexOrThrow(
                                 MediaStore.MediaColumns.DATA));
-                        mediaFolder.filePaths.add(filePath);
-                        mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf("/"));
+
+                        if (filePath != null) {
+                            mediaFolder.filePaths.add(filePath);
+                            mediaFolder.absolutePath = filePath.substring(0, filePath.lastIndexOf("/"));
+                        } else {
+                            failedImages++;
+                        }
                     }
                     cursorImages.close();
 
@@ -139,7 +145,7 @@ public class MediaProvider {
                                 null);
 
                         if (count != null) {
-                            mediaFolder.numberOfFiles = count.getCount();
+                            mediaFolder.numberOfFiles = count.getCount() - failedImages;
                             count.close();
                         }