RecentsCreateFragmentpublic class RecentsCreateFragment extends android.app.Fragment Display directories where recent creates took place. |
Fields Summary |
---|
private android.view.View | mEmptyView | private android.widget.ListView | mListView | private DocumentStackAdapter | mAdapter | private android.app.LoaderManager.LoaderCallbacks | mCallbacks | private static final int | LOADER_RECENTS | private android.widget.AdapterView.OnItemClickListener | mItemListener |
Methods Summary |
---|
private static void | appendDrawable(android.text.SpannableStringBuilder b, android.graphics.drawable.Drawable d)
final int length = b.length();
b.append("\u232a");
b.setSpan(new ImageSpan(d), length, b.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
| public android.view.View | onCreateView(android.view.LayoutInflater inflater, android.view.ViewGroup container, android.os.Bundle savedInstanceState)
final Context context = inflater.getContext();
final View view = inflater.inflate(R.layout.fragment_directory, container, false);
mEmptyView = view.findViewById(android.R.id.empty);
mListView = (ListView) view.findViewById(R.id.list);
mListView.setOnItemClickListener(mItemListener);
mAdapter = new DocumentStackAdapter();
mListView.setAdapter(mAdapter);
final RootsCache roots = DocumentsApplication.getRootsCache(context);
final State state = ((DocumentsActivity) 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);
// When launched into empty recents, show drawer
if (mAdapter.isEmpty() && !state.stackTouched) {
((DocumentsActivity) context).setRootsDrawerOpen(true);
}
}
@Override
public void onLoaderReset(Loader<List<DocumentStack>> loader) {
mAdapter.swapStacks(null);
}
};
return view;
| public void | onStart()
super.onStart();
getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks);
| public void | onStop()
super.onStop();
getLoaderManager().destroyLoader(LOADER_RECENTS);
| public static void | show(android.app.FragmentManager fm)
final RecentsCreateFragment fragment = new RecentsCreateFragment();
final FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.container_directory, fragment);
ft.commitAllowingStateLoss();
|
|