add database storage

chengzhenyu 8 years ago
parent
commit
c4535de343

+ 19 - 1
app/src/main/java/ai/pai/lensman/session/SessionInteractor.java

@@ -129,6 +129,21 @@ public class SessionInteractor {
129 129
                                 bean.sessionDate = sessionBean.sessionDate;
130 130
                                 photoList.add(bean);
131 131
                             }
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);
132 147
                         }
133 148
                         return true;
134 149
                     }
@@ -166,6 +181,9 @@ public class SessionInteractor {
166 181
         protected Boolean doInBackground(PhotoBean... params) {
167 182
             PhotoBean photoBean = params[0];
168 183
             String  path = BoxUrlContainer.PHOTO_PATH_PREFIX_URL+photoBean.photoPath;
184
+            if(photoBean.photoPath.contains("baidu")){
185
+                path = photoBean.photoPath;
186
+            }
169 187
             LogHelper.d(TAG,"保存照片到本地,图片链接地址为"+path);
170 188
             FileOutputStream fOut = null;
171 189
             HttpURLConnection conn = null;
@@ -189,7 +207,7 @@ public class SessionInteractor {
189 207
                         fOut.flush();
190 208
                     }
191 209
                     fOut.flush();
192
-                    LogHelper.d("czy","保存照片到本地,图片保存至"+file.getAbsolutePath()+"图片大小为"+file.length()+"字节\n\n");
210
+                    LogHelper.d(TAG,"保存照片到本地,图片保存至"+file.getAbsolutePath()+"图片大小为"+file.length()+"字节\n\n");
193 211
                 }
194 212
                 return true;
195 213
             } catch (Exception e) {

+ 6 - 1
app/src/main/java/ai/pai/lensman/session/SessionPresenter.java

@@ -11,19 +11,24 @@ public class SessionPresenter implements SessionContract.Presenter,SessionIntera
11 11
     private SessionInteractor interactor;
12 12
     private ArrayList<PhotoBean> photoList;
13 13
     private SessionContract.View sessionView;
14
+    private SessionBean sessionBean;
14 15
 
15 16
     public SessionPresenter(SessionBean sessionBean, SessionContract.View view){
16 17
         this.sessionView = view;
17
-        photoList = DBService.getInstance().getPhotoListBySessionId(sessionBean.sessionId);
18
+        this.sessionBean = sessionBean;
18 19
         interactor = new SessionInteractor(sessionBean,this);
19 20
     }
20 21
 
21 22
     @Override
22 23
     public void start() {
24
+        photoList = DBService.getInstance().getPhotoListBySessionId(sessionBean.sessionId);
23 25
         if(photoList.size()==0){
24 26
             sessionView.showEmptyView();
25 27
         }else{
26 28
             sessionView.showPhotoRecyclerView();
29
+            for(PhotoBean bean : photoList){
30
+                sessionView.addNewPhoto(bean);
31
+            }
27 32
         }
28 33
         interactor.startSession();
29 34
     }