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:
parent
d525b27d44
commit
ee4a5927ab
2 changed files with 35 additions and 6 deletions
|
@ -65,24 +65,48 @@ public class DVDDataSource
|
||||||
SQLiteHelper.COLUMN_ID + " = " + id, null);
|
SQLiteHelper.COLUMN_ID + " = " + id, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<DVD> getWishlist()
|
public List<DVD> getListFromCursor(Cursor cursor)
|
||||||
{
|
{
|
||||||
List<DVD> dvds = new ArrayList<DVD>();
|
List<DVD> dvds = new ArrayList<DVD>();
|
||||||
Cursor cursor = database.query(SQLiteHelper.TABLE_DVD,
|
|
||||||
allColumns, "wishlist = 1", null,
|
|
||||||
null, null, "title");
|
|
||||||
|
|
||||||
cursor.moveToFirst();
|
cursor.moveToFirst();
|
||||||
|
|
||||||
while(!cursor.isAfterLast()) {
|
while(!cursor.isAfterLast()) {
|
||||||
DVD dvd = cursorToDVD(cursor);
|
DVD dvd = cursorToDVD(cursor);
|
||||||
|
|
||||||
dvds.add(dvd);
|
dvds.add(dvd);
|
||||||
cursor.moveToNext();
|
cursor.moveToNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.close();
|
cursor.close();
|
||||||
|
|
||||||
return dvds;
|
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)
|
private DVD cursorToDVD(Cursor cursor)
|
||||||
{
|
{
|
||||||
DVD dvd = new DVD();
|
DVD dvd = new DVD();
|
||||||
|
|
|
@ -18,6 +18,11 @@ public class DVDroidActivity extends ListActivity
|
||||||
{
|
{
|
||||||
private DVDDataSource datasource;
|
private DVDDataSource datasource;
|
||||||
|
|
||||||
|
private List<DVD> getData()
|
||||||
|
{
|
||||||
|
return datasource.getCollection();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode,
|
protected void onActivityResult(int requestCode,
|
||||||
int resultCode,
|
int resultCode,
|
||||||
|
@ -27,7 +32,7 @@ public class DVDroidActivity extends ListActivity
|
||||||
datasource.open();
|
datasource.open();
|
||||||
|
|
||||||
ArrayAdapter<DVD> adapter = (ArrayAdapter<DVD>)getListAdapter();
|
ArrayAdapter<DVD> adapter = (ArrayAdapter<DVD>)getListAdapter();
|
||||||
List<DVD> dvds = datasource.getWishlist();
|
List<DVD> dvds = getData();
|
||||||
|
|
||||||
adapter.clear();
|
adapter.clear();
|
||||||
adapter.addAll(dvds);
|
adapter.addAll(dvds);
|
||||||
|
@ -44,7 +49,7 @@ public class DVDroidActivity extends ListActivity
|
||||||
datasource = new DVDDataSource(this);
|
datasource = new DVDDataSource(this);
|
||||||
datasource.open();
|
datasource.open();
|
||||||
|
|
||||||
List<DVD> values = datasource.getWishlist();
|
List<DVD> values = getData();
|
||||||
|
|
||||||
ArrayAdapter<DVD> adapter =
|
ArrayAdapter<DVD> adapter =
|
||||||
new ArrayAdapter<DVD>(this,
|
new ArrayAdapter<DVD>(this,
|
||||||
|
|
Loading…
Reference in a new issue