Created
November 22, 2014 04:06
-
-
Save thuytrinh/0cec49eabac5b7f13f78 to your computer and use it in GitHub Desktop.
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
import android.database.Cursor; | |
import java.util.Iterator; | |
public class IterableCursor implements Iterable<Cursor> { | |
private Cursor cursor; | |
public IterableCursor(Cursor cursor) { | |
this.cursor = cursor; | |
this.cursor.moveToPosition(-1); | |
} | |
@Override | |
public Iterator<Cursor> iterator() { | |
return new Iterator<Cursor>() { | |
@Override | |
public boolean hasNext() { | |
return !cursor.isClosed() && cursor.moveToNext(); | |
} | |
@Override | |
public Cursor next() { | |
return cursor; | |
} | |
@Override | |
public void remove() {} | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment