diff options
author | 2014-11-17 18:07:35 +0900 | |
---|---|---|
committer | 2014-11-21 12:02:06 +0900 | |
commit | ebe5b42f71bd63973edffbda691b498611326c6f (patch) | |
tree | 3678307310e30775937e01d6cb2add65c1f7d52f /java/src/com/android/inputmethod/dictionarypack/DictionaryService.java | |
parent | a94733cbca5bc3544fa73fa1649bbb1dadf31356 (diff) | |
download | latinime-ebe5b42f71bd63973edffbda691b498611326c6f.tar.gz latinime-ebe5b42f71bd63973edffbda691b498611326c6f.tar.xz latinime-ebe5b42f71bd63973edffbda691b498611326c6f.zip |
Make LocaleUtils.constructLocaleFromString as @Nonnull
Change-Id: I82d574c67b25239510f3ecc8882efe46e40677eb
Diffstat (limited to 'java/src/com/android/inputmethod/dictionarypack/DictionaryService.java')
-rw-r--r-- | java/src/com/android/inputmethod/dictionarypack/DictionaryService.java | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java index e6acb8f36..c678f081d 100644 --- a/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java +++ b/java/src/com/android/inputmethod/dictionarypack/DictionaryService.java @@ -22,6 +22,7 @@ import android.app.Service; import android.content.Context; import android.content.Intent; import android.os.IBinder; +import android.util.Log; import android.widget.Toast; import com.android.inputmethod.latin.R; @@ -33,6 +34,8 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.ThreadPoolExecutor; import java.util.concurrent.TimeUnit; +import javax.annotation.Nonnull; + /** * Service that handles background tasks for the dictionary provider. * @@ -51,6 +54,8 @@ import java.util.concurrent.TimeUnit; * to access, and mark the current state as such. */ public final class DictionaryService extends Service { + private static final String TAG = DictionaryService.class.getSimpleName(); + /** * The package name, to use in the intent actions. */ @@ -156,9 +161,14 @@ public final class DictionaryService extends Service { final int startId) { final DictionaryService self = this; if (SHOW_DOWNLOAD_TOAST_INTENT_ACTION.equals(intent.getAction())) { - // This is a UI action, it can't be run in another thread - showStartDownloadingToast(this, LocaleUtils.constructLocaleFromString( - intent.getStringExtra(LOCALE_INTENT_ARGUMENT))); + final String localeString = intent.getStringExtra(LOCALE_INTENT_ARGUMENT); + if (localeString == null) { + Log.e(TAG, "Received " + intent.getAction() + " without locale; skipped"); + } else { + // This is a UI action, it can't be run in another thread + showStartDownloadingToast( + this, LocaleUtils.constructLocaleFromString(localeString)); + } } else { // If it's a command that does not require UI, arrange for the work to be done on a // separate thread, so that we can return right away. The executor will spawn a thread @@ -245,7 +255,8 @@ public final class DictionaryService extends Service { /** * Shows a toast informing the user that an automatic dictionary download is starting. */ - private static void showStartDownloadingToast(final Context context, final Locale locale) { + private static void showStartDownloadingToast(final Context context, + @Nonnull final Locale locale) { final String toastText = String.format( context.getString(R.string.toast_downloading_suggestions), locale.getDisplayName()); |