@@ -48,7 +48,7 @@ android { |
||
48 | 48 |
zipAlignEnabled false |
49 | 49 |
minifyEnabled false |
50 | 50 |
shrinkResources false |
51 |
- buildConfigField "boolean", "isTestMode", "false" |
|
51 |
+ buildConfigField "boolean", "isTestMode", "true" |
|
52 | 52 |
signingConfig signingConfigs.releaseConfig |
53 | 53 |
} |
54 | 54 |
} |
@@ -17,6 +17,7 @@ import java.util.ArrayList; |
||
17 | 17 |
import java.util.Date; |
18 | 18 |
|
19 | 19 |
import ai.pai.lensman.App; |
20 |
+import ai.pai.lensman.BuildConfig; |
|
20 | 21 |
import ai.pai.lensman.R; |
21 | 22 |
import ai.pai.lensman.base.BaseInteractor; |
22 | 23 |
import ai.pai.lensman.bean.PhotoBean; |
@@ -102,6 +103,12 @@ class MainPresenter implements MainContract.Presenter,BaseInteractor.InteractorL |
||
102 | 103 |
if(sessionIds==null|| sessionIds.size()<20){ |
103 | 104 |
interactor.startJob(); |
104 | 105 |
} |
106 |
+ if(BuildConfig.isTestMode){ |
|
107 |
+ if(sessionIds==null || sessionIds.size()==0){ |
|
108 |
+ sessionIds = new ArrayList<>(); |
|
109 |
+ sessionIds.add(String.valueOf(System.currentTimeMillis())); |
|
110 |
+ } |
|
111 |
+ } |
|
105 | 112 |
if(sessionIds==null || sessionIds.size()<1){ |
106 | 113 |
view.setNewSessionBtnEnabled(false); |
107 | 114 |
view.showSnackBar(R.string.prepare_in_processing); |
@@ -40,6 +40,13 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
40 | 40 |
options = ImageLoaderUtils.getOptions(R.drawable.default_img); |
41 | 41 |
} |
42 | 42 |
|
43 |
+ public PhotoBean getPhotoAt(int position){ |
|
44 |
+ if(photoList==null|| photoList.size()<=position){ |
|
45 |
+ return null; |
|
46 |
+ } |
|
47 |
+ return photoList.get(position); |
|
48 |
+ } |
|
49 |
+ |
|
43 | 50 |
public synchronized void addPhotoBean(PhotoBean item){ |
44 | 51 |
if(photoList==null){ |
45 | 52 |
photoList = new ArrayList<>(); |
@@ -95,13 +102,13 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
95 | 102 |
}else{ |
96 | 103 |
holder.errorLayout.setVisibility(View.GONE); |
97 | 104 |
} |
98 |
- long timePassed = (System.currentTimeMillis()-item.captureTime)/1000; |
|
105 |
+ long timeLeft = 30-(System.currentTimeMillis()-item.captureTime)/1000; |
|
99 | 106 |
|
100 |
- if(timePassed>30){ |
|
107 |
+ if(timeLeft<0){ |
|
101 | 108 |
holder.autoUploadHintText.setVisibility(View.GONE); |
102 | 109 |
}else{ |
103 | 110 |
holder.autoUploadHintText.setVisibility(View.VISIBLE); |
104 |
- holder.autoUploadHintText.setText(context.getString(R.string.auto_upload_after_seconds,timePassed)); |
|
111 |
+ holder.autoUploadHintText.setText(context.getString(R.string.auto_upload_after_seconds,timeLeft)); |
|
105 | 112 |
} |
106 | 113 |
|
107 | 114 |
} |
@@ -4,6 +4,7 @@ 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; |
|
7 | 8 |
import android.support.v7.widget.LinearLayoutManager; |
8 | 9 |
import android.support.v7.widget.RecyclerView; |
9 | 10 |
import android.support.v7.widget.helper.ItemTouchHelper; |
@@ -41,6 +42,8 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
41 | 42 |
private SessionBean sessionBean; |
42 | 43 |
private SessionContract.Presenter presenter; |
43 | 44 |
|
45 |
+ private boolean canDelete; |
|
46 |
+ |
|
44 | 47 |
private static final int JOIN_REQUEST_CODE = 3002; |
45 | 48 |
|
46 | 49 |
private ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, |
@@ -49,12 +52,17 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
49 | 52 |
@Override |
50 | 53 |
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) { |
51 | 54 |
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); |
52 |
- if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE) { |
|
55 |
+ if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE && canDelete) { |
|
53 | 56 |
final float alpha = 1 - Math.abs(dX) / (float)viewHolder.itemView.getWidth(); |
54 | 57 |
viewHolder.itemView.setAlpha(alpha); |
55 | 58 |
viewHolder.itemView.setTranslationX(dX); |
56 | 59 |
viewHolder.itemView.setScaleX(alpha); |
57 | 60 |
viewHolder.itemView.setScaleY(alpha); |
61 |
+ }else{ |
|
62 |
+ viewHolder.itemView.setAlpha(1); |
|
63 |
+ viewHolder.itemView.setTranslationX(0); |
|
64 |
+ viewHolder.itemView.setScaleX(1); |
|
65 |
+ viewHolder.itemView.setScaleY(1); |
|
58 | 66 |
} |
59 | 67 |
} |
60 | 68 |
|
@@ -66,8 +74,17 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
66 | 74 |
@Override |
67 | 75 |
public void onSwiped(RecyclerView.ViewHolder viewHolder, int direction) { |
68 | 76 |
int position = viewHolder.getAdapterPosition(); |
69 |
- presenter.swipeToDeletePhoto(position); |
|
70 |
- adapter.removePhotoAtIndex(position); |
|
77 |
+ PhotoBean photoBean = adapter.getPhotoAt(position); |
|
78 |
+ if(photoBean==null){ |
|
79 |
+ canDelete = false; |
|
80 |
+ } |
|
81 |
+ if(System.currentTimeMillis()-photoBean.captureTime<30_000){ |
|
82 |
+ canDelete = true; |
|
83 |
+ presenter.swipeToDeletePhoto(position); |
|
84 |
+ adapter.removePhotoAtIndex(position); |
|
85 |
+ }else{ |
|
86 |
+ canDelete = false; |
|
87 |
+ } |
|
71 | 88 |
} |
72 | 89 |
}; |
73 | 90 |
|
@@ -59,7 +59,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
59 | 59 |
refreshTimer.schedule(new TimerTask() { |
60 | 60 |
@Override |
61 | 61 |
public void run() { |
62 |
- |
|
62 |
+ sessionView.refreshUploadTimeHint(); |
|
63 | 63 |
} |
64 | 64 |
},1000,1000); |
65 | 65 |
Preferences.getInstance().setCurrentSession(sessionBean.sessionId); |