">
+ fOut.write(buffer,0,len);
+ fOut.flush();
+ }
+ fOut.flush();
+ LogHelper.d("czy","保存照片到本地,图片保存至"+file.getAbsolutePath()+"图片大小为"+file.length()+"字节\n\n");
+ }
+ return true;
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try{
+ inStream.close();
+ conn.disconnect();
+ fOut.close();
+ }catch (Exception e){
+ e.printStackTrace();
+ }
+ }
+ return false;
+ }
+
+ @Override
+ protected void onPostExecute(Boolean result) {
+ super.onPostExecute(result);
+ if (result) {
+ listener.onSessionPhotoCaptured(photoBean);
+ }else{
+ new SavePhotoTask(photoBean).executeOnExecutor(ThreadExecutor.getInstance().getExecutor(),photoBean);
+ }
+ }
+ }
+
+
public void endSession(){
cancelTask(sessionEndTask);
HashMap<String,String> params = new HashMap<>();
@@ -43,12 +43,10 @@ public class SessionPresenter implements SessionContract.Presenter,SessionIntera |
||
| 43 | 43 |
} |
| 44 | 44 |
|
| 45 | 45 |
@Override |
| 46 |
- public void onSessionPhotoCaptured(final ArrayList<PhotoBean> beans) {
|
|
| 46 |
+ public void onSessionPhotoCaptured(final PhotoBean bean) {
|
|
| 47 | 47 |
sessionView.showPhotoRecyclerView(); |
| 48 |
- sessionView.showToast("发现新增照片"+beans.size()+"张");
|
|
| 49 |
- for (PhotoBean bean : beans){
|
|
| 50 |
- sessionView.addNewPhoto(bean); |
|
| 51 |
- } |
|
| 48 |
+ sessionView.showToast("发现新增照片");
|
|
| 49 |
+ sessionView.addNewPhoto(bean); |
|
| 52 | 50 |
} |
| 53 | 51 |
|
| 54 | 52 |
@Override |
@@ -147,7 +147,7 @@ public class UploadActivity extends BaseActivity implements UploadContract.View |
||
| 147 | 147 |
sessionBean.lensmanId = Preferences.getInstance(this).getLensManId(); |
| 148 | 148 |
sessionBean.sessionDate=20160813; |
| 149 | 149 |
sessionBean.sessionSeq = new Random().nextInt(10000); |
| 150 |
- sessionBean.sessionId ="chengzhenyu_test"; |
|
| 150 |
+ sessionBean.sessionId ="chengzhenyu_test"+sessionBean.sessionSeq; |
|
| 151 | 151 |
Intent intent = new Intent(this, SessionActivity.class); |
| 152 | 152 |
intent.putExtra("session",sessionBean);
|
| 153 | 153 |
startActivity(intent); |
@@ -0,0 +1,16 @@ |
||
| 1 |
+package ai.pai.lensman.utils; |
|
| 2 |
+ |
|
| 3 |
+import android.os.Environment; |
|
| 4 |
+ |
|
| 5 |
+/** |
|
| 6 |
+ * Created by chengzhenyu on 2016/8/13. |
|
| 7 |
+ */ |
|
| 8 |
+public class Constants {
|
|
| 9 |
+ |
|
| 10 |
+ public static final String APP_ROOT_DIR = Environment.getExternalStorageDirectory() + "/lensman"; |
|
| 11 |
+ public static final String APP_IMAGE_DIR = APP_ROOT_DIR + "/image"; |
|
| 12 |
+ public static final String ORIGIN_DIR_NAME = "origin"; |
|
| 13 |
+ public static final String THUMBNAIL_DIR_NAME = "thumbnail"; |
|
| 14 |
+ public static final String TMP_DIR_NAME = "tmp"; |
|
| 15 |
+ |
|
| 16 |
+} |
@@ -0,0 +1,40 @@ |
||
| 1 |
+package ai.pai.lensman.utils; |
|
| 2 |
+ |
|
| 3 |
+import android.graphics.Bitmap; |
|
| 4 |
+import android.widget.ImageView; |
|
| 5 |
+ |
|
| 6 |
+import com.nostra13.universalimageloader.core.DisplayImageOptions; |
|
| 7 |
+import com.nostra13.universalimageloader.core.ImageLoader; |
|
| 8 |
+import com.nostra13.universalimageloader.core.assist.ImageScaleType; |
|
| 9 |
+import com.nostra13.universalimageloader.core.imageaware.ImageViewAware; |
|
| 10 |
+ |
|
| 11 |
+public class ImageLoaderUtils {
|
|
| 12 |
+ |
|
| 13 |
+ /** |
|
| 14 |
+ * display local image |
|
| 15 |
+ * @param uri |
|
| 16 |
+ * @param imageView |
|
| 17 |
+ * @param options |
|
| 18 |
+ */ |
|
| 19 |
+ public static void displayLocalImage(String uri, ImageView imageView, DisplayImageOptions options) {
|
|
| 20 |
+ ImageLoader.getInstance().displayImage("file://" + uri, new ImageViewAware(imageView), options, null, null);
|
|
| 21 |
+ } |
|
| 22 |
+ |
|
| 23 |
+ /** |
|
| 24 |
+ * display Drawable image |
|
| 25 |
+ * @param uri |
|
| 26 |
+ * @param imageView |
|
| 27 |
+ * @param options |
|
| 28 |
+ */ |
|
| 29 |
+ public static void displayDrawableImage(String uri, ImageView imageView, DisplayImageOptions options) {
|
|
| 30 |
+ ImageLoader.getInstance().displayImage("drawable://" + uri, new ImageViewAware(imageView), options, null, null);
|
|
| 31 |
+ } |
|
| 32 |
+ |
|
| 33 |
+ public static DisplayImageOptions getOptions(int drawable) {
|
|
| 34 |
+ return new DisplayImageOptions.Builder() |
|
| 35 |
+ .showImageForEmptyUri(drawable).showImageOnFail(drawable) |
|
| 36 |
+ .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true) |
|
| 37 |
+ .bitmapConfig(Bitmap.Config.RGB_565).imageScaleType(ImageScaleType.IN_SAMPLE_POWER_OF_2).build(); |
|
| 38 |
+ } |
|
| 39 |
+ |
|
| 40 |
+} |