From 10cb216ca94725e34d7fa666111e47853761f60e Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 20 Feb 2012 12:47:36 -0800 Subject: [PATCH] Make sure that fragment is attached to activity on ui thread in taskeditbackgroundloader --- .../astrid/activity/TaskEditFragment.java | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java index 19fbed471..a4bca6305 100755 --- a/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskEditFragment.java @@ -655,28 +655,30 @@ ViewPager.OnPageChangeListener, EditNoteActivity.UpdatesChangedListener { public void onUiThread() { // prepare and set listener for voice-button - if (addOnService.hasPowerPack()) { - voiceAddNoteButton = (ImageButton) notesControlSet.getView().findViewById( - R.id.voiceAddNoteButton); - voiceAddNoteButton.setVisibility(View.VISIBLE); - int prompt = R.string.voice_edit_note_prompt; - voiceNoteAssistant = new VoiceInputAssistant(TaskEditFragment.this, - voiceAddNoteButton, notesEditText, REQUEST_VOICE_RECOG); - voiceNoteAssistant.setAppend(true); - voiceNoteAssistant.setLanguageModel(RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); - voiceNoteAssistant.configureMicrophoneButton(prompt); - } + if (getActivity() != null) { + if (addOnService.hasPowerPack()) { + voiceAddNoteButton = (ImageButton) notesControlSet.getView().findViewById( + R.id.voiceAddNoteButton); + voiceAddNoteButton.setVisibility(View.VISIBLE); + int prompt = R.string.voice_edit_note_prompt; + voiceNoteAssistant = new VoiceInputAssistant(TaskEditFragment.this, + voiceAddNoteButton, notesEditText, REQUEST_VOICE_RECOG); + voiceNoteAssistant.setAppend(true); + voiceNoteAssistant.setLanguageModel(RecognizerIntent.LANGUAGE_MODEL_FREE_FORM); + voiceNoteAssistant.configureMicrophoneButton(prompt); + } - // re-read all - synchronized (controls) { - for (TaskEditControlSet controlSet : controls) - controlSet.readFromTask(model); - if (isNewTask) { - hideUntilControls.setDefaults(); + // re-read all + synchronized (controls) { + for (TaskEditControlSet controlSet : controls) + controlSet.readFromTask(model); + if (isNewTask) { + hideUntilControls.setDefaults(); + } } - } - loadMoreContainer(); + loadMoreContainer(); + } } @Override