|
@@ -6,6 +6,11 @@ import android.net.Uri;
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
|
+import com.cooleshow.base.constanst.UploadConstants;
|
|
|
+import com.cooleshow.base.utils.FileUtils;
|
|
|
+import com.cooleshow.base.utils.LogUtils;
|
|
|
+import com.cooleshow.base.utils.helper.upload.UploadHelper;
|
|
|
+
|
|
|
import java.io.File;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.Collection;
|
|
@@ -517,39 +522,79 @@ public class IMCenter {
|
|
|
callback.onAttached(message, uploader);
|
|
|
SightMessage sightMessage = (SightMessage) message.getContent();
|
|
|
String filePath = sightMessage.getLocalPath().getPath();
|
|
|
-// if (isCompressVideo) {
|
|
|
-// final String compressPath = com.rui.common_base.util.FileUtils.getCacheDir(mContext) + File.separator
|
|
|
-// + "VID_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".mp4";
|
|
|
-// VideoCompress.compressVideo(mContext, sightMessage.getLocalPath().getPath(), compressPath, new VideoCompress.CompressListener() {
|
|
|
-// @Override
|
|
|
-// public void onStart() {
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onSuccess() {
|
|
|
-// uploadFile(uploader, compressPath, true);
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onFail() {
|
|
|
-// uploader.error();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @Override
|
|
|
-// public void onProgress(float percent) {
|
|
|
-//
|
|
|
-// }
|
|
|
-// });
|
|
|
-// } else {
|
|
|
-// uploadFile(uploader, filePath, false);
|
|
|
-// }
|
|
|
+ if (isCompressVideo) {
|
|
|
+ final String compressPath = FileUtils.getCacheDir(mContext) + File.separator
|
|
|
+ + "VID_" + new SimpleDateFormat("yyyyMMdd_HHmmss", Locale.CHINA).format(new Date()) + ".mp4";
|
|
|
+ VideoCompress.compressVideo(mContext, sightMessage.getLocalPath().getPath(), compressPath, new VideoCompress.CompressListener() {
|
|
|
+ @Override
|
|
|
+ public void onStart() {
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onSuccess() {
|
|
|
+ uploadFile(uploader, compressPath, true);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onFail() {
|
|
|
+ uploader.error();
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onProgress(float percent) {
|
|
|
+
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ uploadFile(uploader, filePath, false);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
private void uploadFile(final IRongCallback.MediaMessageUploader uploader, final String filePath, final boolean isDelete) {
|
|
|
+ UploadHelper uploadHelper = new UploadHelper(null, UploadConstants.UPLOAD_TYPE_IM);
|
|
|
+ uploadHelper.setUpLoadCallBack(new UploadHelper.UpLoadCallBack() {
|
|
|
+ @Override
|
|
|
+ protected void onSuccess(String url) {
|
|
|
+ if (uploader != null) {
|
|
|
+ uploader.update(100);
|
|
|
+ uploader.success(Uri.parse(url));
|
|
|
+ }
|
|
|
+ //删除临时文件
|
|
|
+ if (isDelete) {
|
|
|
+ new File(filePath).delete();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ protected void onFailure() {
|
|
|
+ if (uploader != null) {
|
|
|
+ uploader.error();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUploadCancel() {
|
|
|
+ super.onUploadCancel();
|
|
|
+ if (uploader != null) {
|
|
|
+ uploader.cancel();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onUploadProgress(double v) {
|
|
|
+ super.onUploadProgress(v);
|
|
|
+ LogUtils.e("onProgress" + v);
|
|
|
+ uploader.update((int) v);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ File file = new File(filePath);
|
|
|
+ uploadHelper.uploadFile(file);
|
|
|
+
|
|
|
// BaseObserver baseObserver = new BaseObserver<FileUploadBean>() {
|
|
|
// @Override
|
|
|
// protected void onStart() {
|
|
@@ -559,13 +604,7 @@ public class IMCenter {
|
|
|
//
|
|
|
// @Override
|
|
|
// protected void onSuccess(FileUploadBean data) {
|
|
|
-// uploader.update(100);
|
|
|
-// uploader.success(Uri.parse(data.getUrl()));
|
|
|
-// //删除临时文件
|
|
|
-// if (isDelete) {
|
|
|
-// new File(filePath).delete();
|
|
|
-// }
|
|
|
-// LOG.e("onSuccess");
|
|
|
+//
|
|
|
// }
|
|
|
//
|
|
|
// @Override
|