minor fixes
This commit is contained in:
parent
cfd5051c69
commit
6b299f6c86
2 changed files with 24 additions and 18 deletions
|
@ -103,12 +103,10 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler {
|
|||
Glide.with(activity).clear(target);
|
||||
} else {
|
||||
ContentResolver cr = activity.getContentResolver();
|
||||
try (InputStream is = cr.openInputStream(uri)) {
|
||||
if (is != null) {
|
||||
data = getBytes(is);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && (MimeTypes.HEIC.equals(mimeType) || MimeTypes.HEIF.equals(mimeType))) {
|
||||
// as of Flutter v1.15.17, Dart Image.memory cannot decode HEIF/HEIC images
|
||||
// so we convert the image using Android native decoder
|
||||
try {
|
||||
ImageDecoder.Source source = ImageDecoder.createSource(cr, uri);
|
||||
Bitmap bitmap = ImageDecoder.decodeBitmap(source);
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
|
@ -116,13 +114,21 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler {
|
|||
// Bitmap.CompressFormat.PNG is slower than JPEG
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, stream);
|
||||
data = stream.toByteArray();
|
||||
} catch (IOException e) {
|
||||
result.error("getImage-decode-exception", "failed to decode image from uri=" + uri, e.getMessage());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
try (InputStream is = cr.openInputStream(uri)) {
|
||||
if (is != null) {
|
||||
data = getBytes(is);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
result.error("getImage-image-exception", "failed to get image from uri=" + uri, e.getMessage());
|
||||
result.error("getImage-read-exception", "failed to get image from uri=" + uri, e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data != null) {
|
||||
result.success(data);
|
||||
|
|
|
@ -56,7 +56,7 @@ class AvesVideoState extends State<AvesVideo> {
|
|||
..clear();
|
||||
}
|
||||
|
||||
bool isPlayable(IjkStatus status) => [IjkStatus.prepared, IjkStatus.playing, IjkStatus.pause, IjkStatus.complete].contains(status);
|
||||
bool isPlayable(IjkStatus status) => controller != null && [IjkStatus.prepared, IjkStatus.playing, IjkStatus.pause, IjkStatus.complete].contains(status);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
|
Loading…
Reference in a new issue