Loading src/com/android/documentsui/DirectoryLoader.java +21 −2 Original line number Diff line number Diff line Loading @@ -281,10 +281,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 @@ -313,4 +314,22 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { FileUtils.closeQuietly(mResult); mResult = null; } private boolean checkIfCursorStale(DirectoryResult result) { if (result == null || result.cursor == null || result.cursor.isClosed()) { return true; } Cursor cursor = result.cursor; try { cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { if (!cursor.moveToNext()) { return true; } } } catch (Exception e) { return true; } return false; } } src/com/android/documentsui/MultiRootDocumentsLoader.java +21 −2 Original line number Diff line number Diff line Loading @@ -303,10 +303,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 @@ -456,4 +457,22 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory mIsClosed = true; } } private boolean checkIfCursorStale(DirectoryResult result) { if (result == null || result.cursor == null || result.cursor.isClosed()) { return true; } Cursor cursor = result.cursor; try { cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { 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 @@ -281,10 +281,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 @@ -313,4 +314,22 @@ public class DirectoryLoader extends AsyncTaskLoader<DirectoryResult> { FileUtils.closeQuietly(mResult); mResult = null; } private boolean checkIfCursorStale(DirectoryResult result) { if (result == null || result.cursor == null || result.cursor.isClosed()) { return true; } Cursor cursor = result.cursor; try { cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { if (!cursor.moveToNext()) { return true; } } } catch (Exception e) { return true; } return false; } }
src/com/android/documentsui/MultiRootDocumentsLoader.java +21 −2 Original line number Diff line number Diff line Loading @@ -303,10 +303,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 @@ -456,4 +457,22 @@ public abstract class MultiRootDocumentsLoader extends AsyncTaskLoader<Directory mIsClosed = true; } } private boolean checkIfCursorStale(DirectoryResult result) { if (result == null || result.cursor == null || result.cursor.isClosed()) { return true; } Cursor cursor = result.cursor; try { cursor.moveToPosition(-1); for (int pos = 0; pos < cursor.getCount(); ++pos) { if (!cursor.moveToNext()) { return true; } } } catch (Exception e) { return true; } return false; } }