95
     public byte[] send(boolean isCompress) throws Exception {
76 96
         initConnection();
77 97
         conn.connect();
@@ -118,6 +138,27 @@ public class PhotoUploadUtils {
118 138
             ds.writeBytes(encode(value) + "\r\n");
119 139
         }
120 140
     }
141
+
142
+    //文件数据
143
+    private void writeThumbFileParams() throws Exception {
144
+        Set<String> keySet = fileparams.keySet();
145
+        for (Iterator<String> it = keySet.iterator(); it.hasNext();) {
146
+            String name = it.next();
147
+            File value = fileparams.get(name);
148
+            ds.writeBytes("--" + boundary + "\r\n");
149
+            ds.writeBytes("Content-Disposition: form-data; name=\"" + name
150
+                    + "\"; filename=\"" + encode(value.getName()) + "\"\r\n");
151
+            ds.writeBytes("Content-Type: " + getContentType(value) + "\r\n");
152
+            ds.writeBytes("\r\n");
153
+            byte[] bmp = getThumbBitmapBytes(value);
154
+            ds.write(bmp);
155
+            LogHelper.d("czy","upload final file length="+bmp.length);
156
+            LogHelper.d("czy","Upload bitmap size:"+bmp.length);
157
+            ds.writeBytes("\r\n");
158
+//            saveUploadFile(value,bmp);
159
+        }
160
+    }
161
+
121 162
     //文件数据
122 163
     private void writeFileParams() throws Exception {
123 164
         Set<String> keySet = fileparams.keySet();
@@ -214,6 +255,18 @@ public class PhotoUploadUtils {
214 255
     }
215 256
 
216 257
     //把文件转换成字节数组
258
+    private byte[] getThumbBitmapBytes(File f) throws Exception {
259
+        int uploadWidth = UPLOAD_THUMB_PHOTO_WIDTH;
260
+        int uploadHeight = UPLOAD_THUMB_PHOTO_HEIGHT;
261
+        int uploadQuality = 90;
262
+        LogHelper.d("czy","upload default width = "+uploadWidth+"uploadQuality="+uploadQuality);
263
+        Bitmap bmp = ImageUtils.decodeBitmapWithSize(f.getAbsolutePath(), uploadWidth,uploadHeight);
264
+        ByteArrayOutputStream baos = new ByteArrayOutputStream();
265
+        bmp.compress(Bitmap.CompressFormat.JPEG, uploadQuality, baos);
266
+        return baos.toByteArray();
267
+    }
268
+
269
+    //把文件转换成字节数组
217 270
     private byte[] getBytes(File f) throws Exception {
218 271
         FileInputStream in = new FileInputStream(f);
219 272
         ByteArrayOutputStream out = new ByteArrayOutputStream();

+ 5 - 2
app/src/main/java/ai/pai/lensman/service/UploadTask.java

@@ -15,7 +15,7 @@ import ai.pai.lensman.utils.UrlContainer;
15 15
 
16 16
 public class UploadTask extends AsyncTask<Void, Integer, Boolean> {
17 17
 
18
-    private static final String TAG = "UploadTask";
18
+    private static final String TAG = "czy";
19 19
     private PhotoBean bean;
20 20
     private OnPhotoUploadListener listener;
21 21
 
@@ -41,13 +41,16 @@ public class UploadTask extends AsyncTask<Void, Integer, Boolean> {
41 41
                     photoUploadUtils.addTextParameter("photo_id", String.valueOf(bean.photoId));
42 42
                     photoUploadUtils.addTextParameter("nickname",Preferences.getInstance().getUserName());
43 43
                     photoUploadUtils.addTextParameter("lensman_type",bean.lensmanType);
44
-                    String result = new String(photoUploadUtils.send(), "UTF-8");
44
+                    String result = new String(bean.priority == 1 ? photoUploadUtils.sendThumb():photoUploadUtils.send(), "UTF-8");
45 45
                     JSONObject resultObj = new JSONObject(result);
46 46
                     if (resultObj.getInt("status") == 200) {
47 47
                         LogHelper.d(TAG, "上传 UploadTask upload result ok ");
48 48
                         return true;
49
+                    }else {
50
+                        LogHelper.d(TAG, "上传 UploadTask status not 200  "+result);
49 51
                     }
50 52
                 } else {
53
+                    LogHelper.d(TAG, "上传 UploadTask本地文件不存在 ");
51 54
                     return false;
52 55
                 }
53 56
 

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

@@ -100,7 +100,7 @@ public class PhotoRecyclerAdapter extends RecyclerView.Adapter<PhotoRecyclerAdap
100 100
         holder.photo.setLayoutParams(lp);
101 101
         long timeLeft = delay - (System.currentTimeMillis() - item.captureTime) / 1000;
102 102
 
103
-        if (timeLeft < 0) {
103
+        if (timeLeft < 0 || item.uploadStatus!=PhotoBean.UploadStatus.STATUS_NO_BEGIN) {
104 104
             item.canDelete = false;
105 105
             if (item.uploadStatus == PhotoBean.UploadStatus.STATUS_ERROR) {
106 106
                 holder.uploadStatusText.setText(context.getString(R.string.upload_error) + "," + context.getString(R.string.click_to_retry));

+ 3 - 0
app/src/main/java/ai/pai/lensman/session/SessionPresenter.java

@@ -109,6 +109,9 @@ public class SessionPresenter implements SessionContract.Presenter, SessionInter
109 109
         }
110 110
         LogHelper.d(TAG,"onSessionPhotoCaptured "+bean);
111 111
         bean.groupId = groupId;
112
+        if(photoList.size()==0){
113
+            bean.priority = 1;
114
+        }
112 115
         DBService.getInstance().addPhotoBean(bean);
113 116
         sessionView.showPhotoRecyclerView();
114 117
         sessionView.addNewPhoto(bean);

kodo - Gogs: Go Git Service

暂无描述

Brightcells: 018d52f61d Update package django_xxx 8 年之前
..
migrations 4547c709bf Add api get_server_time_api 9 年之前
__init__.py 4547c709bf Add api get_server_time_api 9 年之前
admin.py 4547c709bf Add api get_server_time_api 9 年之前
models.py 4547c709bf Add api get_server_time_api 9 年之前
server_views.py 018d52f61d Update package django_xxx 8 年之前
tests.py 4547c709bf Add api get_server_time_api 9 年之前
views.py 4547c709bf Add api get_server_time_api 9 年之前