Commit 4785e81b authored by 林生雨's avatar 林生雨

commit

parent b30a2a42
This diff is collapsed.
......@@ -52,6 +52,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
var premissionHandler: PermissionListener? = null
var nativeImage: File? = null
const val IMAGE_PICKER = "scan_image_picker"
const val ADD_IMAGE_CACHE = "ADD_IMAGE_CACHE"
const val NATIVE_CAMERA = "native_camera"
const val QUIT_PAGE = "quit_page"
const val AI_CAMERA = "ai_camera"
......@@ -128,11 +129,11 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// true;
// }
registrar.addActivityResultListener { requestCode, resultCode, intent ->
Log.e("lsy"," LSY ACTIVITY RESULT ${nativeImage?.exists()} ${requestCode} ")
Log.e("lsy", " LSY ACTIVITY RESULT ${nativeImage?.exists()} ${requestCode} ")
when (requestCode) {
CAMERA_REQUEST_CODE -> {
if (resultCode == RESULT_OK) {
android.util.Log.e("lsy"," RESULT OKKKKK ")
android.util.Log.e("lsy", " RESULT OKKKKK ")
if (nativeImage != null && nativeImage!!.exists()) {
ImageRespository.getInstance().scareImg(nativeImage!!.absolutePath).subscribe({
val map = HashMap<String, Any>()
......@@ -140,7 +141,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
map.put("path", it.second)
map.put("isVideo", "F")
map.put("folderName", "GengmeiAlbum")
android.util.Log.e("lsy"," RESULT MAPPP ")
android.util.Log.e("lsy", " RESULT MAPPP ")
// try {
// MediaStore.Images.Media.insertImage(resign.context().applicationContext.getContentResolver(),
......@@ -199,9 +200,9 @@ class GengmeiFlutterPlugin : MethodCallHandler {
// intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(nativeImage));
// }
val broad = Intent("com.alpha.flutter.album")
broad.putExtra("PATH",nativeImage!!.absolutePath)
broad.putExtra("providerString",providerString)
broad.putExtra("CAMERA_REQUEST_CODE",CAMERA_REQUEST_CODE)
broad.putExtra("PATH", nativeImage!!.absolutePath)
broad.putExtra("providerString", providerString)
broad.putExtra("CAMERA_REQUEST_CODE", CAMERA_REQUEST_CODE)
resign.sendBroadcast(broad)
// resign.activity().startActivityForResult(intent, CAMERA_REQUEST_CODE);
}
......@@ -214,8 +215,21 @@ class GengmeiFlutterPlugin : MethodCallHandler {
val result = resultKey;
ScanImage(result)
}
ADD_IMAGE_CACHE -> {
val result = resultKey;
val map = call.arguments as HashMap<String, String>
ImageRespository.getInstance().addCacheItem(
if (map["isVideo"] == "T") true else false,
map["path"]!!,
map["realPath"]!!,
map["folderName"]!!,
map["during"]!!.toLong()
)
ResultManager.getInstance().resultSuccess(result, true)
}
NATIVE_CAMERA -> {
gotoNativeCameraKey=resultKey;
gotoNativeCameraKey = resultKey;
gotoNativeCamera(call.argument<String>("authority")!!)
}
SAVE_STRING_SHARED -> {
......@@ -327,7 +341,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
path?.run {
val intent = Intent(resign, VideoActivity::class.java)
intent.putExtra("PATH", this)
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK )
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
resign.startActivity(intent)
}
}
......@@ -337,7 +351,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
path?.run {
val intent = Intent(resign, PreviewActivity::class.java)
intent.putExtra("PATH", this)
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK )
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
resign.startActivity(intent)
ResultManager.getInstance().resultSuccess(result, true)
// ImageRespository.getInstance().getPreviewImg(resign.context().applicationContext,this, 800.0f).subscribe({
......@@ -389,7 +403,7 @@ class GengmeiFlutterPlugin : MethodCallHandler {
@TargetApi(Build.VERSION_CODES.M)
private fun checkPermission(listener: PermissionListener) {
premissionHandler=listener
premissionHandler = listener
listener.OK()
// val activity = resign
// val writePremission = activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)
......
......@@ -106,6 +106,21 @@ class ImageRespository {
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
}
fun addCacheItem(isVideo: Boolean, path: String, realPath: String, folderName: String
, during: Long) {
val itemMap = HashMap<String, Any>()
itemMap.put("folderName", folderName)
itemMap.put("path", path)
itemMap.put("realPath", realPath)
if (isVideo) {
itemMap.put("isVideo", "T")
itemMap.put("during", "${during}")
} else {
itemMap.put("isVideo", "F")
}
recordImageListMap.add(0, itemMap)
}
fun savePreviewImg(context: Context, listener: savePreviewListener) {
val start = System.currentTimeMillis();
val needSize = recordImageListMap.size;
......@@ -119,7 +134,7 @@ class ImageRespository {
// if (it["realPath"] == null) {
// continue
// }
Log.e("lsy","index ${index}")
Log.e("lsy", "index ${index}")
val any = it["path"]
val realPath = it["realPath"] as String
if (any != null && !TextUtils.isEmpty(any as String)) {
......@@ -303,7 +318,7 @@ class ImageRespository {
// )
// .setName(getFileName(realPath)!!)
// .get(realPath);
it["path"] = MyUtil.scareImg(realPath, 200f, fileDir + "/" + getFileName(realPath)!! + ".png", 75,degree)
it["path"] = MyUtil.scareImg(realPath, 200f, fileDir + "/" + getFileName(realPath)!! + ".png", 75, degree)
// Log.e("lsy", "封面照片 ${get.absolutePath}");
}
}
......@@ -331,7 +346,7 @@ class ImageRespository {
}
}
finalList["IsGengmeiAlbumAllImages"] = imageListMap;
return finalList;
return finalList
}
fun getPreviewImg(context: Context, realPath: String, scareSize: Float): Observable<String> {
......@@ -343,7 +358,7 @@ class ImageRespository {
// val path = Luban.with(context).setTargetDir(fileDir).quality(100)
// .setName(getFileName(realPath)!! + "_preview.png")
// .get(realPath);
val path = MyUtil.scareImg(realPath, scareSize, copyPath, 90,0);
val path = MyUtil.scareImg(realPath, scareSize, copyPath, 90, 0);
it.onNext(path)
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
}
......
......@@ -25,6 +25,8 @@ Map<String, List<ScanImageItem>> changData(Map images) {
return newMap;
}
const String ADD_IMAGE_CACHE = "ADD_IMAGE_CACHE";
class ScanImagePlugn {
static Future<Map<String, List<ScanImageItem>>> scanImages(
MethodChannel channel) async {
......@@ -38,6 +40,17 @@ class ScanImagePlugn {
.invokeMethod("native_camera", {"authority": authority});
}
static Future<bool> addAlbumItem(bool isVideo, String path, String realPath,
String folderName, int during, MethodChannel channel) async {
return await channel.invokeMethod(ADD_IMAGE_CACHE, {
"isVideo": isVideo ? "T" : "F",
"path": path,
"realPath": realPath,
"folderName": folderName,
"during": "${during}"
});
}
static Future<String> scareImg(
MethodChannel channel, String path, int scare) async {
return await channel
......
......@@ -31,6 +31,8 @@ class SharedPlugin {
.invokeMethod(SAVE_INT_SHARED, {"key": key, "value": value});
}
static Future<bool> saveDouble(
String key, double value, MethodChannel channel) async {
return await channel
......
......@@ -39,6 +39,12 @@ class GengmeiFlutterPlugin {
return await ScanImagePlugn.playAlbumVideo(_channel, path);
}
static Future<bool> addAlbumItem(bool isVideo, String path, String realPath,
String folderName, int during) async {
return await ScanImagePlugn.addAlbumItem(
isVideo, path, realPath, folderName, during, _channel);
}
static Future<bool> quitPage() async {
return await ScanImagePlugn.quitPage(_channel);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment