@@ -250,4 +250,34 @@ public class DBService {
|
||
| 250 | 250 |
return photoBean; |
| 251 | 251 |
} |
| 252 | 252 |
|
| 253 |
+ public boolean isPhotoUploaded(long photoId){
|
|
| 254 |
+ SQLiteDatabase db = null; |
|
| 255 |
+ Cursor c = null; |
|
| 256 |
+ PhotoBean photoBean = null; |
|
| 257 |
+ |
|
| 258 |
+ synchronized (DB_LOCK) {
|
|
| 259 |
+ try {
|
|
| 260 |
+ db = dbHelper.getReadableDatabase(); |
|
| 261 |
+ db.beginTransaction(); |
|
| 262 |
+ c = db.rawQuery("select * from " + DBHelper.PHOTO_INFO_TABLE + " where "
|
|
| 263 |
+ + DBHelper.PHOTO_INFO_COLUMNS.PHOTO_ID + " = '" + photoId + "'", null); |
|
| 264 |
+ if (c.moveToNext()) {
|
|
| 265 |
+ photoBean = cursor2PhotoBean(c); |
|
| 266 |
+ } |
|
| 267 |
+ db.setTransactionSuccessful(); |
|
| 268 |
+ } catch (Exception e) {
|
|
| 269 |
+ LogHelper.d(TAG, "dbservice getGroupInfoByGroupId error happen " + e); |
|
| 270 |
+ } finally {
|
|
| 271 |
+ try {
|
|
| 272 |
+ db.endTransaction(); |
|
| 273 |
+ } catch (Exception e) {
|
|
| 274 |
+ e.printStackTrace(); |
|
| 275 |
+ } |
|
| 276 |
+ closeCursorAndDB(c, db); |
|
| 277 |
+ } |
|
| 278 |
+ } |
|
| 279 |
+ |
|
| 280 |
+ return (photoBean!=null && photoBean.uploadStatus==PhotoBean.UploadStatus.STATUS_SUCCESS); |
|
| 281 |
+ } |
|
| 282 |
+ |
|
| 253 | 283 |
} |
@@ -19,6 +19,7 @@ import java.util.ArrayList; |
||
| 19 | 19 |
import ai.pai.lensman.App; |
| 20 | 20 |
import ai.pai.lensman.R; |
| 21 | 21 |
import ai.pai.lensman.bean.PhotoBean; |
| 22 |
+import ai.pai.lensman.db.DBService; |
|
| 22 | 23 |
import ai.pai.lensman.service.UploadService; |
| 23 | 24 |
import ai.pai.lensman.utils.Constants; |
| 24 | 25 |
import ai.pai.lensman.utils.ImageLoaderUtils; |
@@ -104,7 +105,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap |
||
| 104 | 105 |
} |
| 105 | 106 |
long timeLeft = 30-(System.currentTimeMillis()-item.captureTime)/1000; |
| 106 | 107 |
|
| 107 |
- if(timeLeft<0){
|
|
| 108 |
+ if(timeLeft<0|| DBService.getInstance().isPhotoUploaded(item.photoId)){
|
|
| 108 | 109 |
item.canDelete = false; |
| 109 | 110 |
holder.autoUploadHintText.setVisibility(View.GONE); |
| 110 | 111 |
}else{
|
@@ -40,31 +40,13 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 40 | 40 |
private PhotoRecyclerAdapter adapter; |
| 41 | 41 |
private SessionBean sessionBean; |
| 42 | 42 |
private SessionContract.Presenter presenter; |
| 43 |
- private int swipingPosition = -1; |
|
| 44 | 43 |
private static final int JOIN_REQUEST_CODE = 3002; |
| 45 | 44 |
|
| 46 |
- private ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, |
|
| 47 |
- ItemTouchHelper.LEFT|ItemTouchHelper.RIGHT) {
|
|
| 45 |
+ private ItemTouchHelper.Callback mCallback = new ItemTouchHelper.SimpleCallback(ItemTouchHelper.UP | ItemTouchHelper.DOWN, ItemTouchHelper.RIGHT|ItemTouchHelper.LEFT) {
|
|
| 48 | 46 |
|
| 49 | 47 |
@Override |
| 50 | 48 |
public void onChildDraw(Canvas c, RecyclerView recyclerView, RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
| 51 | 49 |
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive); |
| 52 |
- int position = viewHolder.getAdapterPosition(); |
|
| 53 |
- PhotoBean photoBean = adapter.getPhotoAt(position); |
|
| 54 |
- if(photoBean==null||swipingPosition!=position){
|
|
| 55 |
- viewHolder.itemView.setAlpha(1); |
|
| 56 |
- viewHolder.itemView.setTranslationX(0); |
|
| 57 |
- viewHolder.itemView.setScaleX(1); |
|
| 58 |
- viewHolder.itemView.setScaleY(1); |
|
| 59 |
- return; |
|
| 60 |
- } |
|
| 61 |
- if(actionState == ItemTouchHelper.ACTION_STATE_SWIPE &&photoBean.canDelete && swipingPosition==position) {
|
|
| 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); |
|
| 67 |
- } |
|
| 68 | 50 |
} |
| 69 | 51 |
|
| 70 | 52 |
@Override |
@@ -80,9 +62,10 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 80 | 62 |
return; |
| 81 | 63 |
} |
| 82 | 64 |
if(photoBean.canDelete){
|
| 83 |
- swipingPosition = position; |
|
| 84 | 65 |
presenter.swipeToDeletePhoto(position); |
| 85 | 66 |
adapter.removePhotoAtIndex(position); |
| 67 |
+ }else{
|
|
| 68 |
+ showToast(getString(R.string.can_not_delete)); |
|
| 86 | 69 |
} |
| 87 | 70 |
} |
| 88 | 71 |
}; |
@@ -161,4 +161,6 @@ |
||
| 161 | 161 |
<string name="box_status_error">盒子状态错误,请检查</string> |
| 162 | 162 |
|
| 163 | 163 |
<string name="auto_upload_after_seconds">距自动上传还有%d秒</string> |
| 164 |
+ |
|
| 165 |
+ <string name="can_not_delete">该照片已在上传队列,无法删除</string> |
|
| 164 | 166 |
</resources> |