guilin 1 month ago
parent
commit
84572760c2

+ 9 - 6
app/src/main/java/com/fxy/common/AsyncFileUpload.java

@@ -319,26 +319,27 @@ public class AsyncFileUpload {
      */
     private void resultUpload(String tmpRealmId,Integer status,String photoPath){
         if (tmpRealmId!=null && !tmpRealmId.isEmpty()){
-            int rePush = 0;
             //遍历删除
             if (awaitUploadList.size()>0){
                 for (int i=0;i<awaitUploadList.size();i++){
                     if (awaitUploadList.get(i).getId().equals(tmpRealmId)){
-                        rePush = awaitUploadList.get(i).getRePush();
                         awaitUploadList.remove(i);
                         break;
                     }
                 }
             }
 
-            int pushStatus = 2;
-            if (status==0){
-                pushStatus = rePush>4 ? 1 : 0;
-            }
+
             //更新值
             mRealm.beginTransaction();
             AsyncUploadRealm myObject = mRealm.where(AsyncUploadRealm.class).equalTo("id",tmpRealmId).findFirst();
             assert myObject != null;
+            int pushStatus = 2;
+            int rePush = myObject.getRePush();
+            if (status==0){
+                pushStatus = rePush>4 ? 1 : 0;
+            }
+
             if (myObject.getPushStatus()!=3){
                 myObject.setPushStatus(pushStatus);
             }
@@ -348,6 +349,8 @@ public class AsyncFileUpload {
             }
             if (status == 1){
                 myObject.setOssUrl(photoPath);
+            }else{
+                myObject.setRePush(myObject.getRePush()+1);
             }
 
 

+ 12 - 6
app/src/main/java/com/fxy/common/AsyncPictureUpload.java

@@ -452,6 +452,7 @@ public class AsyncPictureUpload {
         Integer[] isFinish = {0,1,2};
         RealmResults<AsyncUploadRealm> realmResults ;
         RealmQuery<AsyncUploadRealm> queryRealm =  mRealm.where(AsyncUploadRealm.class)
+                .in("isFinish",isFinish)
                 .equalTo("isDelete",0);
         if (isAllRe){
             Integer[] pushStatus = {0,1};
@@ -459,6 +460,7 @@ public class AsyncPictureUpload {
 //                    .equalTo("notifyKey",fileKey)
 //                    .equalTo("uploadType",uploadType)
                     ;
+            isAllRe = false;
         }else{
             queryRealm.equalTo("pushStatus",0)
 //                    .equalTo("notifyKey",fileKey)
@@ -487,26 +489,28 @@ public class AsyncPictureUpload {
      */
     private void resultUpload(String tmpRealmId,Integer status,String photoPath){
         if (tmpRealmId!=null && !tmpRealmId.isEmpty()){
-            int rePush = 0;
+
             //遍历删除
             if (awaitUploadList.size()>0){
                 for (int i=0;i<awaitUploadList.size();i++){
                     if (awaitUploadList.get(i).getId().equals(tmpRealmId)){
-                        rePush = awaitUploadList.get(i).getRePush();
                         awaitUploadList.remove(i);
                         break;
                     }
                 }
             }
 
-            int pushStatus = 2;
-            if (status==0){
-                pushStatus = rePush>4 ? 1 : 0;
-            }
+
             //更新值
             mRealm.beginTransaction();
             AsyncUploadRealm myObject = mRealm.where(AsyncUploadRealm.class).equalTo("id",tmpRealmId).findFirst();
             assert myObject != null;
+            int rePush = myObject.getRePush();
+            int pushStatus = 2;
+            if (status==0){
+                pushStatus = rePush>4 ? 1 : 0;
+            }
+
             if (myObject.getPushStatus()!=3){
                 myObject.setPushStatus(pushStatus);
             }
@@ -516,6 +520,8 @@ public class AsyncPictureUpload {
             }
             if (status == 1){
                 myObject.setOssUrl(photoPath);
+            }else{
+                myObject.setRePush(myObject.getRePush()+1);
             }
             mRealm.commitTransaction();