From 570d340eaf2cb5b8c5d95254fbe731c8d5b49dbd Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Tue, 2 Apr 2013 10:58:53 -0700 Subject: [PATCH] Hopefully fixed a couple rare crashes --- astrid/src/com/todoroo/astrid/helper/AsyncImageView.java | 7 +++++++ .../com/todoroo/astrid/voice/Api6VoiceOutputAssistant.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/astrid/src/com/todoroo/astrid/helper/AsyncImageView.java b/astrid/src/com/todoroo/astrid/helper/AsyncImageView.java index 102538fde..523f5d19f 100644 --- a/astrid/src/com/todoroo/astrid/helper/AsyncImageView.java +++ b/astrid/src/com/todoroo/astrid/helper/AsyncImageView.java @@ -10,6 +10,7 @@ import java.io.IOException; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Bitmap.CompressFormat; +import android.os.Looper; import android.text.TextUtils; import android.util.AttributeSet; @@ -83,6 +84,12 @@ public class AsyncImageView extends greendroid.widget.AsyncImageView { if (imageCacheInstance == null) { synchronized(AsyncImageView.class) { if (imageCacheInstance == null) { + try { + if (Looper.myLooper() == null) + Looper.prepare(); + } catch (Exception e) { + // Ignore + } imageCacheInstance = new ImageCache(ContextManager.getContext(), CompressFormat.JPEG, 85); } } diff --git a/astrid/src/com/todoroo/astrid/voice/Api6VoiceOutputAssistant.java b/astrid/src/com/todoroo/astrid/voice/Api6VoiceOutputAssistant.java index cd8c4fac6..576e920a7 100644 --- a/astrid/src/com/todoroo/astrid/voice/Api6VoiceOutputAssistant.java +++ b/astrid/src/com/todoroo/astrid/voice/Api6VoiceOutputAssistant.java @@ -94,7 +94,7 @@ public class Api6VoiceOutputAssistant implements OnInitListener, VoiceOutputAssi @Override public void onInit(int status) { // status can be either TextToSpeech.SUCCESS or TextToSpeech.ERROR. - if (status == TextToSpeech.SUCCESS) { + if (status == TextToSpeech.SUCCESS && mTts != null) { // Set preferred language to US english. // Note that a language may not be available, and the result will indicate this. int result = mTts.setLanguage(Locale.getDefault());