@@ -223,14 +223,13 @@ public class DBService { |
||
223 | 223 |
PhotoBean photoBean = null; |
224 | 224 |
SQLiteDatabase db = null; |
225 | 225 |
Cursor c = null; |
226 |
- String currentSession = Preferences.getInstance().getCurrentSession(); |
|
227 | 226 |
synchronized (DB_LOCK) { |
228 | 227 |
try { |
229 | 228 |
db = dbHelper.getReadableDatabase(); |
230 | 229 |
db.beginTransaction(); |
231 | 230 |
c = db.rawQuery("select * from " + DBHelper.PHOTO_INFO_TABLE + " where " |
232 | 231 |
+ DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS + " = '" + 0 + "'" |
233 |
- +" and "+DBHelper.PHOTO_INFO_COLUMNS.SESSION_ID+" <>" +"'"+currentSession |
|
232 |
+ +" and "+DBHelper.PHOTO_INFO_COLUMNS.CAPTURE_TIME+" <" +"'"+(System.currentTimeMillis()-30_1000) |
|
234 | 233 |
+"' order by " |
235 | 234 |
+ DBHelper.PHOTO_INFO_COLUMNS.CAPTURE_TIME + " desc limit 1 ", null); |
236 | 235 |
if (c.moveToNext()) { |
@@ -7,6 +7,7 @@ import android.view.LayoutInflater; |
||
7 | 7 |
import android.view.View; |
8 | 8 |
import android.view.ViewGroup; |
9 | 9 |
import android.widget.ImageView; |
10 |
+import android.widget.TextView; |
|
10 | 11 |
import android.widget.Toast; |
11 | 12 |
|
12 | 13 |
import com.android.common.utils.DeviceUtils; |
@@ -94,6 +95,15 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
94 | 95 |
}else{ |
95 | 96 |
holder.errorLayout.setVisibility(View.GONE); |
96 | 97 |
} |
98 |
+ long timePassed = (System.currentTimeMillis()-item.captureTime)/1000; |
|
99 |
+ |
|
100 |
+ if(timePassed>30){ |
|
101 |
+ holder.autoUploadHintText.setVisibility(View.GONE); |
|
102 |
+ }else{ |
|
103 |
+ holder.autoUploadHintText.setVisibility(View.VISIBLE); |
|
104 |
+ holder.autoUploadHintText.setText(context.getString(R.string.auto_upload_after_seconds,timePassed)); |
|
105 |
+ } |
|
106 |
+ |
|
97 | 107 |
} |
98 | 108 |
|
99 | 109 |
@Override |
@@ -109,7 +119,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
109 | 119 |
@BindView(R.id.iv_session_photo_item) ImageView photo; |
110 | 120 |
@BindView(R.id.layout_upload_fail) View errorLayout; |
111 | 121 |
@BindView(R.id.iv_upload_retry) ImageView retryImg; |
112 |
- |
|
122 |
+ @BindView(R.id.tv_auto_upload_hint) TextView autoUploadHintText; |
|
113 | 123 |
public MyViewHolder(View view){ |
114 | 124 |
super(view); |
115 | 125 |
ButterKnife.bind(this,view); |
@@ -185,6 +185,18 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
185 | 185 |
} |
186 | 186 |
|
187 | 187 |
@Override |
188 |
+ public void refreshUploadTimeHint() { |
|
189 |
+ if(adapter!=null && photosRecyclerView!=null && photosRecyclerView.getVisibility()==View.VISIBLE){ |
|
190 |
+ photosRecyclerView.post(new Runnable() { |
|
191 |
+ @Override |
|
192 |
+ public void run() { |
|
193 |
+ adapter.notifyDataSetChanged(); |
|
194 |
+ } |
|
195 |
+ }); |
|
196 |
+ } |
|
197 |
+ } |
|
198 |
+ |
|
199 |
+ @Override |
|
188 | 200 |
protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
189 | 201 |
super.onActivityResult(requestCode,resultCode,data); |
190 | 202 |
if (resultCode == Activity.RESULT_OK) { |
@@ -16,6 +16,7 @@ public class SessionContract { |
||
16 | 16 |
void showToast(String toast); |
17 | 17 |
void showBoxDisconnectedView(int errorCode,String errorMsg); |
18 | 18 |
void showBoxConnectedView(); |
19 |
+ void refreshUploadTimeHint(); |
|
19 | 20 |
} |
20 | 21 |
|
21 | 22 |
interface Presenter extends BasePresenter{ |
@@ -5,6 +5,8 @@ import android.content.Intent; |
||
5 | 5 |
import com.android.common.utils.LogHelper; |
6 | 6 |
|
7 | 7 |
import java.util.ArrayList; |
8 |
+import java.util.Timer; |
|
9 |
+import java.util.TimerTask; |
|
8 | 10 |
|
9 | 11 |
import ai.pai.lensman.App; |
10 | 12 |
import ai.pai.lensman.BuildConfig; |
@@ -26,6 +28,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
26 | 28 |
private SessionBean sessionBean; |
27 | 29 |
private boolean isWorking; |
28 | 30 |
private String groupId; |
31 |
+ private Timer refreshTimer; |
|
29 | 32 |
|
30 | 33 |
private static final String TAG = "SessionPresenter"; |
31 | 34 |
|
@@ -52,6 +55,13 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
52 | 55 |
} |
53 | 56 |
interactor.startSession(); |
54 | 57 |
boxStatusInteractor.startJob(); |
58 |
+ refreshTimer = new Timer(); |
|
59 |
+ refreshTimer.schedule(new TimerTask() { |
|
60 |
+ @Override |
|
61 |
+ public void run() { |
|
62 |
+ |
|
63 |
+ } |
|
64 |
+ },1000,1000); |
|
55 | 65 |
Preferences.getInstance().setCurrentSession(sessionBean.sessionId); |
56 | 66 |
} |
57 | 67 |
|
@@ -59,6 +69,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
59 | 69 |
public void stop() { |
60 | 70 |
boxStatusInteractor.cancelJob(); |
61 | 71 |
interactor.endSession(); |
72 |
+ refreshTimer.cancel(); |
|
62 | 73 |
Preferences.getInstance().setCurrentSession(""); |
63 | 74 |
isWorking = false; |
64 | 75 |
LogHelper.d(TAG,"stop"); |
@@ -11,6 +11,16 @@ |
||
11 | 11 |
android:background="@color/image_bg_white" |
12 | 12 |
android:scaleType="centerCrop"/> |
13 | 13 |
|
14 |
+ <TextView |
|
15 |
+ android:id="@+id/tv_auto_upload_hint" |
|
16 |
+ android:layout_width="match_parent" |
|
17 |
+ android:layout_height="48dp" |
|
18 |
+ android:gravity="center" |
|
19 |
+ android:text="@string/auto_upload_after_seconds" |
|
20 |
+ android:textColor="@color/white" |
|
21 |
+ android:textSize="16sp" |
|
22 |
+ android:background="@color/half_transparent"/> |
|
23 |
+ |
|
14 | 24 |
<RelativeLayout |
15 | 25 |
android:id="@+id/layout_upload_fail" |
16 | 26 |
android:layout_width="wrap_content" |
@@ -27,4 +27,6 @@ |
||
27 | 27 |
<color name="_EF4847">#EF4847</color> |
28 | 28 |
<color name="_333333">#333333</color> |
29 | 29 |
|
30 |
+ <color name="half_transparent">#A0000000</color> |
|
31 |
+ |
|
30 | 32 |
</resources> |
@@ -159,4 +159,6 @@ |
||
159 | 159 |
<string name="set_price_fail">价格设置失败,请重试</string> |
160 | 160 |
|
161 | 161 |
<string name="box_status_error">盒子状态错误,请检查</string> |
162 |
+ |
|
163 |
+ <string name="auto_upload_after_seconds">距自动上传还有%d秒</string> |
|
162 | 164 |
</resources> |