use of com.alphago.alphago.model.Category in project Alphago by Onedelay.
the class WordLearningActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_word_learning);
learnImage = (ImageView) findViewById(R.id.learn_image);
learnLabel = (TextView) findViewById(R.id.learn_label);
tts = new TTSHelper(this);
findViewById(btn_learn_exit).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
findViewById(R.id.btn_learn_pre).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (index > 0) {
index--;
setWord(index);
} else {
Toast.makeText(WordLearningActivity.this, "First card.", Toast.LENGTH_SHORT).show();
}
}
});
findViewById(R.id.btn_learn_next).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (index < cards.size() - 1) {
index++;
setWord(index);
} else {
Toast.makeText(WordLearningActivity.this, "Last card.", Toast.LENGTH_SHORT).show();
}
}
});
findViewById(R.id.btn_pronounce).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (learnLabel.getText().toString().equals("usb"))
tts.speak("U.S.B");
else
tts.speak(learnLabel.getText().toString());
}
});
DbHelper dbHelper = new DbHelper(getBaseContext());
int type = getIntent().getIntExtra("learning_type", 0);
if (type == TYPE_ALL) {
List<Category> categories = dbHelper.categorySelect();
List<CardBook> cardBooks;
// 현재 카드북으로 되어있지만, 카드에서 중복 제거 후 구현해야함.
for (Category category : categories) {
cardBooks = dbHelper.cardbookSelect(category.getId());
cards.addAll(cardBooks);
}
} else if (type == TYPE_ALBUM) {
ArrayList<Long> list = (ArrayList<Long>) getIntent().getSerializableExtra("category_select_list");
for (Long id : list) {
List<CardBook> cardBooks = dbHelper.cardbookSelect(id);
cards.addAll(cardBooks);
}
} else {
Toast.makeText(this, "TYPE ERROR", Toast.LENGTH_SHORT).show();
finish();
}
if (!cards.isEmpty()) {
Collections.shuffle(cards);
setWord(index);
} else {
Toast.makeText(WordLearningActivity.this, "학습할 목록이 없습니다.", Toast.LENGTH_SHORT).show();
}
}
use of com.alphago.alphago.model.Category in project Alphago by Onedelay.
the class CardBookActivity method onCardClick.
@Override
public void onCardClick(Object data) {
if (data instanceof Category) {
long catId = ((Category) data).getId();
if (!isSelectMode) {
Intent intent = new Intent(getBaseContext(), CardBookListActivity.class);
intent.putExtra("categoryId", catId);
intent.putExtra("category", ((Category) data).getLabel());
startActivity(intent);
} else {
if (!selectList.contains(catId)) {
selectList.add(catId);
((Category) data).setSelect(true);
} else {
selectList.remove(catId);
((Category) data).setSelect(false);
}
adapter.notifyDataSetChanged();
}
}
}
use of com.alphago.alphago.model.Category in project Alphago by Onedelay.
the class DbHelper method categorySelect.
public List<Category> categorySelect() {
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<Category> 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);
if (cards.moveToNext())
categoryList.add(new Category(categoryId, category, filePath));
cards.close();
}
c.close();
return categoryList;
}
Aggregations