Loading src/com/android/documentsui/DirectoryLoader.java +21 −2 Original line number Diff line number Diff line Loading @@ -279,10 +279,11 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { @Override protected void onStartLoading() { if (mResult != null) { boolean isCursorStale = checkIfCursorStale(mResult); if (mResult != null && !isCursorStale) { deliverResult(mResult); } if (takeContentChanged() || mResult == null) { if (takeContentChanged() || mResult == null || isCursorStale) { forceLoad(); } } Loading Loading @@ -311,4 +312,22 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { FileUtils.closeQuietly(mResult); mResult = null; } private boolean checkIfCursorStale(DirectoryResult result) { if (mResult == null) { return true; } Cursor cursor = result.cursor; cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { try { if (!cursor.moveToNext()) { return true; } } catch (Exception e) { return true; } } return false; } } src/com/android/documentsui/MultiRootDocumentsLoader.java +21 −4 Original line number Diff line number Diff line Loading @@ -104,8 +104,6 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory * @param state current state * @param executors the executors of authorities * @param fileTypeMap the map of mime types and file types. * @param lock the selection lock * @param contentChangedCallback callback when content changed */ public MultiRootDocumentsLoader(Context context, ProvidersAccess providers, State state, Lookup<String, Executor> executors, Lookup<String, String> fileTypeMap) { Loading Loading @@ -304,10 +302,11 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory @Override protected void onStartLoading() { if (mResult != null) { boolean isCursorStale = checkIfCursorStale(mResult); if (mResult != null && !isCursorStale) { deliverResult(mResult); } if (takeContentChanged() || mResult == null) { if (takeContentChanged() || mResult == null || isCursorStale) { forceLoad(); } } Loading Loading @@ -457,4 +456,22 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory mIsClosed = true; } } private boolean checkIfCursorStale(DirectoryResult result) { if (mResult == null) { return true; } Cursor cursor = result.cursor; cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { try { if (!cursor.moveToNext()) { return true; } } catch (Exception e) { return true; } } return false; } } Loading
src/com/android/documentsui/DirectoryLoader.java +21 −2 Original line number Diff line number Diff line Loading @@ -279,10 +279,11 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { @Override protected void onStartLoading() { if (mResult != null) { boolean isCursorStale = checkIfCursorStale(mResult); if (mResult != null && !isCursorStale) { deliverResult(mResult); } if (takeContentChanged() || mResult == null) { if (takeContentChanged() || mResult == null || isCursorStale) { forceLoad(); } } Loading Loading @@ -311,4 +312,22 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { FileUtils.closeQuietly(mResult); mResult = null; } private boolean checkIfCursorStale(DirectoryResult result) { if (mResult == null) { return true; } Cursor cursor = result.cursor; cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { try { if (!cursor.moveToNext()) { return true; } } catch (Exception e) { return true; } } return false; } }
src/com/android/documentsui/MultiRootDocumentsLoader.java +21 −4 Original line number Diff line number Diff line Loading @@ -104,8 +104,6 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory * @param state current state * @param executors the executors of authorities * @param fileTypeMap the map of mime types and file types. * @param lock the selection lock * @param contentChangedCallback callback when content changed */ public MultiRootDocumentsLoader(Context context, ProvidersAccess providers, State state, Lookup<String, Executor> executors, Lookup<String, String> fileTypeMap) { Loading Loading @@ -304,10 +302,11 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory @Override protected void onStartLoading() { if (mResult != null) { boolean isCursorStale = checkIfCursorStale(mResult); if (mResult != null && !isCursorStale) { deliverResult(mResult); } if (takeContentChanged() || mResult == null) { if (takeContentChanged() || mResult == null || isCursorStale) { forceLoad(); } } Loading Loading @@ -457,4 +456,22 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory mIsClosed = true; } } private boolean checkIfCursorStale(DirectoryResult result) { if (mResult == null) { return true; } Cursor cursor = result.cursor; cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { try { if (!cursor.moveToNext()) { return true; } } catch (Exception e) { return true; } } return false; } }