Commit f78cc649b83f48e36f478366498f20884c189235

Authored by YangShuai
1 parent 3dc5665b

1 修改编译版本测试,无法上传图片问题

config.gradle
@@ -21,7 +21,7 @@ ext { @@ -21,7 +21,7 @@ ext {
21 //编译方式 21 //编译方式
22 debug : false, 22 debug : false,
23 //版本号 23 //版本号
24 - version: "1.0.10-beta1", 24 + version: "1.0.10-beta1.1",
25 //Lib库前缀 25 //Lib库前缀
26 packeg : "com.cnlive.module", 26 packeg : "com.cnlive.module",
27 //Lib库名称 27 //Lib库名称
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/UploadLogic.java
@@ -2,6 +2,7 @@ package com.cnlive.moudle.pedometer.upload; @@ -2,6 +2,7 @@ package com.cnlive.moudle.pedometer.upload;
2 2
3 import android.content.Context; 3 import android.content.Context;
4 import android.media.MediaMetadataRetriever; 4 import android.media.MediaMetadataRetriever;
  5 +import android.os.Build;
5 import android.os.Environment; 6 import android.os.Environment;
6 import android.text.TextUtils; 7 import android.text.TextUtils;
7 import android.util.Log; 8 import android.util.Log;
@@ -335,9 +336,25 @@ public class UploadLogic { @@ -335,9 +336,25 @@ public class UploadLogic {
335 this.imageHeight = imageHeight; 336 this.imageHeight = imageHeight;
336 } 337 }
337 } 338 }
  339 +//
  340 +// private static String getPath(String cachePath) {
  341 +// String path = Environment.getExternalStorageDirectory() + cachePath;
  342 +// File file = new File(path);
  343 +// if (file.mkdirs()) {
  344 +// return path;
  345 +// }
  346 +// return path;
  347 +// }
338 348
339 - private static String getPath(String cachePath) { 349 + /**
  350 + * 鲁班压缩后图片的存储位置
  351 + *
  352 + * @return
  353 + */
  354 + public static String getPath(Context context, String cachePath) {
340 String path = Environment.getExternalStorageDirectory() + cachePath; 355 String path = Environment.getExternalStorageDirectory() + cachePath;
  356 + if (Build.VERSION.SDK_INT >= 29)
  357 + path = context.getExternalFilesDir("").getAbsolutePath();
341 File file = new File(path); 358 File file = new File(path);
342 if (file.mkdirs()) { 359 if (file.mkdirs()) {
343 return path; 360 return path;
@@ -358,11 +375,11 @@ public class UploadLogic { @@ -358,11 +375,11 @@ public class UploadLogic {
358 .action((BaseInfo<UploadAuthData> data, DataCallback<Map<String, Object>> callback) -> 375 .action((BaseInfo<UploadAuthData> data, DataCallback<Map<String, Object>> callback) ->
359 Logic.process(() -> { 376 Logic.process(() -> {
360 Map map = new HashMap(); 377 Map map = new HashMap();
361 - File file = new File(getPath("/strike/cache/") + "share.jpg"); 378 + File file = new File(getPath(context,"/strike/cache/") + "share.jpg");
362 if (file.exists()) { 379 if (file.exists()) {
363 - src = getPath("/strike/cache/") + "share.jpg"; 380 + src = getPath(context,"/strike/cache/") + "share.jpg";
364 } else { 381 } else {
365 - src = getPath("/strike/cache/") + "sharefirst.jpg"; 382 + src = getPath(context,"/strike/cache/") + "sharefirst.jpg";
366 } 383 }
367 map.put("image", src); 384 map.put("image", src);
368 map.put("tocken", data.getData().getToken()); 385 map.put("tocken", data.getData().getToken());
moudle_pedometer/src/main/java/com/cnlive/moudle/pedometer/upload/UploadProvider.java
@@ -224,7 +224,7 @@ public class UploadProvider { @@ -224,7 +224,7 @@ public class UploadProvider {
224 Luban.with(context) 224 Luban.with(context)
225 .load(imageFiles.get(i)) 225 .load(imageFiles.get(i))
226 .ignoreBy(500) 226 .ignoreBy(500)
227 - .setTargetDir(getPath(TYPE_IMAGE_PATH)) 227 + .setTargetDir(getPath(context, TYPE_IMAGE_PATH))
228 .filter(new CompressionPredicate() { 228 .filter(new CompressionPredicate() {
229 @Override 229 @Override
230 public boolean apply(String path) { 230 public boolean apply(String path) {
@@ -248,7 +248,7 @@ public class UploadProvider { @@ -248,7 +248,7 @@ public class UploadProvider {
248 248
249 @Override 249 @Override
250 public void onError(Throwable e) { 250 public void onError(Throwable e) {
251 - Log.e(TAG, "onError: 失败"+e.getMessage() ); 251 + Log.e(TAG, "onError: 失败" + e.getMessage());
252 // TODO 当压缩过程出现问题时调用 252 // TODO 当压缩过程出现问题时调用
253 AlertUtil.showDeftToast(context, "图片压缩失败,请重新上传"); 253 AlertUtil.showDeftToast(context, "图片压缩失败,请重新上传");
254 } 254 }
@@ -298,7 +298,7 @@ public class UploadProvider { @@ -298,7 +298,7 @@ public class UploadProvider {
298 return; 298 return;
299 } 299 }
300 //PLShortVideoTranscoder初始化,三个参数,第一个context,第二个要压缩文件的路径,第三个视频压缩后输出的路径 300 //PLShortVideoTranscoder初始化,三个参数,第一个context,第二个要压缩文件的路径,第三个视频压缩后输出的路径
301 - PLShortVideoTranscoder mShortVideoTranscoder = new PLShortVideoTranscoder(mContext, filepath, getPath(TYPE_VIDEO_PATH) + MD5.getFileMD5(new File(filepath)) + ".mp4"); 301 + PLShortVideoTranscoder mShortVideoTranscoder = new PLShortVideoTranscoder(mContext, filepath, getPath(mContext,TYPE_VIDEO_PATH) + MD5.getFileMD5(new File(filepath)) + ".mp4");
302 MediaMetadataRetriever retr = new MediaMetadataRetriever(); 302 MediaMetadataRetriever retr = new MediaMetadataRetriever();
303 retr.setDataSource(filepath); 303 retr.setDataSource(filepath);
304 String height = retr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); // 视频高度 304 String height = retr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT); // 视频高度
@@ -357,9 +357,25 @@ public class UploadProvider { @@ -357,9 +357,25 @@ public class UploadProvider {
357 8000 * 1000, 357 8000 * 1000,
358 }; 358 };
359 359
  360 +//
  361 +// private static String getPath(String cachePath) {
  362 +// String path = Environment.getExternalStorageDirectory() + cachePath;
  363 +// File file = new File(path);
  364 +// if (file.mkdirs()) {
  365 +// return path;
  366 +// }
  367 +// return path;
  368 +// }
360 369
361 - private static String getPath(String cachePath) { 370 + /**
  371 + * 鲁班压缩后图片的存储位置
  372 + *
  373 + * @return
  374 + */
  375 + public static String getPath(Context context, String cachePath) {
362 String path = Environment.getExternalStorageDirectory() + cachePath; 376 String path = Environment.getExternalStorageDirectory() + cachePath;
  377 + if (Build.VERSION.SDK_INT >= 29)
  378 + path = context.getExternalFilesDir("").getAbsolutePath();
363 File file = new File(path); 379 File file = new File(path);
364 if (file.mkdirs()) { 380 if (file.mkdirs()) {
365 return path; 381 return path;
@@ -432,7 +448,6 @@ public class UploadProvider { @@ -432,7 +448,6 @@ public class UploadProvider {
432 } 448 }
433 449
434 450
435 -  
436 private static List<MultipartBody.Part> getImageParams(List<String> imageFiles, ProgressCallback callback) { 451 private static List<MultipartBody.Part> getImageParams(List<String> imageFiles, ProgressCallback callback) {
437 List<MultipartBody.Part> imageParams = new ArrayList<>(); 452 List<MultipartBody.Part> imageParams = new ArrayList<>();
438 453
@@ -585,7 +600,6 @@ public class UploadProvider { @@ -585,7 +600,6 @@ public class UploadProvider {
585 } 600 }
586 601
587 602
588 -  
589 private static RequestBody getRequestString(String value) { 603 private static RequestBody getRequestString(String value) {
590 RequestBody requestString = RequestBody.create(MediaType.parse("text/plain"), value); 604 RequestBody requestString = RequestBody.create(MediaType.parse("text/plain"), value);
591 return requestString; 605 return requestString;