|
@ -58,6 +58,7 @@ import com.electric.chargingpile.util.Bimp;
|
58
|
58
|
import com.electric.chargingpile.util.CommonParams;
|
59
|
59
|
import com.electric.chargingpile.util.DateUtils;
|
60
|
60
|
import com.electric.chargingpile.util.DensityUtil;
|
|
61
|
import com.electric.chargingpile.util.FileUtils;
|
61
|
62
|
import com.electric.chargingpile.util.ImageItem;
|
62
|
63
|
import com.electric.chargingpile.util.JsonUtils;
|
63
|
64
|
import com.electric.chargingpile.util.LoadingDialog;
|
|
@ -71,6 +72,10 @@ import com.upyun.library.common.ParallelUploader;
|
71
|
72
|
import com.upyun.library.common.UploadEngine;
|
72
|
73
|
import com.upyun.library.listener.UpCompleteListener;
|
73
|
74
|
import com.upyun.library.listener.UpProgressListener;
|
|
75
|
import com.zhihu.matisse.Matisse;
|
|
76
|
import com.zhihu.matisse.MimeType;
|
|
77
|
import com.zhihu.matisse.engine.impl.GlideEngine;
|
|
78
|
import com.zhihu.matisse.internal.entity.CaptureStrategy;
|
74
|
79
|
import com.zhy.http.okhttp.OkHttpUtils;
|
75
|
80
|
import com.zhy.http.okhttp.callback.StringCallback;
|
76
|
81
|
|
|
@ -145,6 +150,8 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
145
|
150
|
private ProgressDialog uploadDialog;
|
146
|
151
|
private PublishItemSerializable intentData;
|
147
|
152
|
|
|
153
|
public static final int REQUEST_CODE_CHOOSE = 342;
|
|
154
|
|
148
|
155
|
|
149
|
156
|
@Override
|
150
|
157
|
protected void onCreate(Bundle savedInstanceState) {
|
|
@ -175,11 +182,6 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
175
|
182
|
if (parallelUploader == null) {
|
176
|
183
|
parallelUploader = new ParallelUploader();
|
177
|
184
|
}
|
178
|
|
//图文路径
|
179
|
|
// String p = "/d/file/liaoliao/img/" + y + "/" + m + "/" + d;
|
180
|
|
//视频路径
|
181
|
|
// p = "/d/file/liaoliao/video/" + y + "/" + m + "/" + d;
|
182
|
|
|
183
|
185
|
}
|
184
|
186
|
|
185
|
187
|
private void initView() {
|
|
@ -209,12 +211,10 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
209
|
211
|
}
|
210
|
212
|
}
|
211
|
213
|
|
212
|
|
// dialog.show();
|
213
|
214
|
MobclickAgent.onEvent(getApplicationContext(), "1035");
|
214
|
215
|
uploadDialog.show();
|
215
|
216
|
//获取又拍云数据
|
216
|
217
|
getYouPaiData();
|
217
|
|
|
218
|
218
|
}
|
219
|
219
|
});
|
220
|
220
|
rl_point = (RelativeLayout) findViewById(R.id.rl_point);
|
|
@ -253,27 +253,6 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
253
|
253
|
et_context.setSelection(500);
|
254
|
254
|
}
|
255
|
255
|
|
256
|
|
// if (containsEmoji(s)) {
|
257
|
|
// tv_right.setEnabled(false);
|
258
|
|
// tv_right.setTextColor(getResources().getColor(R.color.ui_68));
|
259
|
|
// ToastUtil.showToast(getApplicationContext(), "不支持输入表情", Toast.LENGTH_SHORT);
|
260
|
|
// return;
|
261
|
|
// }
|
262
|
|
// if (s.length() > 500) {
|
263
|
|
// tv_right.setEnabled(false);
|
264
|
|
// tv_right.setBackgroundColor(Color.parseColor("color_9ed3ae"));
|
265
|
|
//// tv_right.setTextColor(getResources().getColor(R.color.ui_68));
|
266
|
|
// ToastUtil.showToast(getApplicationContext(), "输入字数不能超过500", Toast.LENGTH_SHORT);
|
267
|
|
// return;
|
268
|
|
// }
|
269
|
|
// if (!s.trim().isEmpty() && s.length() > 0 && null != Bimp.tempSelectBitmap && Bimp.tempSelectBitmap.size() > 0) {
|
270
|
|
// tv_right.setEnabled(true);
|
271
|
|
// tv_right.setBackgroundColor(Color.parseColor("#02b637"));
|
272
|
|
// } else {
|
273
|
|
// tv_right.setEnabled(false);
|
274
|
|
// tv_right.setBackgroundColor(Color.parseColor("#9ed3ae"));
|
275
|
|
// }
|
276
|
|
|
277
|
256
|
if (TextUtils.isEmpty(s))
|
278
|
257
|
publishtopic_word_num.setText("0");
|
279
|
258
|
else
|
|
@ -298,8 +277,6 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
298
|
277
|
for (int i = 0; i < Bimp.tempSelectBitmap.size(); i++) {
|
299
|
278
|
|
300
|
279
|
ImageItem imageItem = Bimp.tempSelectBitmap.get(i);
|
301
|
|
// String fileNameDir = Bimp.tempSelectBitmap.get(i).getImagePath();
|
302
|
|
// String fileName = fileNameDir.substring(fileNameDir.lastIndexOf("/") + 1);
|
303
|
280
|
if (TextUtils.isEmpty(fileNames)) {
|
304
|
281
|
fileNames = imageItem.fName;
|
305
|
282
|
} else {
|
|
@ -332,7 +309,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
332
|
309
|
for (int i = 0; i < publishCount; i++) {
|
333
|
310
|
String sign = signBeans.get(i).sign;
|
334
|
311
|
String policy = signBeans.get(i).policy;
|
335
|
|
formUpload(Bimp.tempSelectBitmap.get(i).getImagePath(), sign, policy);
|
|
312
|
formUpload(Bimp.tempSelectBitmap.get(i).getFile(), sign, policy);
|
336
|
313
|
}
|
337
|
314
|
}
|
338
|
315
|
} else if ("8010".equals(code)) {
|
|
@ -509,14 +486,14 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
509
|
486
|
*/
|
510
|
487
|
private void callGallery() {
|
511
|
488
|
MobclickAgent.onEvent(getApplicationContext(), "1024");
|
512
|
|
Log.e(TAG, "callGallery: " + (Bimp.max - Bimp.tempSelectBitmap.size()));
|
513
|
|
//调用第三方图库选择
|
514
|
|
PhotoPicker.builder()
|
515
|
|
.setPhotoCount(PIC_NUM - Bimp.tempSelectBitmap.size())//可选择图片数量
|
516
|
|
.setShowCamera(true)//是否显示拍照按钮
|
517
|
|
.setShowGif(true)//是否显示动态图
|
518
|
|
.setPreviewEnabled(true)//是否可以预览
|
519
|
|
.start(this, PhotoPicker.REQUEST_CODE);
|
|
489
|
Matisse.from(PublishPicTopicActivity.this)
|
|
490
|
.choose(MimeType.of(MimeType.JPEG, MimeType.PNG, MimeType.GIF))
|
|
491
|
.countable(true)
|
|
492
|
.maxSelectable(PIC_NUM - Bimp.tempSelectBitmap.size())
|
|
493
|
.capture(true)
|
|
494
|
.captureStrategy(new CaptureStrategy(true, "com.electric.chargingpile.provider"))
|
|
495
|
.imageEngine(new GlideEngine())
|
|
496
|
.forResult(REQUEST_CODE_CHOOSE);
|
520
|
497
|
}
|
521
|
498
|
|
522
|
499
|
@Override
|
|
@ -534,7 +511,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
534
|
511
|
if (data != null) {
|
535
|
512
|
if (requestCode == 1) {
|
536
|
513
|
//处理调用系统图库
|
537
|
|
} else if (requestCode == PhotoPicker.REQUEST_CODE) {
|
|
514
|
} else if (requestCode == REQUEST_CODE_CHOOSE) {
|
538
|
515
|
MobclickAgent.onEvent(getApplicationContext(), "1026");
|
539
|
516
|
//异步方式插入图片
|
540
|
517
|
insertImagesSync(data);
|
|
@ -554,13 +531,14 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
554
|
531
|
@Override
|
555
|
532
|
public void subscribe(ObservableEmitter<String> subscriber) throws Exception {
|
556
|
533
|
try {
|
557
|
|
ArrayList<String> photos = data.getStringArrayListExtra(PhotoPicker.KEY_SELECTED_PHOTOS);
|
558
|
|
//可以同时插入多张图片
|
|
534
|
List<Uri> uriList = Matisse.obtainResult(data);
|
559
|
535
|
int i = 0;
|
560
|
|
for (String imagePath : photos) {
|
|
536
|
for (Uri uri: uriList) {
|
561
|
537
|
i++;
|
562
|
|
Log.e(TAG, "call: imagePath " + imagePath);
|
563
|
|
Bitmap bitmap = BitmapFactory.decodeFile(imagePath);//压缩图片
|
|
538
|
Bitmap bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
|
|
539
|
File file = FileUtils.from(PublishPicTopicActivity.this, uri);
|
|
540
|
|
|
541
|
bitmap = FileUtils.rotateIfRequired(file, bitmap);
|
564
|
542
|
bitmap = imageZoom(bitmap);
|
565
|
543
|
ImageItem takePhoto = new ImageItem();
|
566
|
544
|
String deviceId = JPushInterface.getUdid(MainApplication.context);
|
|
@ -572,17 +550,15 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
572
|
550
|
}
|
573
|
551
|
takePhoto.fName += "_00" + i;
|
574
|
552
|
|
575
|
|
String suffix = imagePath.substring(imagePath.lastIndexOf(".") + 1);
|
|
553
|
String filePath = file.getAbsolutePath();
|
|
554
|
String suffix = filePath.substring(filePath.lastIndexOf(".") + 1);
|
576
|
555
|
takePhoto.fName += "." + suffix;
|
577
|
|
|
578
|
556
|
takePhoto.setBitmap(bitmap);
|
579
|
|
takePhoto.setImagePath(imagePath);
|
580
|
|
|
|
557
|
takePhoto.setFile(file);
|
581
|
558
|
Bimp.tempSelectBitmap.add(takePhoto);
|
582
|
|
subscriber.onNext(imagePath);
|
|
559
|
subscriber.onNext("");
|
583
|
560
|
}
|
584
|
561
|
subscriber.onComplete();
|
585
|
|
|
586
|
562
|
} catch (Exception e) {
|
587
|
563
|
e.printStackTrace();
|
588
|
564
|
subscriber.onError(e);
|
|
@ -885,13 +861,10 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
885
|
861
|
/**
|
886
|
862
|
* 表单上传
|
887
|
863
|
*
|
888
|
|
* @param SAMPLE_PIC_FILE
|
889
|
864
|
* @param sign
|
890
|
865
|
* @param policyServer
|
891
|
866
|
*/
|
892
|
|
private void formUpload(String SAMPLE_PIC_FILE, String sign, String policyServer) {
|
893
|
|
File temp = new File(SAMPLE_PIC_FILE);
|
894
|
|
|
|
867
|
private void formUpload(File file, String sign, String policyServer) {
|
895
|
868
|
// //进度回调,可为空
|
896
|
869
|
UpProgressListener progressListener = new UpProgressListener() {
|
897
|
870
|
@Override
|
|
@ -929,7 +902,7 @@ public class PublishPicTopicActivity extends Activity implements OnClickListener
|
929
|
902
|
};
|
930
|
903
|
|
931
|
904
|
//表单上传(服务器签名方式)
|
932
|
|
UploadEngine.getInstance().formUpload(temp, policyServer, OPERATER, sign, completeListener,
|
|
905
|
UploadEngine.getInstance().formUpload(file, policyServer, OPERATER, sign, completeListener,
|
933
|
906
|
progressListener);
|
934
|
907
|
|
935
|
908
|
}
|