@@ -218,12 +218,15 @@ public class DBService {
               | 
            ||
| 218 | 218 | 
                PhotoBean photoBean = null;  | 
            
| 219 | 219 | 
                SQLiteDatabase db = null;  | 
            
| 220 | 220 | 
                Cursor c = null;  | 
            
| 221 | 
                + String currentSession = Preferences.getInstance().getCurrentSession();  | 
            |
| 221 | 222 | 
                         synchronized (DB_LOCK) {
               | 
            
| 222 | 223 | 
                             try {
               | 
            
| 223 | 224 | 
                db = dbHelper.getReadableDatabase();  | 
            
| 224 | 225 | 
                db.beginTransaction();  | 
            
| 225 | 226 | 
                                 c = db.rawQuery("select * from " + DBHelper.PHOTO_INFO_TABLE +  " where "
               | 
            
| 226 | 
                - + DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS + " = '" + 0 + "'"+" order by "  | 
            |
| 227 | 
                + + DBHelper.PHOTO_INFO_COLUMNS.UPLOADED_STATUS + " = '" + 0 + "'"  | 
            |
| 228 | 
                + +" and "+DBHelper.PHOTO_INFO_COLUMNS.SESSION_ID+" <>" +"'"+currentSession  | 
            |
| 229 | 
                + +"' order by "  | 
            |
| 227 | 230 | 
                + DBHelper.PHOTO_INFO_COLUMNS.CAPTURE_TIME + " desc limit 1 ", null);  | 
            
| 228 | 231 | 
                                 if (c.moveToNext()) {
               | 
            
| 229 | 232 | 
                photoBean = cursor2PhotoBean(c);  | 
            
                @@ -64,6 +64,14 @@ public class Preferences {
               | 
            ||
| 64 | 64 | 
                         return mPrefs.getString("mac",NullStr);
               | 
            
| 65 | 65 | 
                }  | 
            
| 66 | 66 | 
                 | 
            
| 67 | 
                +    public String getCurrentSession(){
               | 
            |
| 68 | 
                +        return mPrefs.getString("currentSession", NullStr);
               | 
            |
| 69 | 
                + }  | 
            |
| 70 | 
                +  | 
            |
| 71 | 
                +    public void setCurrentSession(String currentSession){
               | 
            |
| 72 | 
                +        mPrefs.edit().putString("currentSession",currentSession).commit();
               | 
            |
| 73 | 
                + }  | 
            |
| 74 | 
                +  | 
            |
| 67 | 75 | 
                     public void clearPrefs(){
               | 
            
| 68 | 76 | 
                mPrefs.edit().clear().commit();  | 
            
| 69 | 77 | 
                }  | 
            
                @@ -106,11 +106,13 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie  | 
            ||
| 106 | 106 | 
                 | 
            
| 107 | 107 | 
                @OnClick(R.id.title_bar_back_layout)  | 
            
| 108 | 108 | 
                     void backToMain(){
               | 
            
| 109 | 
                + presenter.stop();  | 
            |
| 109 | 110 | 
                finish();  | 
            
| 110 | 111 | 
                }  | 
            
| 111 | 112 | 
                 | 
            
| 112 | 113 | 
                @OnClick(R.id.btn_session_complete)  | 
            
| 113 | 114 | 
                     void onSessionComplete(){
               | 
            
| 115 | 
                + presenter.stop();  | 
            |
| 114 | 116 | 
                finish();  | 
            
| 115 | 117 | 
                }  | 
            
| 116 | 118 | 
                 | 
            
                @@ -158,4 +160,10 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie  | 
            ||
| 158 | 160 | 
                startActivity(new Intent(this, PrinterSettingActivity.class));  | 
            
| 159 | 161 | 
                }  | 
            
| 160 | 162 | 
                }  | 
            
| 163 | 
                +  | 
            |
| 164 | 
                + @Override  | 
            |
| 165 | 
                +    public void onBackPressed() {
               | 
            |
| 166 | 
                + presenter.stop();  | 
            |
| 167 | 
                + super.onBackPressed();  | 
            |
| 168 | 
                + }  | 
            |
| 161 | 169 | 
                }  | 
            
                @@ -9,6 +9,7 @@ import ai.pai.lensman.BuildConfig;  | 
            ||
| 9 | 9 | 
                import ai.pai.lensman.bean.PhotoBean;  | 
            
| 10 | 10 | 
                import ai.pai.lensman.bean.SessionBean;  | 
            
| 11 | 11 | 
                import ai.pai.lensman.db.DBService;  | 
            
| 12 | 
                +import ai.pai.lensman.db.Preferences;  | 
            |
| 12 | 13 | 
                import ai.pai.lensman.service.UploadService;  | 
            
| 13 | 14 | 
                 | 
            
| 14 | 15 | 
                 | 
            
                @@ -40,11 +41,13 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter  | 
            ||
| 40 | 41 | 
                }  | 
            
| 41 | 42 | 
                }  | 
            
| 42 | 43 | 
                interactor.startSession();  | 
            
| 44 | 
                + Preferences.getInstance().setCurrentSession(sessionBean.sessionId);  | 
            |
| 43 | 45 | 
                }  | 
            
| 44 | 46 | 
                 | 
            
| 45 | 47 | 
                @Override  | 
            
| 46 | 48 | 
                     public void stop() {
               | 
            
| 47 | 49 | 
                interactor.endSession();  | 
            
| 50 | 
                +        Preferences.getInstance().setCurrentSession("");
               | 
            |
| 48 | 51 | 
                isWorking = false;  | 
            
| 49 | 52 | 
                }  | 
            
| 50 | 53 | 
                 |