@@ -25,6 +25,8 @@ public class PhotoBean implements Serializable{
|
||
| 25 | 25 |
|
| 26 | 26 |
public int uploadStatus; |
| 27 | 27 |
|
| 28 |
+ public boolean canDelete; |
|
| 29 |
+ |
|
| 28 | 30 |
public boolean isRawPhoto; |
| 29 | 31 |
|
| 30 | 32 |
@Override |
@@ -21,6 +21,7 @@ public class QueryBoxStatusInteractor implements BaseInteractor{
|
||
| 21 | 21 |
private HttpPostTask queryBoxTask; |
| 22 | 22 |
private BoxStatusListener listener; |
| 23 | 23 |
private Timer queryTimer; |
| 24 |
+ private boolean isCancelled; |
|
| 24 | 25 |
|
| 25 | 26 |
public QueryBoxStatusInteractor(BoxStatusListener listener){
|
| 26 | 27 |
this.listener = listener; |
@@ -67,6 +68,9 @@ public class QueryBoxStatusInteractor implements BaseInteractor{
|
||
| 67 | 68 |
@Override |
| 68 | 69 |
protected void onPostFail() {
|
| 69 | 70 |
super.onPostFail(); |
| 71 |
+ if(isCancelled){
|
|
| 72 |
+ return; |
|
| 73 |
+ } |
|
| 70 | 74 |
if(BuildConfig.isTestMode){
|
| 71 | 75 |
if(listener!=null){
|
| 72 | 76 |
listener.onBoxStatusFetched("123","状态消息",100*new Random().nextInt(3)+new Random().nextInt(3));
|
@@ -78,6 +82,9 @@ public class QueryBoxStatusInteractor implements BaseInteractor{
|
||
| 78 | 82 |
@Override |
| 79 | 83 |
protected void onPostSuccess() {
|
| 80 | 84 |
super.onPostSuccess(); |
| 85 |
+ if(isCancelled){
|
|
| 86 |
+ return; |
|
| 87 |
+ } |
|
| 81 | 88 |
if(listener!=null){
|
| 82 | 89 |
listener.onBoxStatusFetched(boxNo,boxStatusMsg,boxStatusNum); |
| 83 | 90 |
} |
@@ -88,6 +95,7 @@ public class QueryBoxStatusInteractor implements BaseInteractor{
|
||
| 88 | 95 |
|
| 89 | 96 |
@Override |
| 90 | 97 |
public void cancelJob() {
|
| 98 |
+ isCancelled = true; |
|
| 91 | 99 |
if(queryTimer!=null){
|
| 92 | 100 |
queryTimer.cancel(); |
| 93 | 101 |
queryTimer = null; |
@@ -41,7 +41,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
| 41 | 41 |
} |
| 42 | 42 |
|
| 43 | 43 |
public PhotoBean getPhotoAt(int position){
|
| 44 |
- if(photoList==null|| photoList.size()<=position){
|
|
| 44 |
+ if(photoList==null|| photoList.size()<=position ||position<0){
|
|
| 45 | 45 |
return null; |
| 46 | 46 |
} |
| 47 | 47 |
return photoList.get(position); |
@@ -105,12 +105,13 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
| 105 | 105 |
long timeLeft = 30-(System.currentTimeMillis()-item.captureTime)/1000; |
| 106 | 106 |
|
| 107 | 107 |
if(timeLeft<0){
|
| 108 |
+ item.canDelete = false; |
|
| 108 | 109 |
holder.autoUploadHintText.setVisibility(View.GONE); |
| 109 | 110 |
}else{
|
| 111 |
+ item.canDelete = true; |
|
| 110 | 112 |
holder.autoUploadHintText.setVisibility(View.VISIBLE); |
| 111 | 113 |
holder.autoUploadHintText.setText(context.getString(R.string.auto_upload_after_seconds,timeLeft)); |
| 112 | 114 |
} |
| 113 |
- |
|
| 114 | 115 |
} |
| 115 | 116 |
|
| 116 | 117 |
@Override |
@@ -4,7 +4,6 @@ import android.app.Activity; |
||
| 4 | 4 |
import android.content.Intent; |
| 5 | 5 |
import android.graphics.Canvas; |
| 6 | 6 |
import android.os.Bundle; |
| 7 |
-import android.provider.Settings; |
|
| 8 | 7 |
import android.support.v7.widget.LinearLayoutManager; |
| 9 | 8 |
import android.support.v7.widget.RecyclerView; |
| 10 | 9 |
import android.support.v7.widget.helper.ItemTouchHelper; |
@@ -31,7 +30,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 31 | 30 |
@BindView(R.id.icon_no_data) View noPhotoLayout; |
| 32 | 31 |
@BindView(R.id.title_bar_middle_txt) TextView titleTextView; |
| 33 | 32 |
@BindView(R.id.recycler_view_photos) RecyclerView photosRecyclerView; |
| 34 |
- @BindView(R.id.iv_scan) ImageView qrcodeScanBtn; |
|
| 33 |
+ @BindView(R.id.iv_scan) ImageView qrcodeScanBtn; |
|
| 35 | 34 |
@BindView(R.id.layout_device_status) View deviceConnectLayout; |
| 36 | 35 |
@BindView(R.id.iv_box) ImageView boxIndicator; |
| 37 | 36 |
@BindView(R.id.iv_box_phone_line) ImageView boxPhoneLineIndicator; |
@@ -42,8 +41,6 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 42 | 41 |
private SessionBean sessionBean; |
| 43 | 42 |
private SessionContract.Presenter presenter; |
| 44 | 43 |
|
| 45 |
- private boolean canDelete; |
|
| 46 |
- |
|
| 47 | 44 |
private static final int JOIN_REQUEST_CODE = 3002; |
| 48 | 45 |
|
| 49 | 46 |
private ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, |
@@ -52,17 +49,21 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 52 | 49 |
@Override |
| 53 | 50 |
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
| 54 | 51 |
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); |
| 55 |
- if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE && canDelete) {
|
|
| 56 |
- final float alpha = 1 - Math.abs(dX) / (float)viewHolder.itemView.getWidth(); |
|
| 57 |
- viewHolder.itemView.setAlpha(alpha); |
|
| 58 |
- viewHolder.itemView.setTranslationX(dX); |
|
| 59 |
- viewHolder.itemView.setScaleX(alpha); |
|
| 60 |
- viewHolder.itemView.setScaleY(alpha); |
|
| 61 |
- }else{
|
|
| 52 |
+ int position = viewHolder.getAdapterPosition(); |
|
| 53 |
+ PhotoBean photoBean = adapter.getPhotoAt(position); |
|
| 54 |
+ if(photoBean==null||!photoBean.canDelete){
|
|
| 62 | 55 |
viewHolder.itemView.setAlpha(1); |
| 63 | 56 |
viewHolder.itemView.setTranslationX(0); |
| 64 | 57 |
viewHolder.itemView.setScaleX(1); |
| 65 | 58 |
viewHolder.itemView.setScaleY(1); |
| 59 |
+ return; |
|
| 60 |
+ } |
|
| 61 |
+ if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE &&photoBean.canDelete) {
|
|
| 62 |
+ final float alpha = 1 - Math.abs(dX) / (float) viewHolder.itemView.getWidth(); |
|
| 63 |
+ viewHolder.itemView.setAlpha(alpha); |
|
| 64 |
+ viewHolder.itemView.setTranslationX(dX); |
|
| 65 |
+ viewHolder.itemView.setScaleX(alpha); |
|
| 66 |
+ viewHolder.itemView.setScaleY(alpha); |
|
| 66 | 67 |
} |
| 67 | 68 |
} |
| 68 | 69 |
|
@@ -76,14 +77,11 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 76 | 77 |
int position = viewHolder.getAdapterPosition(); |
| 77 | 78 |
PhotoBean photoBean = adapter.getPhotoAt(position); |
| 78 | 79 |
if(photoBean==null){
|
| 79 |
- canDelete = false; |
|
| 80 |
+ return; |
|
| 80 | 81 |
} |
| 81 |
- if(System.currentTimeMillis()-photoBean.captureTime<30_000){
|
|
| 82 |
- canDelete = true; |
|
| 82 |
+ if(photoBean.canDelete){
|
|
| 83 | 83 |
presenter.swipeToDeletePhoto(position); |
| 84 | 84 |
adapter.removePhotoAtIndex(position); |
| 85 |
- }else{
|
|
| 86 |
- canDelete = false; |
|
| 87 | 85 |
} |
| 88 | 86 |
} |
| 89 | 87 |
}; |
@@ -98,7 +98,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 98 | 98 |
return; |
| 99 | 99 |
} |
| 100 | 100 |
if(BuildConfig.isTestMode){
|
| 101 |
- if(photoList!=null && photoList.size()>20){
|
|
| 101 |
+ if(photoList!=null && photoList.size()>10){
|
|
| 102 | 102 |
interactor.endSession(); |
| 103 | 103 |
return; |
| 104 | 104 |
} |