diff options
Diffstat (limited to 'src/com/android')
| -rw-r--r-- | src/com/android/gallery3d/app/AbstractGalleryActivity.java | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index b9007d57e..a7c54ee29 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -366,23 +366,32 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext if (uri == null) { return; } - String path = ImageLoader.getLocalPathFromUri(this, uri); - if (path != null) { - path = getLastPathSegment(path); - } else { - path = uri.getLastPathSegment(); - } + String printJobName = getLastPathSegment(uri); PrintHelper printer = new PrintHelper(this); try { - printer.printBitmap(path, uri); + printer.printBitmap(printJobName, uri); } catch (FileNotFoundException fnfe) { Log.e(TAG, "Error printing an image", fnfe); } } - private String getLastPathSegment(String path) { - if (path == null) return null; - Uri localUri = Uri.parse(path); + private String getLastPathSegment(Uri uri) { + String path = ""; + if (uri == null) return path; + try { + path = ImageLoader.getLocalPathFromUri(this, uri); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + } + + Uri localUri; + if (path != null) { + localUri = Uri.parse(path); + } else { + path = uri.getPath(); + localUri = uri; + } + String lastPathSegment = localUri.getLastPathSegment(); // uri.getLastPathSegment will return null if localUri contains |
