aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorMohammadinamul Sheik <inamul@google.com>2015-03-26 22:55:09 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-03-26 22:55:09 +0000
commit8162c3b82a095378e72d96758c296aa589bdeb01 (patch)
tree992901b5baa891e8f9627d7605d970b1e1a82c3a /java/src
parent10ac813adc6c7f19f223c5d62dd6644260a73a6f (diff)
parent7b34ec90eab475bcbfa9724ecbd47ce8c10aa0de (diff)
downloadlatinime-8162c3b82a095378e72d96758c296aa589bdeb01.tar.gz
latinime-8162c3b82a095378e72d96758c296aa589bdeb01.tar.xz
latinime-8162c3b82a095378e72d96758c296aa589bdeb01.zip
am 7b34ec90: Merge "Handle missing resources."
* commit '7b34ec90eab475bcbfa9724ecbd47ce8c10aa0de': Handle missing resources.
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java14
1 files changed, 9 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
index e00532aa6..f4300c462 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionaryGetter.java
@@ -91,10 +91,15 @@ final public class BinaryDictionaryGetter {
*/
public static AssetFileAddress loadFallbackResource(final Context context,
final int fallbackResId) {
- final AssetFileDescriptor afd = context.getResources().openRawResourceFd(fallbackResId);
+ AssetFileDescriptor afd = null;
+ try {
+ afd = context.getResources().openRawResourceFd(fallbackResId);
+ } catch (RuntimeException e) {
+ Log.e(TAG, "Resource not found: " + fallbackResId, e);
+ return null;
+ }
if (afd == null) {
- Log.e(TAG, "Found the resource but cannot read it. Is it compressed? resId="
- + fallbackResId);
+ Log.e(TAG, "Resource cannot be opened: " + fallbackResId);
return null;
}
try {
@@ -103,8 +108,7 @@ final public class BinaryDictionaryGetter {
} finally {
try {
afd.close();
- } catch (IOException e) {
- // Ignored
+ } catch (IOException ignored) {
}
}
}