fix when reporting error from native platform

This commit is contained in:
Thibault Deckers 2020-06-11 14:59:48 +09:00
parent a6eeba7744
commit a6c7f48799
2 changed files with 16 additions and 9 deletions

View file

@ -112,7 +112,7 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler {
@Override
public void onFailure(Throwable throwable) {
result.error("getImageEntry-failure", "failed to get entry for uri=" + uriString, throwable);
result.error("getImageEntry-failure", "failed to get entry for uri=" + uriString, throwable.getMessage());
}
});
}
@ -141,7 +141,7 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler {
@Override
public void onFailure(Throwable throwable) {
new Handler(Looper.getMainLooper()).post(() -> result.error("rename-failure", "failed to rename", throwable));
new Handler(Looper.getMainLooper()).post(() -> result.error("rename-failure", "failed to rename", throwable.getMessage()));
}
});
}
@ -170,7 +170,7 @@ public class ImageFileHandler implements MethodChannel.MethodCallHandler {
@Override
public void onFailure(Throwable throwable) {
new Handler(Looper.getMainLooper()).post(() -> result.error("rotate-failure", "failed to rotate", throwable));
new Handler(Looper.getMainLooper()).post(() -> result.error("rotate-failure", "failed to rotate", throwable.getMessage()));
}
});
}

View file

@ -123,10 +123,14 @@ class _HomePageState extends State<HomePage> {
switch (action) {
case 'view':
AvesApp.mode = AppMode.view;
await _initViewerEntry(
_viewerEntry = await _initViewerEntry(
uri: intentData['uri'],
mimeType: intentData['mimeType'],
);
if (_viewerEntry == null) {
// fallback to default mode when we fail to retrieve the entry
AvesApp.mode = AppMode.main;
}
break;
case 'pick':
AvesApp.mode = AppMode.pick;
@ -140,11 +144,14 @@ class _HomePageState extends State<HomePage> {
}
}
Future<void> _initViewerEntry({@required String uri, @required String mimeType}) async {
_viewerEntry = await ImageFileService.getImageEntry(uri, mimeType);
// cataloguing is essential for geolocation and video rotation
await _viewerEntry.catalog();
unawaited(_viewerEntry.locate());
Future<ImageEntry> _initViewerEntry({@required String uri, @required String mimeType}) async {
final entry = await ImageFileService.getImageEntry(uri, mimeType);
if (entry != null) {
// cataloguing is essential for geolocation and video rotation
await entry.catalog();
unawaited(entry.locate());
}
return entry;
}
@override