@Override public void onReceive(Context context, Intent intent) { Log.d(TAG, intent.getAction()); if (adapter == null) return; if (intent.getExtras() != null) { Folder parentFolder = getParent(); Bundle b = intent.getExtras().getParcelable(IntentIntegrator.EXTRA_DATA); if (b == null) { return; } if (b.getSerializable(IntentIntegrator.EXTRA_FOLDER) instanceof File) { return; } String pFolder = ((Folder) b.getParcelable(IntentIntegrator.EXTRA_FOLDER)).getIdentifier(); if (pFolder.equals(parentFolder.getIdentifier())) { if (intent.getAction().equals(IntentIntegrator.ACTION_DELETE_COMPLETED)) { remove((Node) b.getParcelable(IntentIntegrator.EXTRA_DOCUMENT)); return; } else if (intent.getAction().equals(IntentIntegrator.ACTION_UPLOAD_STARTED)) { String documentName = b.getString(IntentIntegrator.EXTRA_DOCUMENT_NAME); Node node = new NodePlaceHolder( documentName, CreateDocumentRequest.TYPE_ID, Operation.STATUS_RUNNING); ((ProgressNodeAdapter) adapter).replaceNode(node); } else if (intent.getAction().equals(IntentIntegrator.ACTION_UPLOAD_COMPLETED)) { Node node = (Node) b.getParcelable(IntentIntegrator.EXTRA_DOCUMENT); ((ProgressNodeAdapter) adapter).replaceNode(node); } else if (intent.getAction().equals(IntentIntegrator.ACTION_UPDATE_COMPLETED)) { if (b.containsKey(IntentIntegrator.EXTRA_DOCUMENT)) { remove((Node) b.getParcelable(IntentIntegrator.EXTRA_DOCUMENT)); } else { remove((Node) b.getParcelable(IntentIntegrator.EXTRA_NODE)); } Node updatedNode = (Node) b.getParcelable(IntentIntegrator.EXTRA_UPDATED_NODE); ((ProgressNodeAdapter) adapter).replaceNode(updatedNode); } else if (intent.getAction().equals(IntentIntegrator.ACTION_CREATE_FOLDER_COMPLETED)) { Node node = (Node) b.getParcelable(IntentIntegrator.EXTRA_CREATED_FOLDER); ((ProgressNodeAdapter) adapter).replaceNode(node); } else if (intent.getAction().equals(IntentIntegrator.ACTION_FAVORITE_COMPLETED)) { ((ProgressNodeAdapter) adapter).refreshOperations(); } else if (intent.getAction().equals(IntentIntegrator.ACTION_DOWNLOAD_COMPLETED)) { Node node = (Node) b.getParcelable(IntentIntegrator.EXTRA_DOCUMENT); ((ProgressNodeAdapter) adapter).replaceNode(node); } ((ProgressNodeAdapter) adapter).refreshOperations(); refreshList(); gv.setSelection(selectedPosition); } } }
public void createFiles(List<File> files) { if (files.size() == 1) { createFile(files.get(0)); return; } else { OperationsRequestGroup group = new OperationsRequestGroup(getActivity(), SessionUtils.getAccount(getActivity())); for (File file : files) { group.enqueue( new CreateDocumentRequest( importFolder.getIdentifier(), file.getName(), new ContentFileProgressImpl(file))); } BatchOperationManager.getInstance(getActivity()).enqueue(group); if (getActivity() instanceof PublicDispatcherActivity) { getActivity().finish(); } } tmpFile = null; createFile = null; }