FileDocCategorySizeDatePackage
RecentsCreateFragment.javaAPI DocAndroid 5.1 API9384Thu Mar 12 22:22:40 GMT 2015com.android.documentsui

RecentsCreateFragment

public 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
Constructors Summary
Methods Summary
private static voidappendDrawable(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.ViewonCreateView(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 voidonStart()

        super.onStart();
        getLoaderManager().restartLoader(LOADER_RECENTS, getArguments(), mCallbacks);
    
public voidonStop()

        super.onStop();
        getLoaderManager().destroyLoader(LOADER_RECENTS);
    
public static voidshow(android.app.FragmentManager fm)


         
        final RecentsCreateFragment fragment = new RecentsCreateFragment();
        final FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.container_directory, fragment);
        ft.commitAllowingStateLoss();