@@ -16,7 +16,7 @@ import retrofit2.converter.gson.GsonConverterFactory; |
||
16 | 16 |
|
17 | 17 |
public final class ApiClient { |
18 | 18 |
|
19 |
- private static final String BASE_URL = ""; |
|
19 |
+ private static final String BASE_URL = " http://120.27.44.52:8001/"; |
|
20 | 20 |
|
21 | 21 |
private static final OkHttpClient client = new OkHttpClient.Builder() |
22 | 22 |
.retryOnConnectionFailure(true) |
@@ -1,17 +1,26 @@ |
||
1 | 1 |
package ai.pai.lensman.box; |
2 | 2 |
|
3 |
+import java.util.List; |
|
4 |
+ |
|
5 |
+import ai.pai.lensman.session.PhotoBean; |
|
3 | 6 |
import retrofit2.Call; |
4 |
-import retrofit2.http.GET; |
|
5 |
-import retrofit2.http.Query; |
|
7 |
+import retrofit2.http.Field; |
|
8 |
+import retrofit2.http.POST; |
|
6 | 9 |
|
7 | 10 |
public interface ApiService { |
8 | 11 |
|
9 | 12 |
|
10 |
- @GET("session/new") |
|
11 |
- Call<String> startNewSession( |
|
12 |
- @Query("sessionId") String sessionId |
|
13 |
+ @POST("session_start") |
|
14 |
+ Call<String> startNewSession(@Field("session") String sessionId ,@Field("lensman") String lensmanId); |
|
15 |
+ |
|
16 |
+ @POST("session_end") |
|
17 |
+ Call<String> endSession(@Field("session") String sessionId, @Field("lensman") String lensmanId); |
|
18 |
+ |
|
19 |
+ @POST("fetch_thumbnail") |
|
20 |
+ Call<List<PhotoBean>> fetchSessionThumbnails(@Field("session") String sessionId, @Field("lensman") String lensmanId); |
|
13 | 21 |
|
14 |
- ); |
|
22 |
+ @POST("fetch_origin") |
|
23 |
+ Call<String> fetchSessionOriginPhoto(@Field("session") String sessionId, @Field("lensman") String lensmanId, @Field("name") String name); |
|
15 | 24 |
|
16 | 25 |
|
17 | 26 |
} |
@@ -3,9 +3,6 @@ package ai.pai.lensman.db; |
||
3 | 3 |
import android.content.Context; |
4 | 4 |
import android.content.SharedPreferences; |
5 | 5 |
|
6 |
-/** |
|
7 |
- * Created by chengzhenyu on 2015/8/24. |
|
8 |
- */ |
|
9 | 6 |
public class Preferences { |
10 | 7 |
|
11 | 8 |
private Context context; |
@@ -43,20 +40,12 @@ public class Preferences { |
||
43 | 40 |
return mPrefs.getString("userName",NullStr); |
44 | 41 |
} |
45 | 42 |
|
46 |
- public void setNickName(String nickName){ |
|
47 |
- mPrefs.edit().putString("nickName",nickName).commit(); |
|
43 |
+ public void setLensManId(String lensManId){ |
|
44 |
+ mPrefs.edit().putString("lensManId",lensManId).commit(); |
|
48 | 45 |
} |
49 | 46 |
|
50 |
- public String getNickName(){ |
|
51 |
- return mPrefs.getString("nickName",NullStr); |
|
52 |
- } |
|
53 |
- |
|
54 |
- public void setUserId(String userId){ |
|
55 |
- mPrefs.edit().putString("userId",userId).commit(); |
|
56 |
- } |
|
57 |
- |
|
58 |
- public String getUserId(){ |
|
59 |
- return mPrefs.getString("userId",NullStr); |
|
47 |
+ public String getLensManId(){ |
|
48 |
+ return mPrefs.getString("lensManId",NullStr); |
|
60 | 49 |
} |
61 | 50 |
|
62 | 51 |
public void clearPrefs(){ |
@@ -32,9 +32,9 @@ public class SessionActivity extends AppCompatActivity implements SessionContrac |
||
32 | 32 |
super.onCreate(savedInstanceState); |
33 | 33 |
setContentView(R.layout.activity_session); |
34 | 34 |
ButterKnife.bind(this); |
35 |
- presenter = new SessionPresenterImpl(this,this); |
|
36 |
- |
|
37 | 35 |
sessionBean =(SessionBean)getIntent().getSerializableExtra("session"); |
36 |
+ presenter = new SessionPresenterImpl(sessionBean.sessionId,this); |
|
37 |
+ |
|
38 | 38 |
titleTextView.setText(getString(R.string.scene)+sessionBean.sessionSeq); |
39 | 39 |
adapter = new PhotoRecyclerAdapter(this); |
40 | 40 |
RecyclerView.LayoutManager layoutManager = new LinearLayoutManager(this); |
@@ -1,45 +1,35 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 |
-import java.util.Timer; |
|
4 |
-import java.util.TimerTask; |
|
5 |
- |
|
6 | 3 |
/** |
7 | 4 |
* Created by chengzhenyu on 2016/7/7. |
8 | 5 |
*/ |
9 | 6 |
public class SessionInteractor { |
10 | 7 |
|
11 |
- private Timer timer; |
|
8 |
+ private String sessionId; |
|
12 | 9 |
private SessionListener listener; |
13 | 10 |
|
14 |
- public SessionInteractor(SessionListener listener) { |
|
11 |
+ public SessionInteractor(String sessionId, SessionListener listener) { |
|
15 | 12 |
this.listener = listener; |
13 |
+ this.sessionId = sessionId; |
|
16 | 14 |
} |
17 | 15 |
|
18 | 16 |
public interface SessionListener { |
19 | 17 |
|
18 |
+ void onSessionStartSuccess(String session); |
|
19 |
+ void onSessionStartError(String session); |
|
20 | 20 |
void onSessionPhotoCaptured(PhotoBean bean); |
21 |
+ void onSessionEnd(String session); |
|
22 |
+ } |
|
23 |
+ |
|
24 |
+ public void startSession(){ |
|
25 |
+ |
|
21 | 26 |
} |
22 | 27 |
|
23 | 28 |
public void startCapture() { |
24 |
- if (timer != null) { |
|
25 |
- return; |
|
26 |
- } |
|
27 |
- timer = new Timer(); |
|
28 |
- timer.schedule(new TimerTask() { |
|
29 |
- @Override |
|
30 |
- public void run() { |
|
31 |
- if (listener != null) { |
|
32 |
- listener.onSessionPhotoCaptured(new PhotoBean()); |
|
33 |
- } |
|
34 |
- } |
|
35 |
- }, 1000, 1000); |
|
36 | 29 |
} |
37 | 30 |
|
38 |
- public void stopCapture(){ |
|
39 |
- if(timer!=null){ |
|
40 |
- timer.cancel(); |
|
41 |
- timer = null; |
|
42 |
- } |
|
31 |
+ public void endSession(){ |
|
32 |
+ |
|
43 | 33 |
} |
44 | 34 |
|
45 | 35 |
} |
@@ -1,26 +1,22 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 |
-import android.app.Activity; |
|
4 |
- |
|
5 | 3 |
import java.util.ArrayList; |
6 | 4 |
|
7 | 5 |
public class SessionPresenterImpl implements SessionContract.SessionPresenter ,SessionInteractor.SessionListener{ |
8 | 6 |
|
9 |
- private Activity context; |
|
10 |
- private SessionContract.SessionView sessionView; |
|
11 | 7 |
private SessionInteractor interactor; |
12 | 8 |
private ArrayList<PhotoBean> photoList; |
9 |
+ private SessionContract.SessionView sessionView; |
|
13 | 10 |
|
14 |
- public SessionPresenterImpl(Activity context, SessionContract.SessionView view){ |
|
15 |
- this.context = context; |
|
11 |
+ public SessionPresenterImpl(String sessionId, SessionContract.SessionView view){ |
|
16 | 12 |
this.sessionView = view; |
17 | 13 |
photoList = new ArrayList<>(); |
18 |
- interactor = new SessionInteractor(this); |
|
14 |
+ interactor = new SessionInteractor(sessionId,this); |
|
19 | 15 |
} |
20 | 16 |
|
21 | 17 |
@Override |
22 | 18 |
public void start() { |
23 |
- interactor.startCapture(); |
|
19 |
+ interactor.startSession(); |
|
24 | 20 |
if(photoList.size()==0){ |
25 | 21 |
sessionView.showEmptyView(); |
26 | 22 |
}else{ |
@@ -30,7 +26,17 @@ public class SessionPresenterImpl implements SessionContract.SessionPresenter ,S |
||
30 | 26 |
|
31 | 27 |
@Override |
32 | 28 |
public void stop() { |
33 |
- interactor.stopCapture(); |
|
29 |
+ interactor.endSession(); |
|
30 |
+ } |
|
31 |
+ |
|
32 |
+ @Override |
|
33 |
+ public void onSessionStartSuccess(String session) { |
|
34 |
+ |
|
35 |
+ } |
|
36 |
+ |
|
37 |
+ @Override |
|
38 |
+ public void onSessionStartError(String session) { |
|
39 |
+ |
|
34 | 40 |
} |
35 | 41 |
|
36 | 42 |
@Override |
@@ -38,4 +44,9 @@ public class SessionPresenterImpl implements SessionContract.SessionPresenter ,S |
||
38 | 44 |
sessionView.showPhotoRecyclerView(); |
39 | 45 |
sessionView.addNewPhoto(bean); |
40 | 46 |
} |
47 |
+ |
|
48 |
+ @Override |
|
49 |
+ public void onSessionEnd(String session) { |
|
50 |
+ |
|
51 |
+ } |
|
41 | 52 |
} |
@@ -8,6 +8,7 @@ import ai.pai.lensman.session.PhotoBean; |
||
8 | 8 |
public class SessionBean implements Serializable{ |
9 | 9 |
|
10 | 10 |
public int sessionSeq; |
11 |
+ public String sessionId; |
|
11 | 12 |
public ArrayList<PhotoBean> sessionPhotos; |
12 | 13 |
|
13 | 14 |
} |