use of com.android.documentsui.model.DocumentStack in project platform_frameworks_base by android.
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;
}
}
use of com.android.documentsui.model.DocumentStack in project platform_frameworks_base by android.
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 platform_frameworks_base by android.
the class DirectoryFragment method copyDocuments.
private void copyDocuments(final List<DocumentInfo> docs, final DocumentInfo destination) {
BaseActivity activity = (BaseActivity) getActivity();
if (!canCopy(docs, activity.getCurrentRoot(), destination)) {
Snackbars.makeSnackbar(getActivity(), R.string.clipboard_files_cannot_paste, Snackbar.LENGTH_SHORT).show();
return;
}
if (docs.isEmpty()) {
return;
}
final DocumentStack curStack = getDisplayState().stack;
DocumentStack tmpStack = new DocumentStack();
if (destination != null) {
tmpStack.push(destination);
tmpStack.addAll(curStack);
} else {
tmpStack = curStack;
}
FileOperations.copy(getActivity(), docs, tmpStack);
}
use of com.android.documentsui.model.DocumentStack in project platform_frameworks_base by android.
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);
}
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;
}
Aggregations