@@ -59,6 +59,9 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
59 | 59 |
if(bean.equals(currentPhoto)){ |
60 | 60 |
currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_ERROR; |
61 | 61 |
DBService.getInstance().updatePhotoBean(currentPhoto); |
62 |
+ if(listener!=null){ |
|
63 |
+ listener.onPhotoUploadError(currentPhoto); |
|
64 |
+ } |
|
62 | 65 |
currentPhoto = null; |
63 | 66 |
} |
64 | 67 |
startUpload(); |
@@ -70,6 +73,7 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
70 | 73 |
|
71 | 74 |
public interface PhotoUploadListener{ |
72 | 75 |
void onPhotoUploaded(PhotoBean bean); |
76 |
+ void onPhotoUploadError(PhotoBean bean); |
|
73 | 77 |
} |
74 | 78 |
|
75 | 79 |
public class MyBinder extends Binder { |
@@ -118,14 +118,14 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
118 | 118 |
|
119 | 119 |
@Override |
120 | 120 |
public void showPhotoRecyclerView() { |
121 |
- noPhotoLayout.setVisibility(android.view.View.GONE); |
|
122 |
- photosRecyclerView.setVisibility(android.view.View.VISIBLE); |
|
121 |
+ noPhotoLayout.setVisibility(View.GONE); |
|
122 |
+ photosRecyclerView.setVisibility(View.VISIBLE); |
|
123 | 123 |
} |
124 | 124 |
|
125 | 125 |
@Override |
126 | 126 |
public void showEmptyView() { |
127 |
- photosRecyclerView.setVisibility(android.view.View.GONE); |
|
128 |
- noPhotoLayout.setVisibility(android.view.View.VISIBLE); |
|
127 |
+ photosRecyclerView.setVisibility(View.GONE); |
|
128 |
+ noPhotoLayout.setVisibility(View.VISIBLE); |
|
129 | 129 |
} |
130 | 130 |
|
131 | 131 |
@Override |
@@ -101,7 +101,7 @@ public class SessionInteractor { |
||
101 | 101 |
public void run() { |
102 | 102 |
fetchThumbnailTask(); |
103 | 103 |
} |
104 |
- },1000,1000); |
|
104 |
+ },1000,100); |
|
105 | 105 |
} |
106 | 106 |
|
107 | 107 |
private void fetchThumbnailTask(){ |
@@ -16,6 +16,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
16 | 16 |
private ArrayList<PhotoBean> photoList; |
17 | 17 |
private SessionContract.View sessionView; |
18 | 18 |
private SessionBean sessionBean; |
19 |
+ private boolean isWorking; |
|
19 | 20 |
|
20 | 21 |
public SessionPresenter(SessionBean sessionBean, SessionContract.View view) { |
21 | 22 |
this.sessionView = view; |
@@ -40,10 +41,12 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
40 | 41 |
@Override |
41 | 42 |
public void stop() { |
42 | 43 |
interactor.endSession(); |
44 |
+ isWorking = false; |
|
43 | 45 |
} |
44 | 46 |
|
45 | 47 |
@Override |
46 | 48 |
public void onSessionStartSuccess(String session) { |
49 |
+ isWorking = true; |
|
47 | 50 |
sessionView.showToast("session启动成功"); |
48 | 51 |
} |
49 | 52 |
|
@@ -54,6 +57,9 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
54 | 57 |
|
55 | 58 |
@Override |
56 | 59 |
public void onSessionPhotoCaptured(final PhotoBean bean) { |
60 |
+ if(!isWorking){ |
|
61 |
+ return; |
|
62 |
+ } |
|
57 | 63 |
DBService.getInstance().addPhotoBean(bean); |
58 | 64 |
sessionView.showPhotoRecyclerView(); |
59 | 65 |
sessionView.addNewPhoto(bean); |
@@ -11,6 +11,7 @@ import android.widget.ProgressBar; |
||
11 | 11 |
import android.widget.TextView; |
12 | 12 |
|
13 | 13 |
import com.android.common.utils.DeviceUtils; |
14 |
+import com.android.common.utils.LogHelper; |
|
14 | 15 |
import com.nostra13.universalimageloader.core.DisplayImageOptions; |
15 | 16 |
|
16 | 17 |
import java.io.File; |
@@ -69,6 +70,7 @@ public class SessionRecyclerAdapter extends RecyclerView.Adapter<SessionRecycler |
||
69 | 70 |
|
70 | 71 |
@Override |
71 | 72 |
public void onBindViewHolder(MyViewHolder holder, int position) { |
73 |
+ LogHelper.d("czy","onBindViewHolder at position ="+position); |
|
72 | 74 |
if(sessionList==null){ |
73 | 75 |
return; |
74 | 76 |
} |
@@ -8,6 +8,8 @@ import android.support.v7.widget.RecyclerView; |
||
8 | 8 |
import android.widget.ImageView; |
9 | 9 |
import android.widget.TextView; |
10 | 10 |
|
11 |
+import com.android.common.utils.LogHelper; |
|
12 |
+ |
|
11 | 13 |
import java.util.ArrayList; |
12 | 14 |
|
13 | 15 |
import ai.pai.lensman.R; |
@@ -95,6 +97,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
95 | 97 |
|
96 | 98 |
@Override |
97 | 99 |
public void updateSessionUploadViewAt(int position) { |
100 |
+ LogHelper.d("czy","updateSessionUploadViewAt "+position); |
|
98 | 101 |
adapter.notifyItemChanged(position); |
99 | 102 |
} |
100 | 103 |
|
@@ -6,6 +6,8 @@ import android.content.Intent; |
||
6 | 6 |
import android.content.ServiceConnection; |
7 | 7 |
import android.os.IBinder; |
8 | 8 |
|
9 |
+import com.android.common.utils.LogHelper; |
|
10 |
+ |
|
9 | 11 |
import java.text.SimpleDateFormat; |
10 | 12 |
import java.util.ArrayList; |
11 | 13 |
import java.util.Date; |
@@ -108,7 +110,8 @@ public class UploadPresenter implements UploadContract.Presenter,BaseInteractor. |
||
108 | 110 |
|
109 | 111 |
@Override |
110 | 112 |
public synchronized void onPhotoUploaded(PhotoBean bean) { |
111 |
- int position = sessionList.size()-bean.sessionSeq-1; |
|
113 |
+ int position = sessionList.size()-bean.sessionSeq; |
|
114 |
+ LogHelper.d("czy","onPhotoUploaded and notify UI change at "+position); |
|
112 | 115 |
if(position < 0 || position>=sessionList.size()){ |
113 | 116 |
return; |
114 | 117 |
} |
@@ -120,11 +123,38 @@ public class UploadPresenter implements UploadContract.Presenter,BaseInteractor. |
||
120 | 123 |
}else{ |
121 | 124 |
for(PhotoBean photoBean : photoList){ |
122 | 125 |
if(photoBean.photoId == bean.photoId){ |
126 |
+ LogHelper.d("czy","onPhotoUploaded and found data change "+position); |
|
123 | 127 |
photoBean.uploadStatus = PhotoBean.UploadStatus.STATUS_SUCCESS; |
124 | 128 |
break; |
125 | 129 |
} |
126 | 130 |
} |
127 | 131 |
} |
132 |
+ sessionBean.sessionPhotos = photoList; |
|
133 |
+ uploadView.updateSessionUploadViewAt(position); |
|
134 |
+ } |
|
135 |
+ |
|
136 |
+ @Override |
|
137 |
+ public synchronized void onPhotoUploadError(PhotoBean bean) { |
|
138 |
+ int position = sessionList.size()-bean.sessionSeq; |
|
139 |
+ LogHelper.d("czy","onPhotoUploadError and notify UI change at "+position); |
|
140 |
+ if(position < 0 || position>=sessionList.size()){ |
|
141 |
+ return; |
|
142 |
+ } |
|
143 |
+ SessionBean sessionBean = sessionList.get(position); |
|
144 |
+ ArrayList<PhotoBean> photoList = sessionBean.sessionPhotos; |
|
145 |
+ if(photoList==null || photoList.size()==0){ |
|
146 |
+ photoList = new ArrayList<>(); |
|
147 |
+ photoList.add(bean); |
|
148 |
+ }else{ |
|
149 |
+ for(PhotoBean photoBean : photoList){ |
|
150 |
+ if(photoBean.photoId == bean.photoId){ |
|
151 |
+ LogHelper.d("czy","onPhotoUploaded and found data change "+position); |
|
152 |
+ photoBean.uploadStatus = PhotoBean.UploadStatus.STATUS_ERROR; |
|
153 |
+ break; |
|
154 |
+ } |
|
155 |
+ } |
|
156 |
+ } |
|
157 |
+ sessionBean.sessionPhotos = photoList; |
|
128 | 158 |
uploadView.updateSessionUploadViewAt(position); |
129 | 159 |
} |
130 | 160 |
} |