summaryrefslogtreecommitdiffstats
path: root/src/ryuslash/org/dvdroid/DVDDataSource.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ryuslash/org/dvdroid/DVDDataSource.java')
-rw-r--r--src/ryuslash/org/dvdroid/DVDDataSource.java32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/ryuslash/org/dvdroid/DVDDataSource.java b/src/ryuslash/org/dvdroid/DVDDataSource.java
index 6658c8d..b9fe166 100644
--- a/src/ryuslash/org/dvdroid/DVDDataSource.java
+++ b/src/ryuslash/org/dvdroid/DVDDataSource.java
@@ -65,24 +65,48 @@ public class DVDDataSource
SQLiteHelper.COLUMN_ID + " = " + id, null);
}
- public List<DVD> getWishlist()
+ public List<DVD> getListFromCursor(Cursor cursor)
{
List<DVD> dvds = new ArrayList<DVD>();
- Cursor cursor = database.query(SQLiteHelper.TABLE_DVD,
- allColumns, "wishlist = 1", null,
- null, null, "title");
cursor.moveToFirst();
+
while(!cursor.isAfterLast()) {
DVD dvd = cursorToDVD(cursor);
+
dvds.add(dvd);
cursor.moveToNext();
}
cursor.close();
+
return dvds;
}
+ public List<DVD> getWishList()
+ {
+ Cursor cursor = database.query(SQLiteHelper.TABLE_DVD,
+ allColumns, "wishlist = 1", null,
+ null, null, "title");
+ return getListFromCursor(cursor);
+ }
+
+ public List<DVD> getWatchList()
+ {
+ Cursor cursor = database.query(SQLiteHelper.TABLE_DVD,
+ allColumns, "watched = 0", null,
+ null, null, "title");
+ return getListFromCursor(cursor);
+ }
+
+ public List<DVD> getCollection()
+ {
+ Cursor cursor = database.query(SQLiteHelper.TABLE_DVD,
+ allColumns, "wishlist = 0", null,
+ null, null, "title");
+ return getListFromCursor(cursor);
+ }
+
private DVD cursorToDVD(Cursor cursor)
{
DVD dvd = new DVD();