summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI
diff options
context:
space:
mode:
authorMakoto Onuki <omakoto@google.com>2015-07-06 17:13:27 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-07-06 17:13:29 +0000
commitdfd6301fa2570ae5b012dd964847531bdfdb3f4b (patch)
tree94b3a82e047cefddff913e4d5d82867cb2acd39e /packages/DocumentsUI
parentc1e3ac321faea5717e1767bf2091334dde310eb7 (diff)
parent14a6df7d7626b5e3c739e4dafd11073a471c91a8 (diff)
downloadframeworks_base-dfd6301fa2570ae5b012dd964847531bdfdb3f4b.zip
frameworks_base-dfd6301fa2570ae5b012dd964847531bdfdb3f4b.tar.gz
frameworks_base-dfd6301fa2570ae5b012dd964847531bdfdb3f4b.tar.bz2
Merge "If user ejects a storage from details, take user to... ... the storage list view" into mnc-dev
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java19
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java7
2 files changed, 26 insertions, 0 deletions
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
index f4be9c5..006f6e9 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryFragment.java
@@ -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);
diff --git a/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java b/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java
index 8e4ec8c..a8a61d2 100644
--- a/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java
+++ b/packages/DocumentsUI/src/com/android/documentsui/DirectoryLoader.java
@@ -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);