Created
January 27, 2017 12:05
-
-
Save NikolaDespotoski/c09ace9f13a58883ea8a0c9da6472498 to your computer and use it in GitHub Desktop.
Iterate Cursor in using RxJava
This file contains 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 RxCursorIterable implements Iterable<Cursor> { | |
private Cursor mIterableCursor; | |
public RxCursorIterable(Cursor c) { | |
mIterableCursor = c; | |
} | |
public static RxCursorIterable from(Cursor c) { | |
return new RxCursorIterable(c); | |
} | |
@Override | |
public Iterator<Cursor> iterator() { | |
return RxCursorIterator.from(mIterableCursor); | |
} | |
static class RxCursorIterator implements Iterator<Cursor> { | |
private final Cursor mCursor; | |
public RxCursorIterator(Cursor cursor) { | |
mCursor = cursor; | |
} | |
public static Iterator<Cursor> from(Cursor cursor) { | |
return new RxCursorIterator(cursor); | |
} | |
@Override | |
public boolean hasNext() { | |
return !mCursor.isClosed() && mCursor.moveToNext(); | |
} | |
@Override | |
public Cursor next() { | |
return mCursor; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can we send batch of cursors lets say 10 at a time if yes how?