Show collection, not wishlist

* src/ryuslash/org/dvdroid/DVDDataSource.java (getListFromCursor):
  (getWatchList):
  (getCollection): New functions.

  (getWishList): Use `getListFromCursor' to retrieve data.

* src/ryuslash/org/dvdroid/DVDroidActivity.java (getData): New
  function.

  (onActivityResult):
  (onCreate): Use `getData' instead of `datasource.getWishlist'.
This commit is contained in:
Tom Willemsen 2012-08-08 23:32:42 +02:00
parent d525b27d44
commit ee4a5927ab
2 changed files with 35 additions and 6 deletions

View file

@ -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();

View file

@ -18,6 +18,11 @@ public class DVDroidActivity extends ListActivity
{
private DVDDataSource datasource;
private List<DVD> getData()
{
return datasource.getCollection();
}
@Override
protected void onActivityResult(int requestCode,
int resultCode,
@ -27,7 +32,7 @@ public class DVDroidActivity extends ListActivity
datasource.open();
ArrayAdapter<DVD> adapter = (ArrayAdapter<DVD>)getListAdapter();
List<DVD> dvds = datasource.getWishlist();
List<DVD> dvds = getData();
adapter.clear();
adapter.addAll(dvds);
@ -44,7 +49,7 @@ public class DVDroidActivity extends ListActivity
datasource = new DVDDataSource(this);
datasource.open();
List<DVD> values = datasource.getWishlist();
List<DVD> values = getData();
ArrayAdapter<DVD> adapter =
new ArrayAdapter<DVD>(this,