Search in sources :

Example 1 with CollectCategory

use of com.alphago.alphago.model.CollectCategory in project Alphago by Onedelay.

the class DbHelper method categoryAllSelect.

public List<CollectCategory> categoryAllSelect() {
    SQLiteDatabase db = getReadableDatabase();
    String[] projection = { "*" };
    Cursor c = db.query(CategoryEntry.TABLE_NAME, projection, null, null, null, null, null);
    String selection = CardBookEntry.COLUMN_NAME_CATEGORY + " = ?";
    List<CollectCategory> categoryList = new ArrayList<>();
    while (c.moveToNext()) {
        long categoryId = c.getLong(c.getColumnIndexOrThrow(CategoryEntry._ID));
        String category = c.getString(c.getColumnIndexOrThrow(CategoryEntry.COLUMN_NAME_LABEL));
        String filePath = c.getString(c.getColumnIndexOrThrow(CategoryEntry.COLUMN_NAME_PATH));
        String[] selectionArgs = { String.valueOf(categoryId) };
        Cursor cards = db.query(CardBookEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, null);
        categoryList.add(new CollectCategory(categoryId, category, filePath, getAchievementRate(categoryId)));
        cards.close();
    }
    c.close();
    return categoryList;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) CollectCategory(com.alphago.alphago.model.CollectCategory) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor)

Example 2 with CollectCategory

use of com.alphago.alphago.model.CollectCategory in project Alphago by Onedelay.

the class CollectionActivity method onCategoryClick.

@Override
public void onCategoryClick(Object data) {
    if (data instanceof CollectCategory) {
        long catId = ((CollectCategory) data).getId();
        Intent intent = new Intent(getBaseContext(), CollectionListActivity.class);
        intent.putExtra("categoryId", catId);
        startActivity(intent);
    }
}
Also used : CollectCategory(com.alphago.alphago.model.CollectCategory) Intent(android.content.Intent)

Aggregations

CollectCategory (com.alphago.alphago.model.CollectCategory)2 Intent (android.content.Intent)1 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 ArrayList (java.util.ArrayList)1