|
|
@@ -1,8 +1,11 @@
|
|
|
package com.kfzs.duanduan.react.upfile;
|
|
|
|
|
|
|
|
|
+import android.graphics.Bitmap;
|
|
|
+
|
|
|
import com.nanchen.compresshelper.CompressHelper;
|
|
|
import com.sheep.jiuyan.samllsheep.SheepApp;
|
|
|
+import com.sheep.jiuyan.samllsheep.utils.G;
|
|
|
import com.zhy.http.okhttp.OkHttpUtils;
|
|
|
import com.zhy.http.okhttp.callback.Callback;
|
|
|
|
|
|
@@ -59,7 +62,12 @@ public class UpFileUtils {
|
|
|
if (index < photos.size()) {
|
|
|
File file;
|
|
|
if ((file = new File(photos.get(index))).exists()) {
|
|
|
- File newFile = CompressHelper.getDefault(SheepApp.getInstance()).compressToFile(file);
|
|
|
+ File newFile = new CompressHelper.Builder(SheepApp.getInstance())
|
|
|
+ .setMaxWidth(G.WIDTH) // 默认最大宽度为720
|
|
|
+ .setMaxHeight(G.HEIGHT) // 默认最大高度为960
|
|
|
+ .setQuality(80) // 默认压缩质量为80
|
|
|
+ .setCompressFormat(Bitmap.CompressFormat.JPEG) // 设置默认压缩为jpg格式
|
|
|
+ .build().compressToFile(file);
|
|
|
// org.xutils.common.util.FileUtil.copy(newFile.getAbsolutePath(), ClassFileHelper.DIR+"/1.png");
|
|
|
OkHttpUtils.post()
|
|
|
.addFile("uploadfile", "1.png", newFile)//
|