diff options
| author | yongga <yongga@codeaurora.org> | 2016-01-07 15:15:54 +0800 |
|---|---|---|
| committer | yongga <yongga@codeaurora.org> | 2016-01-07 15:15:54 +0800 |
| commit | 7026db4ab23bb71aa8f356eae8d5ba6ba058f207 (patch) | |
| tree | 65663b7f0f6337107b94f9d0dd833737a6db78ad /src/com/android | |
| parent | 701f6401729b727d84b16d58dd8fafb79b23d558 (diff) | |
| download | android_packages_apps_Gallery2-7026db4ab23bb71aa8f356eae8d5ba6ba058f207.tar.gz android_packages_apps_Gallery2-7026db4ab23bb71aa8f356eae8d5ba6ba058f207.tar.bz2 android_packages_apps_Gallery2-7026db4ab23bb71aa8f356eae8d5ba6ba058f207.zip | |
Gallery2: fix a crash when print a photo.
fix a crash when print a photo whose file name contains ':' character.
Change-Id: Ib9ace0cca50c65dd7c42015e85a309ac2cf361f5
CRs-Fixed: 948075
Diffstat (limited to 'src/com/android')
| -rw-r--r-- | src/com/android/gallery3d/app/AbstractGalleryActivity.java | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/AbstractGalleryActivity.java b/src/com/android/gallery3d/app/AbstractGalleryActivity.java index 915fc948a..b9007d57e 100644 --- a/src/com/android/gallery3d/app/AbstractGalleryActivity.java +++ b/src/com/android/gallery3d/app/AbstractGalleryActivity.java @@ -368,8 +368,7 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext } String path = ImageLoader.getLocalPathFromUri(this, uri); if (path != null) { - Uri localUri = Uri.parse(path); - path = localUri.getLastPathSegment(); + path = getLastPathSegment(path); } else { path = uri.getLastPathSegment(); } @@ -381,6 +380,21 @@ public class AbstractGalleryActivity extends Activity implements GalleryContext } } + private String getLastPathSegment(String path) { + if (path == null) return null; + Uri localUri = Uri.parse(path); + String lastPathSegment = localUri.getLastPathSegment(); + + // uri.getLastPathSegment will return null if localUri contains + // spacial characters such as ':', so use other way to get it. + if (lastPathSegment == null) { + // use substring to get last path segment. + int indexOfLastPathSegment = path.lastIndexOf("/") + 1; + lastPathSegment = path.substring(indexOfLastPathSegment, path.length()); + } + return lastPathSegment; + } + public Toolbar getToolbar() { return mToolbar; } |
