summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/data/UriSource.java
diff options
context:
space:
mode:
authorOwen Lin <owenlin@google.com>2012-08-29 11:53:10 +0800
committerOwen Lin <owenlin@google.com>2012-08-30 15:49:10 +0800
commit28cb4161da5fc3756933ca67d509b8af1c6275f1 (patch)
tree704d50fe9bb2acf06efe4a980f714d3f4306bbfd /src/com/android/gallery3d/data/UriSource.java
parente786d3cb1521db74a1c48cae52b8b55b1cee0292 (diff)
downloadandroid_packages_apps_Gallery2-28cb4161da5fc3756933ca67d509b8af1c6275f1.tar.gz
android_packages_apps_Gallery2-28cb4161da5fc3756933ca67d509b8af1c6275f1.tar.bz2
android_packages_apps_Gallery2-28cb4161da5fc3756933ca67d509b8af1c6275f1.zip
Remove unused resources and fix some warnings.
Change-Id: I075977150c7da7650e723e29406f24ae2e23ea97
Diffstat (limited to 'src/com/android/gallery3d/data/UriSource.java')
-rw-r--r--src/com/android/gallery3d/data/UriSource.java21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/com/android/gallery3d/data/UriSource.java b/src/com/android/gallery3d/data/UriSource.java
index d37c51d13..f66bacd7b 100644
--- a/src/com/android/gallery3d/data/UriSource.java
+++ b/src/com/android/gallery3d/data/UriSource.java
@@ -22,6 +22,7 @@ import android.webkit.MimeTypeMap;
import com.android.gallery3d.app.GalleryApp;
+import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.net.URLEncoder;
@@ -30,6 +31,7 @@ class UriSource extends MediaSource {
private static final String TAG = "UriSource";
private static final String IMAGE_TYPE_PREFIX = "image/";
private static final String IMAGE_TYPE_ANY = "image/*";
+ private static final String CHARSET_UTF_8 = "utf-8";
private GalleryApp mApplication;
@@ -44,9 +46,13 @@ class UriSource extends MediaSource {
if (segment.length != 3) {
throw new RuntimeException("bad path: " + path);
}
- String uri = URLDecoder.decode(segment[1]);
- String type = URLDecoder.decode(segment[2]);
- return new UriImage(mApplication, path, Uri.parse(uri), type);
+ try {
+ String uri = URLDecoder.decode(segment[1], CHARSET_UTF_8);
+ String type = URLDecoder.decode(segment[2], CHARSET_UTF_8);
+ return new UriImage(mApplication, path, Uri.parse(uri), type);
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError(e);
+ }
}
private String getMimeType(Uri uri) {
@@ -75,8 +81,13 @@ class UriSource extends MediaSource {
}
if (type.startsWith(IMAGE_TYPE_PREFIX)) {
- return Path.fromString("/uri/" + URLEncoder.encode(uri.toString())
- + "/" +URLEncoder.encode(type));
+ try {
+ return Path.fromString("/uri/"
+ + URLEncoder.encode(uri.toString(), CHARSET_UTF_8)
+ + "/" +URLEncoder.encode(type, CHARSET_UTF_8));
+ } catch (UnsupportedEncodingException e) {
+ throw new AssertionError(e);
+ }
}
// We have no clues that it is an image
return null;