取缩略图任务串行化

chengzhenyu 8 ans auparavant
Parent
Commettre
1b23622758
1 fichiers modifiés avec 7 ajouts et 1 suppressions
  1. 7 1
      app/src/main/java/ai/pai/lensman/session/SessionInteractor.java

+ 7 - 1
app/src/main/java/ai/pai/lensman/session/SessionInteractor.java

@@ -37,7 +37,7 @@ public class SessionInteractor {
37 37
     private String randomSessionId;
38 38
     private long maxId = 0;
39 39
     private boolean isWorking;
40
-
40
+    private boolean isLastQueryReturned = true;
41 41
     private static final String TAG = "SessionInteractor";
42 42
 
43 43
         public SessionInteractor(SessionBean sessionBean, SessionListener listener) {
@@ -128,6 +128,9 @@ public class SessionInteractor {
128 128
         if(!isWorking){
129 129
             return;
130 130
         }
131
+        if(!isLastQueryReturned){
132
+            return;
133
+        }
131 134
 
132 135
         if(BuildConfig.isTestMode){
133 136
             PhotoBean bean = new PhotoBean();
@@ -202,11 +205,13 @@ public class SessionInteractor {
202 205
             protected void onPostFail() {
203 206
                 LogHelper.d(TAG,"fetchThumbnailTask onPostFail");
204 207
                 super.onPostFail();
208
+                isLastQueryReturned = true;
205 209
             }
206 210
 
207 211
             @Override
208 212
             protected void onPostSuccess() {
209 213
                 super.onPostSuccess();
214
+                isLastQueryReturned = true;
210 215
                 LogHelper.d(TAG,"fetchThumbnailTask onPostSuccess with photo number = "+photoList.size());
211 216
                 for(PhotoBean bean :photoList){
212 217
                     new SavePhotoTask(bean).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),bean);
@@ -215,6 +220,7 @@ public class SessionInteractor {
215 220
             }
216 221
         };
217 222
         fetchThumbnailTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.FETCH_THUMBNAIL_URL);
223
+        isLastQueryReturned = false;
218 224
         LogHelper.d(TAG,"fetchThumbnailTask starts");
219 225
     }
220 226