Search in sources :

Example 31 with RootInfo

use of com.android.documentsui.model.RootInfo in project android_frameworks_base by ResurrectionRemix.

the class FilesActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    final RootInfo root = getCurrentRoot();
    // the user what has happened, let them close us. Less surprising.
    if (mRoots.getRootBlocking(root.authority, root.rootId) == null) {
        finish();
    }
}
Also used : RootInfo(com.android.documentsui.model.RootInfo)

Example 32 with RootInfo

use of com.android.documentsui.model.RootInfo in project android_frameworks_base by crdroidandroid.

the class RootsFragment method onActivityCreated.

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    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;
            }
            Intent handlerAppIntent = getArguments().getParcelable(EXTRA_INCLUDE_APPS);
            mAdapter = new RootsAdapter(context, result, handlerAppIntent, state);
            mList.setAdapter(mAdapter);
            onCurrentRootChanged();
        }

        @Override
        public void onLoaderReset(Loader<Collection<RootInfo>> loader) {
            mAdapter = null;
            mList.setAdapter(null);
        }
    };
}
Also used : Context(android.content.Context) Bundle(android.os.Bundle) Loader(android.content.Loader) Intent(android.content.Intent) RootInfo(com.android.documentsui.model.RootInfo) Collection(java.util.Collection)

Example 33 with RootInfo

use of com.android.documentsui.model.RootInfo in project android_frameworks_base by crdroidandroid.

the class RootsCache method getRootOneshot.

/**
     * Return the requested {@link RootInfo}, but only loading the roots for the
     * requested authority. This is useful when we want to load fast without
     * waiting for all the other roots to come back.
     */
public RootInfo getRootOneshot(String authority, String rootId) {
    synchronized (mLock) {
        RootInfo root = getRootLocked(authority, rootId);
        if (root == null) {
            mRoots.putAll(authority, loadRootsForAuthority(mContext.getContentResolver(), authority, false));
            root = getRootLocked(authority, rootId);
        }
        return root;
    }
}
Also used : RootInfo(com.android.documentsui.model.RootInfo)

Example 34 with RootInfo

use of com.android.documentsui.model.RootInfo in project android_frameworks_base by crdroidandroid.

the class RootsCacheTest method testMatchingRoots_DirectoryCopy.

public void testMatchingRoots_DirectoryCopy() throws Exception {
    RootInfo downloads = buildForMimeTypes("*/*");
    downloads.authority = "com.android.providers.downloads.documents";
    mRoots.add(downloads);
    mState.acceptMimes = new String[] { "*/*" };
    mState.directoryCopy = true;
    // basically we're asserting that the results don't contain downloads
    assertContainsExactly(newArrayList(mNull, mWild, mImages, mAudio, mDocs, mMalformed1, mMalformed2), getMatchingRoots(mRoots, mState));
}
Also used : RootInfo(com.android.documentsui.model.RootInfo)

Example 35 with RootInfo

use of com.android.documentsui.model.RootInfo in project android_frameworks_base by crdroidandroid.

the class RootsCacheTest method buildForMimeTypes.

private static RootInfo buildForMimeTypes(String... mimeTypes) {
    final RootInfo root = new RootInfo();
    root.derivedMimeTypes = mimeTypes;
    return root;
}
Also used : RootInfo(com.android.documentsui.model.RootInfo)

Aggregations

RootInfo (com.android.documentsui.model.RootInfo)85 DocumentInfo (com.android.documentsui.model.DocumentInfo)20 FragmentManager (android.app.FragmentManager)15 Bundle (android.os.Bundle)15 ArrayList (java.util.ArrayList)15 Intent (android.content.Intent)10 Cursor (android.database.Cursor)10 ContentProviderClient (android.content.ContentProviderClient)5 Context (android.content.Context)5 Loader (android.content.Loader)5 MatrixCursor (android.database.MatrixCursor)5 MergeCursor (android.database.MergeCursor)5 Uri (android.net.Uri)5 VisibleForTesting (android.support.annotation.VisibleForTesting)5 MenuItem (android.view.MenuItem)5 DirectoryFragment (com.android.documentsui.dirlist.DirectoryFragment)5 IOException (java.io.IOException)5 Collection (java.util.Collection)5 CountDownLatch (java.util.concurrent.CountDownLatch)5 ExecutionException (java.util.concurrent.ExecutionException)5