@@ -9,7 +9,8 @@ public class SessionBean implements Serializable{ |
||
9 | 9 |
|
10 | 10 |
public int sessionSeq; |
11 | 11 |
public long sessionDate; |
12 |
- public String sessionId ="chengzhenyu_test"; |
|
12 |
+ public String lensmanId; |
|
13 |
+ public String sessionId; |
|
13 | 14 |
public ArrayList<PhotoBean> sessionPhotos; |
14 | 15 |
|
15 | 16 |
} |
@@ -13,7 +13,6 @@ import ai.pai.lensman.R; |
||
13 | 13 |
import ai.pai.lensman.base.BaseActivity; |
14 | 14 |
import ai.pai.lensman.bean.PhotoBean; |
15 | 15 |
import ai.pai.lensman.bean.SessionBean; |
16 |
-import ai.pai.lensman.db.Preferences; |
|
17 | 16 |
import ai.pai.lensman.qrcode.QRCaptureActivity; |
18 | 17 |
import butterknife.BindView; |
19 | 18 |
import butterknife.ButterKnife; |
@@ -36,8 +35,7 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
36 | 35 |
setContentView(R.layout.activity_session); |
37 | 36 |
ButterKnife.bind(this); |
38 | 37 |
sessionBean =(SessionBean)getIntent().getSerializableExtra("session"); |
39 |
- String lensmanId = Preferences.getInstance(this).getLensManId(); |
|
40 |
- presenter = new SessionPresenter(lensmanId,sessionBean.sessionId,this); |
|
38 |
+ presenter = new SessionPresenter(sessionBean,this); |
|
41 | 39 |
|
42 | 40 |
titleTextView.setText(getString(R.string.scene)+sessionBean.sessionSeq); |
43 | 41 |
adapter = new PhotoRecyclerAdapter(this); |
@@ -14,30 +14,23 @@ import java.util.Timer; |
||
14 | 14 |
import java.util.TimerTask; |
15 | 15 |
|
16 | 16 |
import ai.pai.lensman.bean.PhotoBean; |
17 |
+import ai.pai.lensman.bean.SessionBean; |
|
17 | 18 |
import ai.pai.lensman.box.BoxUrlContainer; |
18 | 19 |
import ai.pai.lensman.utils.HttpPostTask; |
19 | 20 |
|
20 |
-/** |
|
21 |
- * Created by chengzhenyu on 2016/7/7. |
|
22 |
- */ |
|
23 | 21 |
public class SessionInteractor { |
24 | 22 |
|
25 |
- private String sessionId; |
|
26 |
- private String lensmanId; |
|
23 |
+ private SessionBean sessionBean; |
|
27 | 24 |
private Timer timer; |
28 | 25 |
private SessionListener listener; |
29 | 26 |
private HttpPostTask sessionStartTask; |
30 | 27 |
private HttpPostTask sessionEndTask; |
31 |
- private HttpPostTask fetchThumbnailTask; |
|
32 |
- private HttpPostTask fetchOriginTask; |
|
33 | 28 |
|
34 | 29 |
private static final String TAG = "SessionInteractor"; |
35 | 30 |
|
36 |
- public SessionInteractor(String lensmanId,String sessionId, SessionListener listener) { |
|
37 |
- this.lensmanId = lensmanId; |
|
31 |
+ public SessionInteractor(SessionBean sessionBean, SessionListener listener) { |
|
38 | 32 |
this.listener = listener; |
39 |
- this.sessionId = sessionId; |
|
40 |
- |
|
33 |
+ this.sessionBean = sessionBean; |
|
41 | 34 |
} |
42 | 35 |
|
43 | 36 |
public interface SessionListener { |
@@ -51,8 +44,8 @@ public class SessionInteractor { |
||
51 | 44 |
public void startSession(){ |
52 | 45 |
cancelTask(sessionStartTask); |
53 | 46 |
HashMap<String,String> params = new HashMap<>(); |
54 |
- params.put("lensman",lensmanId); |
|
55 |
- params.put("session",sessionId); |
|
47 |
+ params.put("lensman",sessionBean.lensmanId); |
|
48 |
+ params.put("session",sessionBean.sessionId); |
|
56 | 49 |
sessionStartTask = new HttpPostTask(params){ |
57 | 50 |
@Override |
58 | 51 |
protected boolean parseResponse(String response) { |
@@ -72,13 +65,13 @@ public class SessionInteractor { |
||
72 | 65 |
@Override |
73 | 66 |
protected void onPostFail() { |
74 | 67 |
super.onPostFail(); |
75 |
- listener.onSessionStartError(sessionId); |
|
68 |
+ listener.onSessionStartError(sessionBean.sessionId); |
|
76 | 69 |
} |
77 | 70 |
|
78 | 71 |
@Override |
79 | 72 |
protected void onPostSuccess() { |
80 | 73 |
super.onPostSuccess(); |
81 |
- listener.onSessionStartSuccess(sessionId); |
|
74 |
+ listener.onSessionStartSuccess(sessionBean.sessionId); |
|
82 | 75 |
startCapture(); |
83 | 76 |
} |
84 | 77 |
}; |
@@ -100,11 +93,10 @@ public class SessionInteractor { |
||
100 | 93 |
} |
101 | 94 |
|
102 | 95 |
private void fetchThumbnailTask(){ |
103 |
- cancelTask(fetchThumbnailTask); |
|
104 | 96 |
HashMap<String,String> params = new HashMap<>(); |
105 |
- params.put("lensman",lensmanId); |
|
106 |
- params.put("session",sessionId); |
|
107 |
- fetchThumbnailTask = new HttpPostTask(params){ |
|
97 |
+ params.put("lensman",sessionBean.lensmanId); |
|
98 |
+ params.put("session",sessionBean.sessionId); |
|
99 |
+ HttpPostTask fetchThumbnailTask = new HttpPostTask(params){ |
|
108 | 100 |
ArrayList<PhotoBean> photoList = new ArrayList<>(); |
109 | 101 |
@Override |
110 | 102 |
protected boolean parseResponse(String response) { |
@@ -125,7 +117,10 @@ public class SessionInteractor { |
||
125 | 117 |
bean.captureTime = bean.photoId; |
126 | 118 |
bean.isRawPhoto = false; |
127 | 119 |
bean.isUploaded = false; |
128 |
- bean.sessionId = sessionId; |
|
120 |
+ bean.sessionId = sessionBean.sessionId; |
|
121 |
+ bean.lensmanId = sessionBean.lensmanId; |
|
122 |
+ bean.sessionSeq = sessionBean.sessionSeq; |
|
123 |
+ bean.sessionDate = sessionBean.sessionDate; |
|
129 | 124 |
photoList.add(bean); |
130 | 125 |
} |
131 | 126 |
} |
@@ -154,15 +149,15 @@ public class SessionInteractor { |
||
154 | 149 |
public void endSession(){ |
155 | 150 |
cancelTask(sessionEndTask); |
156 | 151 |
HashMap<String,String> params = new HashMap<>(); |
157 |
- params.put("lensman",lensmanId); |
|
158 |
- params.put("session",sessionId); |
|
152 |
+ params.put("lensman",sessionBean.lensmanId); |
|
153 |
+ params.put("session",sessionBean.sessionId); |
|
159 | 154 |
sessionEndTask = new HttpPostTask(params); |
160 | 155 |
sessionEndTask.executeOnExecutor(ThreadExecutor.getInstance().getExecutor(), BoxUrlContainer.SESSION_END_URL); |
161 | 156 |
if(timer!=null){ |
162 | 157 |
timer.cancel(); |
163 | 158 |
timer = null; |
164 | 159 |
} |
165 |
- listener.onSessionEnd(sessionId); |
|
160 |
+ listener.onSessionEnd(sessionBean.sessionId); |
|
166 | 161 |
} |
167 | 162 |
|
168 | 163 |
private void cancelTask(HttpPostTask task){ |
@@ -3,6 +3,7 @@ package ai.pai.lensman.session; |
||
3 | 3 |
import java.util.ArrayList; |
4 | 4 |
|
5 | 5 |
import ai.pai.lensman.bean.PhotoBean; |
6 |
+import ai.pai.lensman.bean.SessionBean; |
|
6 | 7 |
|
7 | 8 |
public class SessionPresenter implements SessionContract.Presenter,SessionInteractor.SessionListener{ |
8 | 9 |
|
@@ -10,10 +11,10 @@ public class SessionPresenter implements SessionContract.Presenter,SessionIntera |
||
10 | 11 |
private ArrayList<PhotoBean> photoList; |
11 | 12 |
private SessionContract.View sessionView; |
12 | 13 |
|
13 |
- public SessionPresenter(String lensmanId, String sessionId, SessionContract.View view){ |
|
14 |
+ public SessionPresenter(SessionBean sessionBean, SessionContract.View view){ |
|
14 | 15 |
this.sessionView = view; |
15 | 16 |
photoList = new ArrayList<>(); |
16 |
- interactor = new SessionInteractor(lensmanId,sessionId,this); |
|
17 |
+ interactor = new SessionInteractor(sessionBean,this); |
|
17 | 18 |
} |
18 | 19 |
|
19 | 20 |
@Override |
@@ -9,11 +9,14 @@ import android.widget.ImageView; |
||
9 | 9 |
import android.widget.TextView; |
10 | 10 |
|
11 | 11 |
import java.util.ArrayList; |
12 |
+import java.util.Random; |
|
12 | 13 |
|
13 | 14 |
import ai.pai.lensman.R; |
14 | 15 |
import ai.pai.lensman.base.BaseActivity; |
15 | 16 |
import ai.pai.lensman.bean.SessionBean; |
16 | 17 |
import ai.pai.lensman.briefs.BriefsActivity; |
18 |
+import ai.pai.lensman.db.Preferences; |
|
19 |
+import ai.pai.lensman.session.SessionActivity; |
|
17 | 20 |
import butterknife.BindView; |
18 | 21 |
import butterknife.ButterKnife; |
19 | 22 |
import butterknife.OnClick; |
@@ -34,7 +37,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
34 | 37 |
setContentView(R.layout.activity_upload); |
35 | 38 |
ButterKnife.bind(this); |
36 | 39 |
|
37 |
- presenter = new UploadPresenter(this,this); |
|
40 |
+ presenter = new UploadPresenter(this); |
|
38 | 41 |
adapter = new SessionRecyclerAdapter(this); |
39 | 42 |
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(this,2,LinearLayoutManager.VERTICAL,false); |
40 | 43 |
sessionsRecyclerView.setLayoutManager(layoutManager); |
@@ -60,12 +63,14 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
60 | 63 |
|
61 | 64 |
@OnClick(R.id.iv_add_session) |
62 | 65 |
void jumpToNewSession(){ |
63 |
- presenter.jumpToNewSession(); |
|
66 |
+ SessionBean sessionBean = new SessionBean(); |
|
67 |
+ |
|
68 |
+ jumpToSelectedSession(sessionBean); |
|
64 | 69 |
} |
65 | 70 |
|
66 | 71 |
@OnClick(R.id.iv_bt_status) |
67 | 72 |
void checkBTStatus(){ |
68 |
- presenter.checkBTStatus(); |
|
73 |
+ |
|
69 | 74 |
} |
70 | 75 |
|
71 | 76 |
|
@@ -137,4 +142,15 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
137 | 142 |
}); |
138 | 143 |
} |
139 | 144 |
|
145 |
+ |
|
146 |
+ public void jumpToSelectedSession(SessionBean sessionBean) { |
|
147 |
+ sessionBean.lensmanId = Preferences.getInstance(this).getLensManId(); |
|
148 |
+ sessionBean.sessionDate=20160813; |
|
149 |
+ sessionBean.sessionSeq = new Random().nextInt(10000); |
|
150 |
+ sessionBean.sessionId ="chengzhenyu_test"; |
|
151 |
+ Intent intent = new Intent(this, SessionActivity.class); |
|
152 |
+ intent.putExtra("session",sessionBean); |
|
153 |
+ startActivity(intent); |
|
154 |
+ } |
|
155 |
+ |
|
140 | 156 |
} |
@@ -20,16 +20,10 @@ public class UploadContract { |
||
20 | 20 |
void showSessionViews(); |
21 | 21 |
void updateSessionUploadView(SessionBean bean); |
22 | 22 |
void refreshSessionViews(ArrayList<SessionBean> sessionList); |
23 |
- |
|
24 | 23 |
} |
25 | 24 |
|
26 | 25 |
interface Presenter extends BasePresenter{ |
27 | 26 |
|
28 |
- void checkBTStatus(); |
|
29 |
- void jumpToBriefs(); |
|
30 |
- void jumpToNewSession(); |
|
31 |
- void jumpToSelectedSession(SessionBean sessionBean); |
|
32 |
- |
|
33 | 27 |
} |
34 | 28 |
|
35 | 29 |
} |
@@ -1,30 +1,20 @@ |
||
1 | 1 |
package ai.pai.lensman.upload; |
2 | 2 |
|
3 |
-import android.app.Activity; |
|
4 |
-import android.content.Intent; |
|
5 |
- |
|
6 | 3 |
import java.util.ArrayList; |
7 | 4 |
|
8 | 5 |
import ai.pai.lensman.bean.SessionBean; |
9 |
-import ai.pai.lensman.session.SessionActivity; |
|
10 | 6 |
|
11 | 7 |
public class UploadPresenter implements UploadContract.Presenter { |
12 | 8 |
|
13 |
- private Activity activity; |
|
14 | 9 |
private UploadContract.View uploadView; |
15 | 10 |
private ArrayList<SessionBean> sessionList; |
16 | 11 |
|
17 |
- private int seq = 0; |
|
18 |
- public UploadPresenter(Activity activity, UploadContract.View view){ |
|
19 |
- this.activity = activity; |
|
12 |
+ |
|
13 |
+ public UploadPresenter( UploadContract.View view){ |
|
20 | 14 |
this.uploadView = view; |
21 | 15 |
sessionList = new ArrayList<>(); |
22 | 16 |
} |
23 | 17 |
|
24 |
- @Override |
|
25 |
- public void checkBTStatus() { |
|
26 |
- |
|
27 |
- } |
|
28 | 18 |
|
29 | 19 |
@Override |
30 | 20 |
public void start() { |
@@ -41,26 +31,4 @@ public class UploadPresenter implements UploadContract.Presenter { |
||
41 | 31 |
|
42 | 32 |
} |
43 | 33 |
|
44 |
- |
|
45 |
- @Override |
|
46 |
- public void jumpToBriefs() { |
|
47 |
- |
|
48 |
- } |
|
49 |
- |
|
50 |
- @Override |
|
51 |
- public void jumpToNewSession() { |
|
52 |
- seq ++; |
|
53 |
- SessionBean sessionBean = new SessionBean(); |
|
54 |
- sessionBean.sessionSeq = seq; |
|
55 |
- sessionList.add(sessionBean); |
|
56 |
- jumpToSelectedSession(sessionBean); |
|
57 |
- } |
|
58 |
- |
|
59 |
- @Override |
|
60 |
- public void jumpToSelectedSession(SessionBean sessionBean) { |
|
61 |
- Intent intent = new Intent(activity, SessionActivity.class); |
|
62 |
- intent.putExtra("session",sessionBean); |
|
63 |
- activity.startActivity(intent); |
|
64 |
- } |
|
65 |
- |
|
66 | 34 |
} |