Loading src/com/android/documentsui/DocumentsApplication.java +2 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public class DocumentsApplication extends Application { final int memoryClassBytes = am.getMemoryClass() * 1024 * 1024; mRoots = new RootsCache(this); mRoots.updateAsync(); mRoots.updateAsync(false); mThumbnails = new ThumbnailCache(memoryClassBytes / 4); Loading Loading @@ -105,7 +105,7 @@ public class DocumentsApplication extends Application { final String packageName = data.getSchemeSpecificPart(); mRoots.updatePackageAsync(packageName); } else { mRoots.updateAsync(); mRoots.updateAsync(true); } } }; Loading src/com/android/documentsui/RootsCache.java +15 −22 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class RootsCache { /** * Gather roots from all known storage providers. */ public void updateAsync() { public void updateAsync(boolean forceRefreshAll) { // NOTE: This method is called when the UI language changes. // For that reason we update our RecentsRoot to reflect Loading @@ -139,14 +139,15 @@ public class RootsCache { | Root.FLAG_SUPPORTS_CREATE)); assert(mRecentsRoot.availableBytes == -1); new UpdateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateTask(forceRefreshAll, null) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } /** * Gather roots from storage providers belonging to given package name. */ public void updatePackageAsync(String packageName) { new UpdateTask(packageName).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateTask(false, packageName).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } /** Loading Loading @@ -223,23 +224,22 @@ public class RootsCache { } private class UpdateTask extends AsyncTask<Void, Void, Void> { private final boolean mForceRefreshAll; private final String mForceRefreshPackage; private final Multimap<String, RootInfo> mTaskRoots = ArrayListMultimap.create(); private final HashSet<String> mTaskStoppedAuthorities = new HashSet<>(); /** * Update all roots. */ public UpdateTask() { this(null); } /** * Force update roots belonging to given package name. Other roots will * be copied from cached {@link #mRoots} values. * Create task to update roots cache. * * @param forceRefreshAll when true, all previously cached values for * all packages should be ignored. * @param forceRefreshPackage when non-null, all previously cached * values for this specific package should be ignored. */ public UpdateTask(String forceRefreshPackage) { public UpdateTask(boolean forceRefreshAll, String forceRefreshPackage) { mForceRefreshAll = forceRefreshAll; mForceRefreshPackage = forceRefreshPackage; } Loading @@ -247,14 +247,6 @@ public class RootsCache { protected Void doInBackground(Void... params) { final long start = SystemClock.elapsedRealtime(); if (mForceRefreshPackage != null) { // We must have previously cached values to fill in non-matching // packages, so wait around for successful first load. if (!waitForFirstLoad()) { return null; } } mTaskRoots.put(mRecentsRoot.authority, mRecentsRoot); final ContentResolver resolver = mContext.getContentResolver(); Loading Loading @@ -300,7 +292,8 @@ public class RootsCache { return; } final boolean forceRefresh = Objects.equals(mForceRefreshPackage, info.packageName); final boolean forceRefresh = mForceRefreshAll || Objects.equals(info.packageName, mForceRefreshPackage); mTaskRoots.putAll(info.authority, loadRootsForAuthority(mContext.getContentResolver(), info.authority, forceRefresh)); } Loading Loading
src/com/android/documentsui/DocumentsApplication.java +2 −2 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ public class DocumentsApplication extends Application { final int memoryClassBytes = am.getMemoryClass() * 1024 * 1024; mRoots = new RootsCache(this); mRoots.updateAsync(); mRoots.updateAsync(false); mThumbnails = new ThumbnailCache(memoryClassBytes / 4); Loading Loading @@ -105,7 +105,7 @@ public class DocumentsApplication extends Application { final String packageName = data.getSchemeSpecificPart(); mRoots.updatePackageAsync(packageName); } else { mRoots.updateAsync(); mRoots.updateAsync(true); } } }; Loading
src/com/android/documentsui/RootsCache.java +15 −22 Original line number Diff line number Diff line Loading @@ -122,7 +122,7 @@ public class RootsCache { /** * Gather roots from all known storage providers. */ public void updateAsync() { public void updateAsync(boolean forceRefreshAll) { // NOTE: This method is called when the UI language changes. // For that reason we update our RecentsRoot to reflect Loading @@ -139,14 +139,15 @@ public class RootsCache { | Root.FLAG_SUPPORTS_CREATE)); assert(mRecentsRoot.availableBytes == -1); new UpdateTask().executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateTask(forceRefreshAll, null) .executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } /** * Gather roots from storage providers belonging to given package name. */ public void updatePackageAsync(String packageName) { new UpdateTask(packageName).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); new UpdateTask(false, packageName).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); } /** Loading Loading @@ -223,23 +224,22 @@ public class RootsCache { } private class UpdateTask extends AsyncTask<Void, Void, Void> { private final boolean mForceRefreshAll; private final String mForceRefreshPackage; private final Multimap<String, RootInfo> mTaskRoots = ArrayListMultimap.create(); private final HashSet<String> mTaskStoppedAuthorities = new HashSet<>(); /** * Update all roots. */ public UpdateTask() { this(null); } /** * Force update roots belonging to given package name. Other roots will * be copied from cached {@link #mRoots} values. * Create task to update roots cache. * * @param forceRefreshAll when true, all previously cached values for * all packages should be ignored. * @param forceRefreshPackage when non-null, all previously cached * values for this specific package should be ignored. */ public UpdateTask(String forceRefreshPackage) { public UpdateTask(boolean forceRefreshAll, String forceRefreshPackage) { mForceRefreshAll = forceRefreshAll; mForceRefreshPackage = forceRefreshPackage; } Loading @@ -247,14 +247,6 @@ public class RootsCache { protected Void doInBackground(Void... params) { final long start = SystemClock.elapsedRealtime(); if (mForceRefreshPackage != null) { // We must have previously cached values to fill in non-matching // packages, so wait around for successful first load. if (!waitForFirstLoad()) { return null; } } mTaskRoots.put(mRecentsRoot.authority, mRecentsRoot); final ContentResolver resolver = mContext.getContentResolver(); Loading Loading @@ -300,7 +292,8 @@ public class RootsCache { return; } final boolean forceRefresh = Objects.equals(mForceRefreshPackage, info.packageName); final boolean forceRefresh = mForceRefreshAll || Objects.equals(info.packageName, mForceRefreshPackage); mTaskRoots.putAll(info.authority, loadRootsForAuthority(mContext.getContentResolver(), info.authority, forceRefresh)); } Loading