Created
October 21, 2011 17:03
-
-
Save developernotes/1304329 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CrossProcessCursorWrapper extends CursorWrapper implements CrossProcessCursor { | |
| public CrossProcessCursorWrapper(Cursor cursor) { | |
| super(cursor); | |
| } | |
| @Override | |
| public CursorWindow getWindow() { | |
| return null; | |
| } | |
| @Override | |
| public void fillWindow(int position, CursorWindow window) { | |
| if (position < 0 || position > getCount()) { | |
| return; | |
| } | |
| window.acquireReference(); | |
| try { | |
| moveToPosition(position - 1); | |
| window.clear(); | |
| window.setStartPosition(position); | |
| int columnNum = getColumnCount(); | |
| window.setNumColumns(columnNum); | |
| while (moveToNext() && window.allocRow()) { | |
| for (int i = 0; i < columnNum; i++) { | |
| String field = getString(i); | |
| if (field != null) { | |
| if (!window.putString(field, getPosition(), i)) { | |
| window.freeLastRow(); | |
| break; | |
| } | |
| } else { | |
| if (!window.putNull(getPosition(), i)) { | |
| window.freeLastRow(); | |
| break; | |
| } | |
| } | |
| } | |
| } | |
| } catch (IllegalStateException e) { | |
| // simply ignore it | |
| } finally { | |
| window.releaseReference(); | |
| } | |
| } | |
| @Override | |
| public boolean onMove(int oldPosition, int newPosition) { | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment