这里是UTS代码
import Manifest from 'android.Manifest';
import TargetApi from 'android.annotation.TargetApi';
import Activity from 'android.app.Activity';
import Intent from 'android.content.Intent';
import PackageManager from 'android.content.pm.PackageManager';
import Bitmap from 'android.graphics.Bitmap';
import Uri from 'android.net.Uri';
import AsyncTask from 'android.os.AsyncTask';
import Build from 'android.os.Build';
import Bundle from 'android.os.Bundle';
import MediaStore from 'android.provider.MediaStore';
import ActivityCompat from 'androidx.core.app.ActivityCompat';
import FileProvider from 'androidx.core.content.FileProvider';
import AppCompatActivity from 'androidx.appcompat.app.AppCompatActivity';
import DisplayMetrics from 'android.util.DisplayMetrics';
import Log from 'android.util.Log';
import View from 'android.view.View';
import ImageView from 'android.widget.ImageView';
import Toast from 'android.widget.Toast';
import R from 'uts.sdk.modules.fzImageEdit.R';
import EditImageActivity from 'com.xinlan.imageeditlibrary.editimage.EditImageActivity';
import BitmapUtils from 'com.xinlan.imageeditlibrary.editimage.utils.BitmapUtils';
import File from 'java.io.File';
export class RHFimage {
static getEdit(options : UTSJSONObject, callback : (res: UTSJSONObject ) => void) {
let ACTION_REQUEST_EDITIMAGE:Int = 9;
let path = options['path'] as string;
console.log(path)
let outputFile:File = new FileUtils.genEditFile();
let savepath = outputFile.getAbsolutePath()
console.log(savepath)
EditImageActivity.start(UTSAndroid.getUniActivity()!.startActivityForResult,path,savepath,ACTION_REQUEST_EDITIMAGE);
}
}
UTSAndroid.onAppActivityResult((requestCode: Int, resultCode: Int, data?: Intent) => {
console.log("测试数据")
console.log(data)
console.log(requestCode)
console.log(resultCode)
// super.onAppActivityResult(requestCode, resultCode, data);
// if(requestCode == RESULT_OK){
// handleEditorImage(data as Intent);
// }else{
// console.log("保存失败")
// // 别的代码发起的请求,不要处理
// }
});
下面是JAVA代码:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK) {
// System.out.println("RESULT_OK");
switch (requestCode) {
case SELECT_GALLERY_IMAGE_CODE://
handleSelectFromAblum(data);
break;
case TAKE_PHOTO_CODE://拍照返回
handleTakePhoto(data);
break;
case ACTION_REQUEST_EDITIMAGE://
handleEditorImage(data);
break;
}// end switch
}
}
赢无翳 (作者)
EditImageActivity.start类里已经封装了startActivityForResult了怎么办呢?EditImageActivity类是封装在AAR里的我看到EditImageActivity类里有这个方法public static void start(Activity context, final String editImagePath, final String outputPath, final int requestCode) {
if (TextUtils.isEmpty(editImagePath)) {
Toast.makeText(context, R.string.no_choose, Toast.LENGTH_SHORT).show();
return;
}
2024-11-20 20:31