@@ -23,6 +23,7 @@ android { |
||
23 | 23 |
targetSdkVersion 24 |
24 | 24 |
versionCode 1 |
25 | 25 |
versionName "1.0" |
26 |
+ buildConfigField "boolean", "isTestMode", "true" |
|
26 | 27 |
} |
27 | 28 |
signingConfigs { |
28 | 29 |
releaseConfig { |
@@ -140,7 +140,7 @@ public class PhotoUploadUtils { |
||
140 | 140 |
private byte[] getBitmapBytes(File f) throws Exception { |
141 | 141 |
int uploadWidth = UPLOAD_PHOTO_WIDTH; |
142 | 142 |
int uploadHeight = UPLOAD_PHOTO_HEIGHT; |
143 |
- int uploadQuality = 35; |
|
143 |
+ int uploadQuality = 90; |
|
144 | 144 |
LogHelper.d("czy","upload default width = "+uploadWidth+"uploadQuality="+uploadQuality); |
145 | 145 |
try{ |
146 | 146 |
File file = new File(Constants.APP_UPLOAD_CONFIG_PATH); |
@@ -44,7 +44,6 @@ public class UploadTask extends AsyncTask<Void, Integer, Boolean> { |
||
44 | 44 |
JSONObject resultObj = new JSONObject(result); |
45 | 45 |
if (resultObj.getInt("status") == 200) { |
46 | 46 |
LogHelper.d(TAG, "上传 UploadTask upload result ok "); |
47 |
- JSONObject info = resultObj.getJSONObject("data"); |
|
48 | 47 |
return true; |
49 | 48 |
} |
50 | 49 |
} else { |
@@ -18,6 +18,7 @@ import java.util.HashMap; |
||
18 | 18 |
import java.util.Timer; |
19 | 19 |
import java.util.TimerTask; |
20 | 20 |
|
21 |
+import ai.pai.lensman.BuildConfig; |
|
21 | 22 |
import ai.pai.lensman.bean.PhotoBean; |
22 | 23 |
import ai.pai.lensman.bean.SessionBean; |
23 | 24 |
import ai.pai.lensman.box.BoxUrlContainer; |
@@ -48,6 +49,11 @@ public class SessionInteractor { |
||
48 | 49 |
} |
49 | 50 |
|
50 | 51 |
public void startSession(){ |
52 |
+ if(BuildConfig.isTestMode){ |
|
53 |
+ listener.onSessionStartSuccess(sessionBean.sessionId); |
|
54 |
+ startCapture(); |
|
55 |
+ return; |
|
56 |
+ } |
|
51 | 57 |
cancelTask(sessionStartTask); |
52 | 58 |
HashMap<String,String> params = new HashMap<>(); |
53 | 59 |
params.put("lensman",sessionBean.lensmanId); |
@@ -99,6 +105,22 @@ public class SessionInteractor { |
||
99 | 105 |
} |
100 | 106 |
|
101 | 107 |
private void fetchThumbnailTask(){ |
108 |
+ if(BuildConfig.isTestMode){ |
|
109 |
+ PhotoBean bean = new PhotoBean(); |
|
110 |
+ long milisec = System.currentTimeMillis(); |
|
111 |
+ bean.photoName = milisec+".jpg"; |
|
112 |
+ bean.photoId = milisec; |
|
113 |
+ bean.photoPath = "http://e.hiphotos.baidu.com/image/h%3D200/sign=31e61d6532f33a87816d071af65d1018/95eef01f3a292df504213240b4315c6035a87381.jpg"; |
|
114 |
+ bean.captureTime = bean.photoId; |
|
115 |
+ bean.isRawPhoto = false; |
|
116 |
+ bean.isUploaded = false; |
|
117 |
+ bean.sessionId = sessionBean.sessionId; |
|
118 |
+ bean.lensmanId = sessionBean.lensmanId; |
|
119 |
+ bean.sessionSeq = sessionBean.sessionSeq; |
|
120 |
+ bean.sessionDate = sessionBean.sessionDate; |
|
121 |
+ new SavePhotoTask(bean).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),bean); |
|
122 |
+ return; |
|
123 |
+ } |
|
102 | 124 |
HashMap<String,String> params = new HashMap<>(); |
103 | 125 |
params.put("lensman",sessionBean.lensmanId); |
104 | 126 |
params.put("session",sessionBean.sessionId); |
@@ -129,21 +151,6 @@ public class SessionInteractor { |
||
129 | 151 |
bean.sessionDate = sessionBean.sessionDate; |
130 | 152 |
photoList.add(bean); |
131 | 153 |
} |
132 |
- }else{ |
|
133 |
- //TODO for test |
|
134 |
- PhotoBean bean = new PhotoBean(); |
|
135 |
- long milisec = System.currentTimeMillis(); |
|
136 |
- bean.photoName = milisec+".jpg"; |
|
137 |
- bean.photoId = milisec; |
|
138 |
- bean.photoPath = "http://e.hiphotos.baidu.com/image/h%3D200/sign=31e61d6532f33a87816d071af65d1018/95eef01f3a292df504213240b4315c6035a87381.jpg"; |
|
139 |
- bean.captureTime = bean.photoId; |
|
140 |
- bean.isRawPhoto = false; |
|
141 |
- bean.isUploaded = false; |
|
142 |
- bean.sessionId = sessionBean.sessionId; |
|
143 |
- bean.lensmanId = sessionBean.lensmanId; |
|
144 |
- bean.sessionSeq = sessionBean.sessionSeq; |
|
145 |
- bean.sessionDate = sessionBean.sessionDate; |
|
146 |
- photoList.add(bean); |
|
147 | 154 |
} |
148 | 155 |
return true; |
149 | 156 |
} |
@@ -181,8 +188,7 @@ public class SessionInteractor { |
||
181 | 188 |
protected Boolean doInBackground(PhotoBean... params) { |
182 | 189 |
PhotoBean photoBean = params[0]; |
183 | 190 |
String path = BoxUrlContainer.PHOTO_PATH_PREFIX_URL+photoBean.photoPath; |
184 |
- //TODO for test |
|
185 |
- if(photoBean.photoPath.contains("baidu")){ |
|
191 |
+ if(BuildConfig.isTestMode){ |
|
186 | 192 |
path = photoBean.photoPath; |
187 | 193 |
} |
188 | 194 |
LogHelper.d(TAG,"保存照片到本地,图片链接地址为"+path); |
@@ -1,12 +1,14 @@ |
||
1 | 1 |
package ai.pai.lensman.session; |
2 | 2 |
|
3 |
-import android.os.SystemClock; |
|
3 |
+import android.content.Intent; |
|
4 | 4 |
|
5 | 5 |
import java.util.ArrayList; |
6 | 6 |
|
7 |
+import ai.pai.lensman.App; |
|
7 | 8 |
import ai.pai.lensman.bean.PhotoBean; |
8 | 9 |
import ai.pai.lensman.bean.SessionBean; |
9 | 10 |
import ai.pai.lensman.db.DBService; |
11 |
+import ai.pai.lensman.service.UploadService; |
|
10 | 12 |
|
11 | 13 |
public class SessionPresenter implements SessionContract.Presenter, SessionInteractor.SessionListener { |
12 | 14 |
|
@@ -24,23 +26,6 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
24 | 26 |
@Override |
25 | 27 |
public void start() { |
26 | 28 |
photoList = DBService.getInstance().getPhotoListBySessionId(sessionBean.sessionId); |
27 |
- //TODO for test |
|
28 |
- for (int k = 0; k < 10; k++) { |
|
29 |
- PhotoBean bean = new PhotoBean(); |
|
30 |
- long milisec = System.currentTimeMillis(); |
|
31 |
- bean.photoName = milisec + ".jpg"; |
|
32 |
- bean.photoId = milisec; |
|
33 |
- bean.photoPath = "http://e.hiphotos.baidu.com/image/h%3D200/sign=31e61d6532f33a87816d071af65d1018/95eef01f3a292df504213240b4315c6035a87381.jpg"; |
|
34 |
- bean.captureTime = bean.photoId; |
|
35 |
- bean.isRawPhoto = false; |
|
36 |
- bean.isUploaded = false; |
|
37 |
- bean.sessionId = sessionBean.sessionId; |
|
38 |
- bean.lensmanId = sessionBean.lensmanId; |
|
39 |
- bean.sessionSeq = sessionBean.sessionSeq; |
|
40 |
- bean.sessionDate = sessionBean.sessionDate; |
|
41 |
- photoList.add(bean); |
|
42 |
- SystemClock.sleep(10); |
|
43 |
- } |
|
44 | 29 |
if (photoList.size() == 0) { |
45 | 30 |
sessionView.showEmptyView(); |
46 | 31 |
} else { |
@@ -72,6 +57,7 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter |
||
72 | 57 |
DBService.getInstance().addPhotoBean(bean); |
73 | 58 |
sessionView.showPhotoRecyclerView(); |
74 | 59 |
sessionView.addNewPhoto(bean); |
60 |
+ App.getAppContext().startService(new Intent(App.getAppContext(), UploadService.class)); |
|
75 | 61 |
} |
76 | 62 |
|
77 | 63 |
@Override |