浏览代码

Moved upload waiting for Wifi to the section 'current' in uploads view

David A. Velasco 9 年之前
父节点
当前提交
dab4ef4550

+ 18 - 3
src/com/owncloud/android/datamodel/UploadsStorageManager.java

@@ -363,12 +363,15 @@ public class UploadsStorageManager extends Observable {
      * Get all uploads which are currently being uploaded or waiting in the queue to be uploaded.
      */
     public OCUpload[] getCurrentAndPendingUploads() {
-        return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value, null);
+        return getUploads(
+            ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_IN_PROGRESS.value + " OR " +
+            ProviderTableMeta.UPLOADS_LAST_RESULT + "==" + UploadResult.DELAYED_FOR_WIFI.getValue(),
+            null
+        );
     }
 
     /**
-     * Get all unrecoverably failed. Upload of these should/must/will not be
-     * retried.
+     * Get all failed uploads.
      */
     public OCUpload[] getFailedUploads() {
         return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value, null);
@@ -381,6 +384,18 @@ public class UploadsStorageManager extends Observable {
         return getUploads(ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_SUCCEEDED.value, null);
     }
 
+    /**
+     * Get all failed uploads, except for those that were not performed due to lack of Wifi connection
+     * @return      Array of failed uploads, except for those that were not performed due to lack of Wifi connection.
+     */
+    public OCUpload[] getFailedButNotDelayedForWifiUploads() {
+        return getUploads(
+            ProviderTableMeta.UPLOADS_STATUS + "==" + UploadStatus.UPLOAD_FAILED.value + " AND " +
+                ProviderTableMeta.UPLOADS_LAST_RESULT + "<>" + UploadResult.DELAYED_FOR_WIFI.getValue(),
+            null
+        );
+    }
+
     private ContentResolver getDB() {
         return mContentResolver;
     }

+ 6 - 1
src/com/owncloud/android/ui/adapter/ExpandableUploadListAdapter.java

@@ -92,6 +92,9 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
             @Override
             public int compare(OCUpload upload1, OCUpload upload2) {
                 if (upload1.getUploadStatus().equals(UploadStatus.UPLOAD_IN_PROGRESS)) {
+                    if (!upload2.getUploadStatus().equals(UploadStatus.UPLOAD_IN_PROGRESS)) {
+                        return -1;
+                    }
                     FileUploader.FileUploaderBinder binder = mParentActivity.getFileUploaderBinder();
                     if (binder != null) {
                         if (binder.isUploadingNow(upload1)) {
@@ -100,6 +103,8 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
                             return 1;
                         }
                     }
+                } else if (upload2.getUploadStatus().equals(UploadStatus.UPLOAD_IN_PROGRESS)) {
+                    return 1;
                 }
                 if (upload1.getUploadEndTimestamp() == 0) {
                     return compareUploadId(upload1, upload2);
@@ -142,7 +147,7 @@ public class ExpandableUploadListAdapter extends BaseExpandableListAdapter imple
         mUploadGroups[1] = new UploadGroup(mParentActivity.getString(R.string.uploads_view_group_failed_uploads)) {
             @Override
             public void refresh() {
-                items = mUploadsStorageManager.getFailedUploads();
+                items = mUploadsStorageManager.getFailedButNotDelayedForWifiUploads();
                 Arrays.sort(items, comparator);
             }