* commit '6599c12843fe3c82a5a02978afeb262eeb76f3f4': Update roots when data cleared, refresh UI.
This commit is contained in:
@ -75,6 +75,7 @@ public class DocumentsApplication extends Application {
|
|||||||
packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
packageFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||||
packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
packageFilter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||||
packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
packageFilter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||||
|
packageFilter.addAction(Intent.ACTION_PACKAGE_DATA_CLEARED);
|
||||||
packageFilter.addDataScheme("package");
|
packageFilter.addDataScheme("package");
|
||||||
registerReceiver(mCacheReceiver, packageFilter);
|
registerReceiver(mCacheReceiver, packageFilter);
|
||||||
|
|
||||||
|
@ -60,8 +60,8 @@ import java.util.concurrent.TimeUnit;
|
|||||||
public class RootsCache {
|
public class RootsCache {
|
||||||
private static final boolean LOGD = true;
|
private static final boolean LOGD = true;
|
||||||
|
|
||||||
// TODO: cache roots in local provider to avoid spinning up backends
|
public static final Uri sNotificationUri = Uri.parse(
|
||||||
// TODO: root updates should trigger UI refresh
|
"content://com.android.documentsui.roots/");
|
||||||
|
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final ContentObserver mObserver;
|
private final ContentObserver mObserver;
|
||||||
@ -201,6 +201,7 @@ public class RootsCache {
|
|||||||
mStoppedAuthorities = mTaskStoppedAuthorities;
|
mStoppedAuthorities = mTaskStoppedAuthorities;
|
||||||
}
|
}
|
||||||
mFirstLoad.countDown();
|
mFirstLoad.countDown();
|
||||||
|
resolver.notifyChange(sNotificationUri, null, false);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@ import com.android.documentsui.model.RootInfo;
|
|||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
public class RootsLoader extends AsyncTaskLoader<Collection<RootInfo>> {
|
public class RootsLoader extends AsyncTaskLoader<Collection<RootInfo>> {
|
||||||
|
private final ForceLoadContentObserver mObserver = new ForceLoadContentObserver();
|
||||||
|
|
||||||
private final RootsCache mRoots;
|
private final RootsCache mRoots;
|
||||||
private final State mState;
|
private final State mState;
|
||||||
|
|
||||||
@ -34,6 +36,9 @@ public class RootsLoader extends AsyncTaskLoader<Collection<RootInfo>> {
|
|||||||
super(context);
|
super(context);
|
||||||
mRoots = roots;
|
mRoots = roots;
|
||||||
mState = state;
|
mState = state;
|
||||||
|
|
||||||
|
getContext().getContentResolver()
|
||||||
|
.registerContentObserver(RootsCache.sNotificationUri, false, mObserver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,5 +82,7 @@ public class RootsLoader extends AsyncTaskLoader<Collection<RootInfo>> {
|
|||||||
onStopLoading();
|
onStopLoading();
|
||||||
|
|
||||||
mResult = null;
|
mResult = null;
|
||||||
|
|
||||||
|
getContext().getContentResolver().unregisterContentObserver(mObserver);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user