/** * Callback method from {@link TaskListFragment.Callbacks} indicating that the item with the given * ID was selected. */ @Override public void onItemSelected(Uri uri, boolean forceReload, int pagePosition) { // only accept selections from the current visible task fragment or the activity itself if (pagePosition == -1 || pagePosition == mCurrentPagePosition) { if (mTwoPane) { mShouldShowDetails = true; if (forceReload) { mSelectedTaskUri = null; mShouldSwitchToDetail = false; mTaskDetailFrag.loadUri(uri); } else { mTaskDetailFrag.loadUri(uri); } } else if (forceReload) { mSelectedTaskUri = uri; // In single-pane mode, simply start the detail activity // for the selected item ID. Intent detailIntent = new Intent(Intent.ACTION_VIEW); detailIntent.setData(uri); startActivity(detailIntent); mSwitchedToDetail = true; mShouldSwitchToDetail = false; } } }
@Override public void onDelete(Uri taskUri) { // nothing to do here, the loader will take care of reloading the list and the list view will // take care of selecting the next element. // empty the detail fragment if (mTwoPane) { mTaskDetailFrag.loadUri(null); } }