- super.onPostSuccess();
- if(isCancelled){
- return;
- }
- if(listener!=null){
- listener.onBoxStatusFetched(boxNo,boxStatusMsg,boxStatusNum);
- }
- }
- };
- queryBoxTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.BOX_INFO_URL);
- }
-
- @Override
- public void cancelJob() {
- if(queryTimer!=null){
- queryTimer.cancel();
- queryTimer = null;
- }
- if(queryBoxTask==null){
- return;
- }
- if(queryBoxTask.getStatus()== AsyncTask.Status.RUNNING){
- queryBoxTask.cancel(true);
- }
- isCancelled = true;
- queryBoxTask = null;
- }
-
- public interface BoxStatusListener{
-
- void onBoxStatusFetched(String boxNo, String boxStatus, int boxStatusCode);
- }
-}
@@ -14,15 +14,12 @@ import ai.pai.lensman.bean.PhotoBean; |
||
| 14 | 14 |
import ai.pai.lensman.bean.SessionBean; |
| 15 | 15 |
import ai.pai.lensman.db.DBService; |
| 16 | 16 |
import ai.pai.lensman.db.Preferences; |
| 17 |
-import ai.pai.lensman.main.QueryBoxStatusInteractor; |
|
| 18 | 17 |
import ai.pai.lensman.service.UploadService; |
| 19 | 18 |
|
| 20 | 19 |
|
| 21 |
-public class SessionPresenter implements SessionContract.Presenter, SessionInteractor.SessionListener, |
|
| 22 |
- QueryBoxStatusInteractor.BoxStatusListener {
|
|
| 20 |
+public class SessionPresenter implements SessionContract.Presenter, SessionInteractor.SessionListener{
|
|
| 23 | 21 |
|
| 24 | 22 |
private SessionInteractor interactor; |
| 25 |
- private QueryBoxStatusInteractor boxStatusInteractor; |
|
| 26 | 23 |
private ArrayList<PhotoBean> photoList; |
| 27 | 24 |
private SessionContract.View sessionView; |
| 28 | 25 |
private SessionBean sessionBean; |
@@ -42,7 +39,6 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 42 | 39 |
isWorking = true; |
| 43 | 40 |
LogHelper.d(TAG,"SessionPresenter start "+sessionBean); |
| 44 | 41 |
interactor = new SessionInteractor(sessionBean, this); |
| 45 |
- boxStatusInteractor = new QueryBoxStatusInteractor(this); |
|
| 46 | 42 |
photoList = DBService.getInstance().getPhotoListBySessionId(sessionBean.sessionId); |
| 47 | 43 |
if (photoList.size() == 0) {
|
| 48 | 44 |
LogHelper.d(TAG,"SessionPresenter start and found no old photos"); |
@@ -55,7 +51,6 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 55 | 51 |
} |
| 56 | 52 |
} |
| 57 | 53 |
interactor.startSession(); |
| 58 |
- boxStatusInteractor.startJob(); |
|
| 59 | 54 |
refreshTimer = new Timer(); |
| 60 | 55 |
refreshTimer.schedule(new TimerTask() {
|
| 61 | 56 |
@Override |
@@ -68,7 +63,6 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 68 | 63 |
|
| 69 | 64 |
@Override |
| 70 | 65 |
public void stop() {
|
| 71 |
- boxStatusInteractor.cancelJob(); |
|
| 72 | 66 |
interactor.endSession(); |
| 73 | 67 |
refreshTimer.cancel(); |
| 74 | 68 |
Preferences.getInstance().setCurrentSession("");
|
@@ -141,14 +135,4 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
| 141 | 135 |
this.groupId = groupId; |
| 142 | 136 |
} |
| 143 | 137 |
|
| 144 |
- @Override |
|
| 145 |
- public void onBoxStatusFetched(String boxNo, String boxStatus, int boxStatusCode) {
|
|
| 146 |
- LogHelper.d(TAG,"onBoxStatusFetched 盒子当前状态 "+boxStatus+" code = "+boxStatusCode); |
|
| 147 |
- if(boxStatusCode == 200){
|
|
| 148 |
- sessionView.showBoxConnectedView(); |
|
| 149 |
- }else{
|
|
| 150 |
- sessionView.showBoxDisconnectedView(boxStatusCode,boxStatus); |
|
| 151 |
- } |
|
| 152 |
- } |
|
| 153 |
- |
|
| 154 | 138 |
} |
@@ -23,6 +23,4 @@ public class BoxUrlContainer {
|
||
| 23 | 23 |
*/ |
| 24 | 24 |
public static String FETCH_ORIGIN_URL = BASE_URL +"fetch_origin"; |
| 25 | 25 |
|
| 26 |
- public static String BOX_INFO_URL = BASE_URL+"box_info"; |
|
| 27 |
- |
|
| 28 | 26 |
} |