Search in sources :

Example 6 with DocumentStack

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

the class AbstractJobTest method createJob.

final T createJob(List<Uri> srcs, Uri srcParent, Uri destination) throws Exception {
    DocumentStack stack = new DocumentStack();
    stack.push(DocumentInfo.fromUri(mResolver, destination));
    List<DocumentInfo> srcDocs = Lists.newArrayList();
    for (Uri src : srcs) {
        srcDocs.add(DocumentInfo.fromUri(mResolver, src));
    }
    return createJob(srcDocs, DocumentInfo.fromUri(mResolver, srcParent), stack);
}
Also used : DocumentStack(com.android.documentsui.model.DocumentStack) Uri(android.net.Uri) DocumentInfo(com.android.documentsui.model.DocumentInfo)

Example 7 with DocumentStack

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

the class FileOperationServiceTest method createCopyIntent.

private Intent createCopyIntent(ArrayList<DocumentInfo> files, DocumentInfo dest) throws Exception {
    DocumentStack stack = new DocumentStack();
    stack.push(dest);
    return createBaseIntent(OPERATION_COPY, getContext(), createJobId(), files, stack);
}
Also used : DocumentStack(com.android.documentsui.model.DocumentStack)

Example 8 with DocumentStack

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

the class FilesActivity method includeState.

@Override
void includeState(State state) {
    final Intent intent = getIntent();
    state.action = State.ACTION_BROWSE;
    state.allowMultiple = true;
    // Options specific to the DocumentsActivity.
    assert (!intent.hasExtra(Intent.EXTRA_LOCAL_ONLY));
    final DocumentStack stack = intent.getParcelableExtra(Shared.EXTRA_STACK);
    if (stack != null) {
        state.stack = stack;
    }
}
Also used : Intent(android.content.Intent) DocumentStack(com.android.documentsui.model.DocumentStack)

Example 9 with DocumentStack

use of com.android.documentsui.model.DocumentStack in project android_frameworks_base by DirtyUnicorns.

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)

Example 10 with DocumentStack

use of com.android.documentsui.model.DocumentStack in project android_frameworks_base by DirtyUnicorns.

the class RecentsProvider method purgeByAuthority.

/**
     * Purge all internal data whose authority matches the given
     * {@link Predicate}.
     */
private void purgeByAuthority(Predicate<String> predicate) {
    final SQLiteDatabase db = mHelper.getWritableDatabase();
    final DocumentStack stack = new DocumentStack();
    Cursor cursor = db.query(TABLE_RECENT, null, null, null, null, null, null);
    try {
        while (cursor.moveToNext()) {
            try {
                final byte[] rawStack = cursor.getBlob(cursor.getColumnIndex(RecentColumns.STACK));
                DurableUtils.readFromArray(rawStack, stack);
                if (stack.root != null && predicate.apply(stack.root.authority)) {
                    final String key = getCursorString(cursor, RecentColumns.KEY);
                    db.delete(TABLE_RECENT, RecentColumns.KEY + "=?", new String[] { key });
                }
            } catch (IOException ignored) {
            }
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    cursor = db.query(TABLE_STATE, new String[] { StateColumns.AUTHORITY }, null, null, StateColumns.AUTHORITY, null, null);
    try {
        while (cursor.moveToNext()) {
            final String authority = getCursorString(cursor, StateColumns.AUTHORITY);
            if (predicate.apply(authority)) {
                db.delete(TABLE_STATE, StateColumns.AUTHORITY + "=?", new String[] { authority });
                if (DEBUG)
                    Log.d(TAG, "Purged state for " + authority);
            }
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
    cursor = db.query(TABLE_RESUME, null, null, null, null, null, null);
    try {
        while (cursor.moveToNext()) {
            try {
                final byte[] rawStack = cursor.getBlob(cursor.getColumnIndex(ResumeColumns.STACK));
                DurableUtils.readFromArray(rawStack, stack);
                if (stack.root != null && predicate.apply(stack.root.authority)) {
                    final String packageName = getCursorString(cursor, ResumeColumns.PACKAGE_NAME);
                    db.delete(TABLE_RESUME, ResumeColumns.PACKAGE_NAME + "=?", new String[] { packageName });
                }
            } catch (IOException ignored) {
            }
        }
    } finally {
        IoUtils.closeQuietly(cursor);
    }
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) DocumentStack(com.android.documentsui.model.DocumentStack) DocumentInfo.getCursorString(com.android.documentsui.model.DocumentInfo.getCursorString) IOException(java.io.IOException) Cursor(android.database.Cursor)

Aggregations

DocumentStack (com.android.documentsui.model.DocumentStack)35 DocumentInfo (com.android.documentsui.model.DocumentInfo)10 Context (android.content.Context)5 Intent (android.content.Intent)5 Loader (android.content.Loader)5 Cursor (android.database.Cursor)5 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)5 Uri (android.net.Uri)5 Bundle (android.os.Bundle)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 BaseActivity (com.android.documentsui.BaseActivity)5 DocumentInfo.getCursorString (com.android.documentsui.model.DocumentInfo.getCursorString)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 List (java.util.List)5