@@ -158,6 +158,11 @@ class MainPresenter implements MainContract.Presenter,SyncTimeInteractor.SyncTim |
||
| 158 | 158 |
|
| 159 | 159 |
|
| 160 | 160 |
@Override |
| 161 |
+ public void onPhotoUploadStart(PhotoBean bean) {
|
|
| 162 |
+ |
|
| 163 |
+ } |
|
| 164 |
+ |
|
| 165 |
+ @Override |
|
| 161 | 166 |
public synchronized void onPhotoUploaded(PhotoBean bean) {
|
| 162 | 167 |
int position = sessionList.size()-bean.sessionSeq; |
| 163 | 168 |
if(position < 0 || position>=sessionList.size()){
|
@@ -69,6 +69,9 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
| 69 | 69 |
currentPhoto.uploadStatus = PhotoBean.UploadStatus.STATUS_UPLOADING; |
| 70 | 70 |
DBService.getInstance().updatePhotoBean(currentPhoto); |
| 71 | 71 |
new UploadTask(currentPhoto, this).executeOnExecutor(ThreadExecutor.getInstance().getExecutor()); |
| 72 |
+ if (listener != null) {
|
|
| 73 |
+ listener.onPhotoUploadStart(currentPhoto); |
|
| 74 |
+ } |
|
| 72 | 75 |
} |
| 73 | 76 |
|
| 74 | 77 |
@Override |
@@ -111,6 +114,8 @@ public class UploadService extends Service implements UploadTask.OnPhotoUploadLi |
||
| 111 | 114 |
} |
| 112 | 115 |
|
| 113 | 116 |
public interface PhotoUploadListener {
|
| 117 |
+ void onPhotoUploadStart(PhotoBean bean); |
|
| 118 |
+ |
|
| 114 | 119 |
void onPhotoUploaded(PhotoBean bean); |
| 115 | 120 |
|
| 116 | 121 |
void onPhotoUploadError(PhotoBean bean); |
@@ -98,28 +98,23 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
| 98 | 98 |
lp.width = width; |
| 99 | 99 |
lp.height = height; |
| 100 | 100 |
holder.photo.setLayoutParams(lp); |
| 101 |
- if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR) {
|
|
| 102 |
- holder.errorLayout.setVisibility(View.VISIBLE); |
|
| 103 |
- holder.retryImg.setOnClickListener(new View.OnClickListener() {
|
|
| 104 |
- @Override |
|
| 105 |
- public void onClick(View view) {
|
|
| 106 |
- Intent intent = new Intent(App.getAppContext(), UploadService.class); |
|
| 107 |
- intent.putExtra("photo", item);
|
|
| 108 |
- App.getAppContext().startService(intent); |
|
| 109 |
- item.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN; |
|
| 110 |
- notifyItemChanged(position); |
|
| 111 |
- Toast.makeText(context, R.string.add_to_upload_queue, Toast.LENGTH_SHORT).show(); |
|
| 112 |
- } |
|
| 113 |
- }); |
|
| 114 |
- } else {
|
|
| 115 |
- holder.errorLayout.setVisibility(View.GONE); |
|
| 116 |
- } |
|
| 117 | 101 |
long timeLeft = delay - (System.currentTimeMillis() - item.captureTime) / 1000; |
| 118 | 102 |
|
| 119 | 103 |
if (timeLeft < 0) {
|
| 120 | 104 |
item.canDelete = false; |
| 121 | 105 |
if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR) {
|
| 122 |
- holder.uploadStatusText.setText(context.getString(R.string.upload_error)); |
|
| 106 |
+ holder.uploadStatusText.setText(context.getString(R.string.upload_error) + "," + context.getString(R.string.click_to_retry)); |
|
| 107 |
+ holder.itemView.setOnClickListener(new View.OnClickListener() {
|
|
| 108 |
+ @Override |
|
| 109 |
+ public void onClick(View view) {
|
|
| 110 |
+ Intent intent = new Intent(App.getAppContext(), UploadService.class); |
|
| 111 |
+ intent.putExtra("photo", item);
|
|
| 112 |
+ App.getAppContext().startService(intent); |
|
| 113 |
+ item.uploadStatus = PhotoBean.UploadStatus.STATUS_NO_BEGIN; |
|
| 114 |
+ notifyItemChanged(position); |
|
| 115 |
+ Toast.makeText(context, R.string.add_to_upload_queue, Toast.LENGTH_SHORT).show(); |
|
| 116 |
+ } |
|
| 117 |
+ }); |
|
| 123 | 118 |
} else if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_SUCCESS) {
|
| 124 | 119 |
holder.uploadStatusText.setText(context.getString(R.string.upload_success)); |
| 125 | 120 |
} else if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_NO_BEGIN) {
|
@@ -145,10 +140,6 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
| 145 | 140 |
|
| 146 | 141 |
@BindView(R.id.iv_session_photo_item) |
| 147 | 142 |
ImageView photo; |
| 148 |
- @BindView(R.id.layout_upload_fail) |
|
| 149 |
- View errorLayout; |
|
| 150 |
- @BindView(R.id.iv_upload_retry) |
|
| 151 |
- ImageView retryImg; |
|
| 152 | 143 |
@BindView(R.id.tv_upload_status) |
| 153 | 144 |
TextView uploadStatusText; |
| 154 | 145 |
|
@@ -159,6 +159,17 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 159 | 159 |
} |
| 160 | 160 |
|
| 161 | 161 |
@Override |
| 162 |
+ public void onPhotoUploadStart(PhotoBean bean) {
|
|
| 163 |
+ for(PhotoBean photoBean : photoList){
|
|
| 164 |
+ if(photoBean.photoId == bean.photoId){
|
|
| 165 |
+ photoBean.uploadStatus = PhotoBean.UploadStatus.STATUS_UPLOADING; |
|
| 166 |
+ sessionView.refreshRecyclerView(); |
|
| 167 |
+ break; |
|
| 168 |
+ } |
|
| 169 |
+ } |
|
| 170 |
+ } |
|
| 171 |
+ |
|
| 172 |
+ @Override |
|
| 162 | 173 |
public void onPhotoUploaded(PhotoBean bean) {
|
| 163 | 174 |
for(PhotoBean photoBean : photoList){
|
| 164 | 175 |
if(photoBean.photoId == bean.photoId){
|
@@ -18,37 +18,8 @@ |
||
| 18 | 18 |
android:gravity="center" |
| 19 | 19 |
android:text="@string/auto_upload_after_seconds" |
| 20 | 20 |
android:textColor="@color/white" |
| 21 |
+ android:layout_alignParentBottom="true" |
|
| 21 | 22 |
android:textSize="16sp" |
| 22 | 23 |
android:background="@color/half_transparent"/> |
| 23 | 24 |
|
| 24 |
- <RelativeLayout |
|
| 25 |
- android:id="@+id/layout_upload_fail" |
|
| 26 |
- android:layout_width="wrap_content" |
|
| 27 |
- android:layout_height="wrap_content" |
|
| 28 |
- android:layout_alignBottom="@+id/iv_session_photo_item" |
|
| 29 |
- android:layout_alignLeft="@+id/iv_session_photo_item" |
|
| 30 |
- android:layout_alignTop="@+id/iv_session_photo_item" |
|
| 31 |
- android:layout_alignRight="@+id/iv_session_photo_item" |
|
| 32 |
- android:background="@color/black" |
|
| 33 |
- android:alpha="0.6" |
|
| 34 |
- android:visibility="gone"> |
|
| 35 |
- |
|
| 36 |
- <ImageView |
|
| 37 |
- android:id="@+id/iv_upload_retry" |
|
| 38 |
- android:layout_width="40dp" |
|
| 39 |
- android:layout_height="40dp" |
|
| 40 |
- android:padding="10dp" |
|
| 41 |
- android:layout_centerInParent="true" |
|
| 42 |
- android:src="@drawable/retry"/> |
|
| 43 |
- <TextView |
|
| 44 |
- android:id="@+id/tv_upload_fail" |
|
| 45 |
- android:layout_width="wrap_content" |
|
| 46 |
- android:layout_height="wrap_content" |
|
| 47 |
- android:layout_below="@id/iv_upload_retry" |
|
| 48 |
- android:layout_centerHorizontal="true" |
|
| 49 |
- android:text="@string/click_to_retry" |
|
| 50 |
- android:textSize="16sp" |
|
| 51 |
- android:textColor="@color/white"/> |
|
| 52 |
- |
|
| 53 |
- </RelativeLayout> |
|
| 54 | 25 |
</RelativeLayout> |