fix:修复分享时bitmap可能为空导致的崩溃问题;

master
yangbingqiao 2022-04-15 19:16:35 +08:00
parent a14045ca6d
commit 3c8bcea19e
1 changed files with 7 additions and 5 deletions

View File

@ -23,12 +23,12 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import org.json.JSONObject; import org.json.JSONObject;
import java.io.ByteArrayOutputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.concurrent.CountDownLatch; import java.util.concurrent.CountDownLatch;
import java.io.ByteArrayOutputStream;
import io.flutter.plugin.common.MethodChannel; import io.flutter.plugin.common.MethodChannel;
@ -63,10 +63,12 @@ public class AppletHandlerModule extends BaseApi {
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("appletInfo", GsonUtil.gson.fromJson(s, new TypeToken<Map<String, Object>>() { params.put("appletInfo", GsonUtil.gson.fromJson(s, new TypeToken<Map<String, Object>>() {
}.getType())); }.getType()));
ByteArrayOutputStream baos = new ByteArrayOutputStream(); if (bitmap != null) {
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos); ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] data = baos.toByteArray(); bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
params.put("bitmap", data); byte[] data = baos.toByteArray();
params.put("bitmap", data);
}
handler.post(() -> { handler.post(() -> {
channel.invokeMethod("extensionApi:forwardApplet", params, new MethodChannel.Result() { channel.invokeMethod("extensionApi:forwardApplet", params, new MethodChannel.Result() {
@Override @Override