Hopefully fixed a rare crash in the task list fragment

pull/14/head
Sam Bosley 12 years ago
parent 3ec37a8a35
commit 45556e5a7f

@ -854,7 +854,6 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
return; return;
} }
int oldListItemSelected = getListView().getSelectedItemPosition();
Cursor taskCursor = taskAdapter.getCursor(); Cursor taskCursor = taskAdapter.getCursor();
if (requery) { if (requery) {
@ -863,9 +862,12 @@ public class TaskListFragment extends ListFragment implements OnScrollListener,
taskAdapter.notifyDataSetChanged(); taskAdapter.notifyDataSetChanged();
} }
if (getView() != null) { // This was happening sometimes
int oldListItemSelected = getListView().getSelectedItemPosition();
if (oldListItemSelected != ListView.INVALID_POSITION if (oldListItemSelected != ListView.INVALID_POSITION
&& oldListItemSelected < taskCursor.getCount()) && oldListItemSelected < taskCursor.getCount())
getListView().setSelection(oldListItemSelected); getListView().setSelection(oldListItemSelected);
}
// also load sync actions // also load sync actions
syncActionHelper.request(); syncActionHelper.request();

Loading…
Cancel
Save