@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Context context = getActivity(); mAdapter = new DocumentStackAdapter(); mListView.setAdapter(mAdapter); final RootsCache roots = DocumentsApplication.getRootsCache(context); final State state = ((BaseActivity) getActivity()).getDisplayState(); mCallbacks = new LoaderCallbacks<List<DocumentStack>>() { @Override public Loader<List<DocumentStack>> onCreateLoader(int id, Bundle args) { return new RecentsCreateLoader(context, roots, state); } @Override public void onLoadFinished( Loader<List<DocumentStack>> loader, List<DocumentStack> data) { mAdapter.swapStacks(data); if (isResumed()) { setListShown(true); } else { setListShownNoAnimation(true); } // When launched into empty recents, show drawer if (mAdapter.isEmpty() && !state.stackTouched) { ((BaseActivity) context).setRootsDrawerOpen(true); } } @Override public void onLoaderReset(Loader<List<DocumentStack>> loader) { mAdapter.swapStacks(null); } }; setListAdapter(mAdapter); setListShown(false); getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks); }
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); if(null != savedInstanceState) { group_size = savedInstanceState.getInt(GROUP_SIZE, 0); expandedIds = (ArrayList<Long>) savedInstanceState.getSerializable(GROUP_IDS); } final Context context = getActivity(); final RootsCache roots = DocumentsApplication.getRootsCache(context); final State state = ((BaseActivity) context).getDisplayState(); mCallbacks = new LoaderCallbacks<Collection<RootInfo>>() { @Override public Loader<Collection<RootInfo>> onCreateLoader(int id, Bundle args) { return new RootsLoader(context, roots, state); } @Override public void onLoadFinished( Loader<Collection<RootInfo>> loader, Collection<RootInfo> result) { if (!isAdded()) return; final Intent includeApps = getArguments().getParcelable(EXTRA_INCLUDE_APPS); if (mAdapter == null) { mAdapter = new RootsExpandableAdapter(context, result, includeApps); Parcelable state = mList.onSaveInstanceState(); mList.setAdapter(mAdapter); mList.onRestoreInstanceState(state); } else { mAdapter.setData(result); } int groupCount = mAdapter.getGroupCount(); if(group_size != 0 && group_size == groupCount){ if (expandedIds != null) { restoreExpandedState(expandedIds); } } else { group_size = groupCount; for (int i = 0; i < group_size; i++) { mList.expandGroup(i); } expandedIds = getExpandedIds(); mList.setOnGroupExpandListener(mOnGroupExpandListener); mList.setOnGroupCollapseListener(mOnGroupCollapseListener); } } @Override public void onLoaderReset(Loader<Collection<RootInfo>> loader) { mAdapter = null; mList.setAdapter((RootsExpandableAdapter)null); } }; }
private void initialiseExistingFormList() { FormAdapter adapter = new FormAdapter(this.getApplicationContext(), null, this); setListAdapter(adapter); getLoaderManager().initLoader(0, null, (LoaderCallbacks<Cursor>) this); }
@Override public void execute(final Query request, final QueryListener listener) { final LoaderCallbacks<?> callbacks = new QueryLoaderCallbacks(listener); execute(request, callbacks); }
@Override public void execute(final Update request, final UpdateListener listener) { final LoaderCallbacks<?> callbacks = new UpdateLoaderCallbacks(listener); execute(request, callbacks); }
@Override public void execute(final Insert request, final InsertListener listener) { final LoaderCallbacks<?> callbacks = new InsertLoaderCallbacks(listener); execute(request, callbacks); }
@Override public void execute(final Delete request, final DeleteListener listener) { final LoaderCallbacks<?> callbacks = new DeleteLoaderCallbacks(listener); execute(request, callbacks); }
@Override public void execute(final Batch request, final BatchListener listener) { final LoaderCallbacks<?> callbacks = new BatchLoaderCallbacks(listener); execute(request, callbacks); }
private void execute(final Request<?> request, final LoaderCallbacks<?> callbacks) { final int identifier = request.getIdentifier(); final Bundle bundle = createRequestBundle(request); mLoaderManager.restartLoader(identifier, bundle, callbacks); }