Loading src/com/android/documentsui/sorting/SortingCursorWrapper.java +6 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.documentsui.base.DocumentInfo.getCursorString; import android.database.AbstractCursor; import android.database.Cursor; import android.os.Bundle; import android.provider.DocumentsContract.Document; import com.android.documentsui.base.Shared; Loading Loading @@ -156,6 +157,11 @@ class SortingCursorWrapper extends AbstractCursor { return mCursor.isNull(column); } @Override public Bundle getExtras() { return mCursor.getExtras(); } /** * @return Timestamp for the given document. Some docs (e.g. active downloads) have a null * timestamp - these will be replaced with MAX_LONG so that such files get sorted to the top Loading tests/common/com/android/documentsui/StubProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -766,7 +766,7 @@ public class StubProvider extends DocumentsProvider { this.file = file; this.documentId = getDocumentIdForFile(file); this.mimeType = Document.MIME_TYPE_DIR; this.streamTypes = new ArrayList<String>(); this.streamTypes = new ArrayList<>(); this.flags = Document.FLAG_DIR_SUPPORTS_CREATE | Document.FLAG_SUPPORTS_RENAME; this.parentId = null; this.rootInfo = rootInfo; Loading tests/unit/com/android/documentsui/sorting/SortingCursorWrapperTest.java +23 −1 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ package com.android.documentsui.sorting; import static com.android.documentsui.base.DocumentInfo.getCursorString; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import android.database.Cursor; import android.database.MatrixCursor; import android.os.Bundle; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; import android.support.test.runner.AndroidJUnit4; Loading Loading @@ -366,6 +367,27 @@ public class SortingCursorWrapperTest { } } @Test public void testReturnsWrappedExtras() { MatrixCursor c = new MatrixCursor(COLUMNS); Bundle extras = new Bundle(); extras.putBoolean(DocumentsContract.EXTRA_LOADING, true); extras.putString(DocumentsContract.EXTRA_INFO, "cheddar"); extras.putString(DocumentsContract.EXTRA_ERROR, "flop"); c.setExtras(extras); // set sorting to avoid an NPE. sortModel.sortByUser( SortModel.SORT_DIMENSION_ID_DATE, SortDimension.SORT_DIRECTION_DESCENDING); Bundle actual = createSortingCursorWrapper(c).getExtras(); assertTrue(actual.getBoolean(DocumentsContract.EXTRA_LOADING, false)); assertEquals("cheddar", actual.getString(DocumentsContract.EXTRA_INFO)); assertEquals("flop", actual.getString(DocumentsContract.EXTRA_ERROR)); } private Cursor createSortingCursorWrapper() { return createSortingCursorWrapper(cursor); } Loading Loading
src/com/android/documentsui/sorting/SortingCursorWrapper.java +6 −0 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.documentsui.base.DocumentInfo.getCursorString; import android.database.AbstractCursor; import android.database.Cursor; import android.os.Bundle; import android.provider.DocumentsContract.Document; import com.android.documentsui.base.Shared; Loading Loading @@ -156,6 +157,11 @@ class SortingCursorWrapper extends AbstractCursor { return mCursor.isNull(column); } @Override public Bundle getExtras() { return mCursor.getExtras(); } /** * @return Timestamp for the given document. Some docs (e.g. active downloads) have a null * timestamp - these will be replaced with MAX_LONG so that such files get sorted to the top Loading
tests/common/com/android/documentsui/StubProvider.java +1 −1 Original line number Diff line number Diff line Loading @@ -766,7 +766,7 @@ public class StubProvider extends DocumentsProvider { this.file = file; this.documentId = getDocumentIdForFile(file); this.mimeType = Document.MIME_TYPE_DIR; this.streamTypes = new ArrayList<String>(); this.streamTypes = new ArrayList<>(); this.flags = Document.FLAG_DIR_SUPPORTS_CREATE | Document.FLAG_SUPPORTS_RENAME; this.parentId = null; this.rootInfo = rootInfo; Loading
tests/unit/com/android/documentsui/sorting/SortingCursorWrapperTest.java +23 −1 Original line number Diff line number Diff line Loading @@ -17,13 +17,14 @@ package com.android.documentsui.sorting; import static com.android.documentsui.base.DocumentInfo.getCursorString; import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; import android.database.Cursor; import android.database.MatrixCursor; import android.os.Bundle; import android.provider.DocumentsContract; import android.provider.DocumentsContract.Document; import android.support.test.runner.AndroidJUnit4; Loading Loading @@ -366,6 +367,27 @@ public class SortingCursorWrapperTest { } } @Test public void testReturnsWrappedExtras() { MatrixCursor c = new MatrixCursor(COLUMNS); Bundle extras = new Bundle(); extras.putBoolean(DocumentsContract.EXTRA_LOADING, true); extras.putString(DocumentsContract.EXTRA_INFO, "cheddar"); extras.putString(DocumentsContract.EXTRA_ERROR, "flop"); c.setExtras(extras); // set sorting to avoid an NPE. sortModel.sortByUser( SortModel.SORT_DIMENSION_ID_DATE, SortDimension.SORT_DIRECTION_DESCENDING); Bundle actual = createSortingCursorWrapper(c).getExtras(); assertTrue(actual.getBoolean(DocumentsContract.EXTRA_LOADING, false)); assertEquals("cheddar", actual.getString(DocumentsContract.EXTRA_INFO)); assertEquals("flop", actual.getString(DocumentsContract.EXTRA_ERROR)); } private Cursor createSortingCursorWrapper() { return createSortingCursorWrapper(cursor); } Loading