Search in sources :

Example 16 with Loader

use of android.content.Loader in project android_frameworks_base by ResurrectionRemix.

the class RecentsCreateFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final Context context = inflater.getContext();
    final View view = inflater.inflate(R.layout.fragment_directory, container, false);
    mRecView = (RecyclerView) view.findViewById(R.id.dir_list);
    mRecView.setLayoutManager(new LinearLayoutManager(getContext()));
    mRecView.addOnItemTouchListener(mItemListener);
    mEmptyView = view.findViewById(android.R.id.empty);
    mAdapter = new DocumentStackAdapter();
    mRecView.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.update(data);
            // When launched into empty recents, show drawer
            if (mAdapter.isEmpty() && !state.hasLocationChanged() && state.action != ACTION_CREATE && context instanceof DocumentsActivity) {
                ((DocumentsActivity) context).setRootsDrawerOpen(true);
            }
        }

        @Override
        public void onLoaderReset(Loader<List<DocumentStack>> loader) {
            mAdapter.update(null);
        }
    };
    return view;
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Loader(android.content.Loader) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView) ArrayList(java.util.ArrayList) List(java.util.List) DocumentStack(com.android.documentsui.model.DocumentStack)

Aggregations

Loader (android.content.Loader)16 Context (android.content.Context)10 Bundle (android.os.Bundle)10 Intent (android.content.Intent)5 OnLoadCompleteListener (android.content.Loader.OnLoadCompleteListener)5 Handler (android.os.Handler)5 Message (android.os.Message)5 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)5 RecyclerView (android.support.v7.widget.RecyclerView)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 DocumentStack (com.android.documentsui.model.DocumentStack)5 RootInfo (com.android.documentsui.model.RootInfo)5 ArrayList (java.util.ArrayList)5 Collection (java.util.Collection)5 List (java.util.List)5 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)5 CursorLoader (android.content.CursorLoader)1 Cursor (android.database.Cursor)1