Loading src/com/android/documentsui/dirlist/DirectoryFragment.java +111 −151 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import android.content.Loader; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; Loading Loading @@ -905,24 +904,21 @@ public class DirectoryFragment extends Fragment } } // Support for opening multiple documents is currently exclusive to DocumentsActivity. private void openDocuments(final Selection selected) { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_OPEN); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // TODO: Implement support in Files activity for opening multiple docs. // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); BaseActivity.get(DirectoryFragment.this).onDocumentsPicked(docs); } }.execute(selected); } private void shareDocuments(final Selection selected) { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_SHARE); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); Intent intent; // Filter out directories and virtual files - those can't be shared. Loading Loading @@ -964,8 +960,6 @@ public class DirectoryFragment extends Fragment intent = Intent.createChooser(intent, getActivity().getText(R.string.share_via)); startActivity(intent); } }.execute(selected); } private String generateDeleteMessage(final List<DocumentInfo> docs) { String message; Loading Loading @@ -1021,21 +1015,15 @@ public class DirectoryFragment extends Fragment return true; } // private boolean onSelect(DocumentDetails doc) { // mSelectionMgr.toggleSelection(doc.getModelId()); // mSelectionMgr.setSelectionRangeBegin(doc.getAdapterPosition()); // return true; // } private void deleteDocuments(final Selection selected) { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_DELETE); assert(!selected.isEmpty()); final DocumentInfo srcParent = getDisplayState().stack.peek(); new GetDocumentsTask() { @Override void onDocumentsReady(final List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null); Loading Loading @@ -1088,8 +1076,6 @@ public class DirectoryFragment extends Fragment .setNegativeButton(android.R.string.cancel, null) .show(); } }.execute(selected); } private void transferDocuments(final Selection selected, final @OpType int mode) { if(mode == FileOperationService.OPERATION_COPY) { Loading Loading @@ -1135,9 +1121,9 @@ public class DirectoryFragment extends Fragment ? R.string.menu_move : R.string.menu_copy; intent.putExtra(DocumentsContract.EXTRA_PROMPT, getResources().getString(drawerTitleId)); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); // Determine if there is a directory in the set of documents // to be copied? Why? Directory creation isn't supported by some roots // (like Downloads). This informs DocumentsActivity (the "picker") Loading @@ -1150,9 +1136,6 @@ public class DirectoryFragment extends Fragment startActivityForResult(intent, REQUEST_COPY_DESTINATION); } }.execute(selected); } private static boolean hasDirectory(List<DocumentInfo> docs) { for (DocumentInfo info : docs) { if (Document.MIME_TYPE_DIR.equals(info.mimeType)) { Loading @@ -1169,13 +1152,10 @@ public class DirectoryFragment extends Fragment // Rename option is only available in menu when 1 document selected assert(selected.size() == 1); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); RenameDocumentFragment.show(getFragmentManager(), docs.get(0)); } }.execute(selected); } @Override public void initDocumentHolder(DocumentHolder holder) { Loading Loading @@ -1484,26 +1464,6 @@ public class DirectoryFragment extends Fragment return null; } /** * Abstract task providing support for loading documents *off* * the main thread. And if it isn't obvious, creating a list * of documents (especially large lists) can be pretty expensive. */ private abstract class GetDocumentsTask extends AsyncTask<Selection, Void, List<DocumentInfo>> { @Override protected final List<DocumentInfo> doInBackground(Selection... selected) { return mModel.getDocuments(selected[0]); } @Override protected final void onPostExecute(List<DocumentInfo> docs) { onDocumentsReady(docs); } abstract void onDocumentsReady(List<DocumentInfo> docs); } @Override public boolean isSelected(String modelId) { return mSelectionMgr.getSelection().contains(modelId); Loading Loading
src/com/android/documentsui/dirlist/DirectoryFragment.java +111 −151 Original line number Diff line number Diff line Loading @@ -39,7 +39,6 @@ import android.content.Loader; import android.database.Cursor; import android.graphics.drawable.Drawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Bundle; import android.os.Handler; import android.os.Parcelable; Loading Loading @@ -905,24 +904,21 @@ public class DirectoryFragment extends Fragment } } // Support for opening multiple documents is currently exclusive to DocumentsActivity. private void openDocuments(final Selection selected) { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_OPEN); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // TODO: Implement support in Files activity for opening multiple docs. // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); BaseActivity.get(DirectoryFragment.this).onDocumentsPicked(docs); } }.execute(selected); } private void shareDocuments(final Selection selected) { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_SHARE); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); Intent intent; // Filter out directories and virtual files - those can't be shared. Loading Loading @@ -964,8 +960,6 @@ public class DirectoryFragment extends Fragment intent = Intent.createChooser(intent, getActivity().getText(R.string.share_via)); startActivity(intent); } }.execute(selected); } private String generateDeleteMessage(final List<DocumentInfo> docs) { String message; Loading Loading @@ -1021,21 +1015,15 @@ public class DirectoryFragment extends Fragment return true; } // private boolean onSelect(DocumentDetails doc) { // mSelectionMgr.toggleSelection(doc.getModelId()); // mSelectionMgr.setSelectionRangeBegin(doc.getAdapterPosition()); // return true; // } private void deleteDocuments(final Selection selected) { Metrics.logUserAction(getContext(), Metrics.USER_ACTION_DELETE); assert(!selected.isEmpty()); final DocumentInfo srcParent = getDisplayState().stack.peek(); new GetDocumentsTask() { @Override void onDocumentsReady(final List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); TextView message = (TextView) mInflater.inflate(R.layout.dialog_delete_confirmation, null); Loading Loading @@ -1088,8 +1076,6 @@ public class DirectoryFragment extends Fragment .setNegativeButton(android.R.string.cancel, null) .show(); } }.execute(selected); } private void transferDocuments(final Selection selected, final @OpType int mode) { if(mode == FileOperationService.OPERATION_COPY) { Loading Loading @@ -1135,9 +1121,9 @@ public class DirectoryFragment extends Fragment ? R.string.menu_move : R.string.menu_copy; intent.putExtra(DocumentsContract.EXTRA_PROMPT, getResources().getString(drawerTitleId)); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); // Determine if there is a directory in the set of documents // to be copied? Why? Directory creation isn't supported by some roots // (like Downloads). This informs DocumentsActivity (the "picker") Loading @@ -1150,9 +1136,6 @@ public class DirectoryFragment extends Fragment startActivityForResult(intent, REQUEST_COPY_DESTINATION); } }.execute(selected); } private static boolean hasDirectory(List<DocumentInfo> docs) { for (DocumentInfo info : docs) { if (Document.MIME_TYPE_DIR.equals(info.mimeType)) { Loading @@ -1169,13 +1152,10 @@ public class DirectoryFragment extends Fragment // Rename option is only available in menu when 1 document selected assert(selected.size() == 1); new GetDocumentsTask() { @Override void onDocumentsReady(List<DocumentInfo> docs) { // Model must be accessed in UI thread, since underlying cursor is not threadsafe. List<DocumentInfo> docs = mModel.getDocuments(selected); RenameDocumentFragment.show(getFragmentManager(), docs.get(0)); } }.execute(selected); } @Override public void initDocumentHolder(DocumentHolder holder) { Loading Loading @@ -1484,26 +1464,6 @@ public class DirectoryFragment extends Fragment return null; } /** * Abstract task providing support for loading documents *off* * the main thread. And if it isn't obvious, creating a list * of documents (especially large lists) can be pretty expensive. */ private abstract class GetDocumentsTask extends AsyncTask<Selection, Void, List<DocumentInfo>> { @Override protected final List<DocumentInfo> doInBackground(Selection... selected) { return mModel.getDocuments(selected[0]); } @Override protected final void onPostExecute(List<DocumentInfo> docs) { onDocumentsReady(docs); } abstract void onDocumentsReady(List<DocumentInfo> docs); } @Override public boolean isSelected(String modelId) { return mSelectionMgr.getSelection().contains(modelId); Loading