use of com.android.documentsui.model.DocumentStack in project android_frameworks_base by ResurrectionRemix.
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);
}
}
use of com.android.documentsui.model.DocumentStack 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;
}
use of com.android.documentsui.model.DocumentStack in project android_frameworks_base by DirtyUnicorns.
the class FileOperationService method handleOperation.
private void handleOperation(Intent intent, int serviceId, String jobId, int operationType) {
if (DEBUG)
Log.d(TAG, "onStartCommand: " + jobId + " with serviceId " + serviceId);
// Track the service supplied id so we can stop the service once we're out of work to do.
mLastServiceId = serviceId;
Job job = null;
synchronized (mRunning) {
if (mWakeLock == null) {
mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
}
List<DocumentInfo> srcs = intent.getParcelableArrayListExtra(EXTRA_SRC_LIST);
DocumentInfo srcParent = intent.getParcelableExtra(EXTRA_SRC_PARENT);
DocumentStack stack = intent.getParcelableExtra(Shared.EXTRA_STACK);
job = createJob(operationType, jobId, srcs, srcParent, stack);
if (job == null) {
return;
}
mWakeLock.acquire();
}
assert (job != null);
int delay = intent.getIntExtra(EXTRA_DELAY, DEFAULT_DELAY);
assert (delay <= MAX_DELAY);
if (DEBUG)
Log.d(TAG, "Scheduling job " + job.id + " to run in " + delay + " milliseconds.");
ScheduledFuture<?> future = executor.schedule(job, delay, TimeUnit.MILLISECONDS);
mRunning.put(jobId, new JobRecord(job, future));
}
use of com.android.documentsui.model.DocumentStack in project android_frameworks_base by DirtyUnicorns.
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);
}
use of com.android.documentsui.model.DocumentStack in project android_frameworks_base by crdroidandroid.
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);
}
Aggregations