From 8a023f9409868488c78c114ff2d59c9177da330f Mon Sep 17 00:00:00 2001 From: Sam Bosley Date: Mon, 6 Feb 2012 12:40:27 -0800 Subject: [PATCH] Added try/catch to fix crash when showing task edit popover after delay --- .../astrid/activity/TaskListFragment.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java index bfb2a7e70..923ceb0e6 100644 --- a/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java +++ b/astrid/src/com/todoroo/astrid/activity/TaskListFragment.java @@ -1054,14 +1054,18 @@ public class TaskListFragment extends ListFragment implements OnScrollListener, imm.hideSoftInputFromWindow(quickAddBox.getWindowToken(), 0); getListView().postDelayed(new Runnable() { public void run() { - if (taskAdapter != null && taskAdapter.getCount() > 0) { - final View view = getListView().getChildAt( - getListView().getChildCount() - 1); - if (view != null) { - HelpInfoPopover.showPopover(getActivity(), view, - R.string.help_popover_tap_task, null); - Preferences.setBoolean(R.string.p_showed_tap_task_help, true); + try { + if (taskAdapter != null && taskAdapter.getCount() > 0) { + final View view = getListView().getChildAt( + getListView().getChildCount() - 1); + if (view != null) { + HelpInfoPopover.showPopover(getActivity(), view, + R.string.help_popover_tap_task, null); + Preferences.setBoolean(R.string.p_showed_tap_task_help, true); + } } + } catch (IllegalStateException e) { + // Whoops, view is gone. Try again later } } }, 1000L);