-import okhttp3.OkHttpClient;
-import retrofit2.Retrofit;
-import retrofit2.converter.gson.GsonConverterFactory;
-
-public final class BoxClient {
-
- private static final String BASE_URL = " http://120.27.44.52:8001/";
-
- private static final OkHttpClient client = new OkHttpClient.Builder()
- .retryOnConnectionFailure(true)
- .connectTimeout(10, TimeUnit.SECONDS)
- .build();
-
- public static final Gson gson = new GsonBuilder().create();
-
- public static final BoxHttpService service = new Retrofit.Builder()
- .baseUrl(BASE_URL)
- .client(client)
- .addConverterFactory(GsonConverterFactory.create(gson))
- .build()
- .create(BoxHttpService.class);
-
-}
@@ -1,31 +0,0 @@ |
||
| 1 |
-package ai.pai.lensman.box; |
|
| 2 |
- |
|
| 3 |
-import java.util.List; |
|
| 4 |
- |
|
| 5 |
-import ai.pai.lensman.bean.PhotoBean; |
|
| 6 |
-import retrofit2.Call; |
|
| 7 |
-import retrofit2.http.Field; |
|
| 8 |
-import retrofit2.http.FormUrlEncoded; |
|
| 9 |
-import retrofit2.http.POST; |
|
| 10 |
- |
|
| 11 |
-public interface BoxHttpService {
|
|
| 12 |
- |
|
| 13 |
- |
|
| 14 |
- @POST("session_start")
|
|
| 15 |
- @FormUrlEncoded |
|
| 16 |
- Call<String> startNewSession(@Field("session") String sessionId ,@Field("lensman") String lensmanId);
|
|
| 17 |
- |
|
| 18 |
- @POST("session_end")
|
|
| 19 |
- @FormUrlEncoded |
|
| 20 |
- Call<String> endSession(@Field("session") String sessionId, @Field("lensman") String lensmanId);
|
|
| 21 |
- |
|
| 22 |
- @POST("fetch_thumbnail")
|
|
| 23 |
- @FormUrlEncoded |
|
| 24 |
- Call<List<PhotoBean>> fetchSessionThumbnails(@Field("session") String sessionId, @Field("lensman") String lensmanId);
|
|
| 25 |
- |
|
| 26 |
- @POST("fetch_origin")
|
|
| 27 |
- @FormUrlEncoded |
|
| 28 |
- Call<String> fetchSessionOriginPhoto(@Field("session") String sessionId, @Field("lensman") String lensmanId, @Field("name") String name);
|
|
| 29 |
- |
|
| 30 |
- |
|
| 31 |
-} |
@@ -0,0 +1,16 @@ |
||
| 1 |
+package ai.pai.lensman.box; |
|
| 2 |
+ |
|
| 3 |
+public final class BoxUrlContainer {
|
|
| 4 |
+ |
|
| 5 |
+ private static final String BASE_URL = " http://120.27.44.52:8001/"; |
|
| 6 |
+ |
|
| 7 |
+ public static final String SESSION_START_URL = BASE_URL+"session_start"; |
|
| 8 |
+ |
|
| 9 |
+ public static final String SESSION_END_URL = BASE_URL+"session_end"; |
|
| 10 |
+ |
|
| 11 |
+ public static final String FETCH_THUMBNAIL_URL = BASE_URL+"fetch_thumbnail"; |
|
| 12 |
+ |
|
| 13 |
+ public static final String FETCH_ORIGIN_URL = BASE_URL+"fetch_origin"; |
|
| 14 |
+ |
|
| 15 |
+ |
|
| 16 |
+} |
@@ -1,18 +0,0 @@ |
||
| 1 |
-package ai.pai.lensman.box; |
|
| 2 |
- |
|
| 3 |
-import ai.pai.lensman.bean.Result; |
|
| 4 |
-import retrofit2.Response; |
|
| 5 |
- |
|
| 6 |
-public interface CallbackLifecycle<T> {
|
|
| 7 |
- |
|
| 8 |
- boolean onResultOk(Response<T> response, T result); |
|
| 9 |
- |
|
| 10 |
- boolean onResultError(Response<T> response, Result.Error error); |
|
| 11 |
- |
|
| 12 |
- boolean onCallCancel(); |
|
| 13 |
- |
|
| 14 |
- boolean onCallException(Throwable t, Result.Error error); |
|
| 15 |
- |
|
| 16 |
- void onFinish(); |
|
| 17 |
- |
|
| 18 |
-} |
@@ -65,8 +65,4 @@ public class LoginActivity extends BaseActivity implements LoginContract.View{
|
||
| 65 | 65 |
finish(); |
| 66 | 66 |
} |
| 67 | 67 |
|
| 68 |
- @Override |
|
| 69 |
- public void setPresenter(LoginContract.Presenter presenter) {
|
|
| 70 |
- |
|
| 71 |
- } |
|
| 72 | 68 |
} |
@@ -5,7 +5,7 @@ import ai.pai.lensman.base.BaseView; |
||
| 5 | 5 |
|
| 6 | 6 |
public class LoginContract {
|
| 7 | 7 |
|
| 8 |
- interface View extends BaseView<Presenter>{
|
|
| 8 |
+ interface View extends BaseView{
|
|
| 9 | 9 |
void showLoginHint(String hint); |
| 10 | 10 |
void showProgressView(); |
| 11 | 11 |
void hideProgressView(); |
@@ -121,8 +121,4 @@ public class SessionActivity extends BaseActivity implements SessionContract.Vie |
||
| 121 | 121 |
|
| 122 | 122 |
} |
| 123 | 123 |
|
| 124 |
- @Override |
|
| 125 |
- public void setPresenter(SessionContract.Presenter presenter) {
|
|
| 126 |
- |
|
| 127 |
- } |
|
| 128 | 124 |
} |
@@ -9,7 +9,7 @@ import ai.pai.lensman.bean.PhotoBean; |
||
| 9 | 9 |
*/ |
| 10 | 10 |
public class SessionContract {
|
| 11 | 11 |
|
| 12 |
- interface View extends BaseView<Presenter>{
|
|
| 12 |
+ interface View extends BaseView{
|
|
| 13 | 13 |
void addNewPhoto(PhotoBean bean); |
| 14 | 14 |
void showPhotoRecyclerView(); |
| 15 | 15 |
void showEmptyView(); |
@@ -2,16 +2,11 @@ package ai.pai.lensman.session; |
||
| 2 | 2 |
|
| 3 | 3 |
import android.content.Context; |
| 4 | 4 |
|
| 5 |
-import java.util.List; |
|
| 6 | 5 |
import java.util.Timer; |
| 7 | 6 |
import java.util.TimerTask; |
| 8 | 7 |
|
| 9 | 8 |
import ai.pai.lensman.bean.PhotoBean; |
| 10 |
-import ai.pai.lensman.box.BoxClient; |
|
| 11 | 9 |
import ai.pai.lensman.db.Preferences; |
| 12 |
-import retrofit2.Call; |
|
| 13 |
-import retrofit2.Callback; |
|
| 14 |
-import retrofit2.Response; |
|
| 15 | 10 |
|
| 16 | 11 |
/** |
| 17 | 12 |
* Created by chengzhenyu on 2016/7/7. |
@@ -40,17 +35,7 @@ public class SessionInteractor {
|
||
| 40 | 35 |
} |
| 41 | 36 |
|
| 42 | 37 |
public void startSession(){
|
| 43 |
- BoxClient.service.startNewSession(sessionId,lensmanId).enqueue(new Callback<String>() {
|
|
| 44 |
- @Override |
|
| 45 |
- public void onResponse(Call<String> call, Response<String> response) {
|
|
| 46 |
- listener.onSessionStartSuccess(sessionId); |
|
| 47 |
- } |
|
| 48 | 38 |
|
| 49 |
- @Override |
|
| 50 |
- public void onFailure(Call<String> call, Throwable t) {
|
|
| 51 |
- listener.onSessionStartError(sessionId); |
|
| 52 |
- } |
|
| 53 |
- }); |
|
| 54 | 39 |
} |
| 55 | 40 |
|
| 56 | 41 |
public void startCapture() {
|
@@ -61,19 +46,7 @@ public class SessionInteractor {
|
||
| 61 | 46 |
timer = new Timer(); |
| 62 | 47 |
timer.schedule(new TimerTask() {
|
| 63 | 48 |
@Override |
| 64 |
- public void run() {
|
|
| 65 |
- BoxClient.service.fetchSessionThumbnails(sessionId,lensmanId).enqueue(new Callback<List<PhotoBean>>() {
|
|
| 66 |
- @Override |
|
| 67 |
- public void onResponse(Call<List<PhotoBean>> call, Response<List<PhotoBean>> response) {
|
|
| 68 |
- |
|
| 69 |
- } |
|
| 70 |
- |
|
| 71 |
- @Override |
|
| 72 |
- public void onFailure(Call<List<PhotoBean>> call, Throwable t) {
|
|
| 73 |
- |
|
| 74 |
- } |
|
| 75 |
- }); |
|
| 76 |
- } |
|
| 49 |
+ public void run() {}
|
|
| 77 | 50 |
},1000,1000); |
| 78 | 51 |
} |
| 79 | 52 |
|
@@ -82,17 +55,7 @@ public class SessionInteractor {
|
||
| 82 | 55 |
timer.cancel(); |
| 83 | 56 |
timer = null; |
| 84 | 57 |
} |
| 85 |
- BoxClient.service.endSession(sessionId,lensmanId).enqueue(new Callback<String>() {
|
|
| 86 |
- @Override |
|
| 87 |
- public void onResponse(Call<String> call, Response<String> response) {
|
|
| 88 |
- listener.onSessionEnd(sessionId); |
|
| 89 |
- } |
|
| 90 |
- |
|
| 91 |
- @Override |
|
| 92 |
- public void onFailure(Call<String> call, Throwable t) {
|
|
| 93 | 58 |
|
| 94 |
- } |
|
| 95 |
- }); |
|
| 96 | 59 |
} |
| 97 | 60 |
|
| 98 | 61 |
} |
@@ -137,8 +137,4 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
| 137 | 137 |
}); |
| 138 | 138 |
} |
| 139 | 139 |
|
| 140 |
- @Override |
|
| 141 |
- public void setPresenter(UploadContract.Presenter presenter) {
|
|
| 142 |
- |
|
| 143 |
- } |
|
| 144 | 140 |
} |
@@ -11,7 +11,7 @@ import ai.pai.lensman.bean.SessionBean; |
||
| 11 | 11 |
*/ |
| 12 | 12 |
public class UploadContract {
|
| 13 | 13 |
|
| 14 |
- interface View extends BaseView<Presenter> {
|
|
| 14 |
+ interface View extends BaseView {
|
|
| 15 | 15 |
|
| 16 | 16 |
void addNewSessionView(SessionBean bean); |
| 17 | 17 |
void showBTDisconnectedView(); |