am 164d229a: am dfd6301f: Merge "If user ejects a storage from details, take user to... ... the storage list view" into mnc-dev
* commit '164d229a1caad22a8509a86c52e6722d416bf760': If user ejects a storage from details, take user to... ... the storage list view
This commit is contained in:
@@ -50,6 +50,8 @@ import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.OperationCanceledException;
|
||||
import android.os.Parcelable;
|
||||
import android.provider.DocumentsContract;
|
||||
@@ -135,6 +137,8 @@ public class DirectoryFragment extends Fragment {
|
||||
|
||||
private final int mLoaderId = 42;
|
||||
|
||||
private final Handler mHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
public static void showNormal(FragmentManager fm, RootInfo root, DocumentInfo doc, int anim) {
|
||||
show(fm, TYPE_NORMAL, root, doc, null, anim);
|
||||
}
|
||||
@@ -297,6 +301,21 @@ public class DirectoryFragment extends Fragment {
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<DirectoryResult> loader, DirectoryResult result) {
|
||||
if (result == null || result.exception != null) {
|
||||
// onBackPressed does a fragment transaction, which can't be done inside
|
||||
// onLoadFinished
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
activity.onBackPressed();
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if (!isAdded()) return;
|
||||
|
||||
mAdapter.swapResult(result);
|
||||
|
||||
@@ -31,7 +31,10 @@ import android.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.CancellationSignal;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.OperationCanceledException;
|
||||
import android.os.RemoteException;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.provider.DocumentsContract.Document;
|
||||
import android.util.Log;
|
||||
@@ -163,6 +166,10 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> {
|
||||
|
||||
cursor = client.query(
|
||||
mUri, null, null, null, getQuerySortOrder(result.sortOrder), mSignal);
|
||||
if (cursor == null) {
|
||||
throw new RemoteException("Provider returned null");
|
||||
}
|
||||
|
||||
cursor.registerContentObserver(mObserver);
|
||||
|
||||
cursor = new RootCursorWrapper(mUri.getAuthority(), mRoot.rootId, cursor, -1);
|
||||
|
||||
@@ -62,6 +62,9 @@ public class ExternalStorageProvider extends DocumentsProvider {
|
||||
|
||||
public static final String AUTHORITY = "com.android.externalstorage.documents";
|
||||
|
||||
private static final Uri BASE_URI =
|
||||
new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).build();
|
||||
|
||||
// docId format: root:path/to/file
|
||||
|
||||
private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
|
||||
@@ -170,8 +173,10 @@ public class ExternalStorageProvider extends DocumentsProvider {
|
||||
|
||||
Log.d(TAG, "After updating volumes, found " + mRoots.size() + " active roots");
|
||||
|
||||
getContext().getContentResolver()
|
||||
.notifyChange(DocumentsContract.buildRootsUri(AUTHORITY), null, false);
|
||||
// Note this affects content://com.android.externalstorage.documents/root/39BD-07C5
|
||||
// as well as content://com.android.externalstorage.documents/document/*/children,
|
||||
// so just notify on content://com.android.externalstorage.documents/.
|
||||
getContext().getContentResolver().notifyChange(BASE_URI, null, false);
|
||||
}
|
||||
|
||||
private static String[] resolveRootProjection(String[] projection) {
|
||||
|
||||
Reference in New Issue
Block a user