use of com.alphago.alphago.model.CardBook in project Alphago by Onedelay.
the class GameWordActivity2 method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game_word2);
// Load CardBook in Database
categoryList = dbHelper.categorySelect();
int catSize = categoryList.size();
long catId = 0;
int carSize = 0;
for (int i = 0; i < catSize; i++) {
catId = categoryList.get(i).getId();
// 해당 카테고리의 카드북 반환
List<CardBook> tmpList = dbHelper.cardbookSelect(catId);
// 카드북의 사이즈 반환
carSize = tmpList.size();
// 사이즈만큼 돌면서 카드북에 추가
for (int j = 0; j < carSize; j++) {
cardBookList.add(tmpList.get(j));
}
}
btn_wgame_exit = (ImageButton) findViewById(R.id.btn_wgame_exit);
btn_wgame_next = (ImageButton) findViewById(R.id.btn_wgame_next);
btn_wgame_ex1 = (Button) findViewById(R.id.btn_wgame_ex1);
btn_wgame_ex2 = (Button) findViewById(R.id.btn_wgame_ex2);
btn_wgame_ex3 = (Button) findViewById(R.id.btn_wgame_ex3);
btn_wgame_ex4 = (Button) findViewById(R.id.btn_wgame_ex4);
img_wgame_tvqst = (ImageView) findViewById(R.id.img_wgame_tvqst);
tv_wgame_tvqst = (TextView) findViewById(R.id.tv_wgame_tvqst);
img_wgame_qst = (ImageView) findViewById(R.id.img_wgame_qst);
final Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
// First Question
if (qcount == 0) {
// CreateQuestion(TestData.dataID.length);
CreateQuestion(cardBookList.size());
SetQuestion(qcount);
qcount++;
}
btn_wgame_exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(GameWordActivity2.this, MainActivity.class);
startActivity(intent);
finish();
}
});
btn_wgame_next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Show Result
if (result == true) {
img_wgame_tvqst.setImageResource(R.drawable.img_right);
res[qcount - 1] = true;
} else {
vibe.vibrate(500);
img_wgame_tvqst.setImageResource(R.drawable.img_wrong);
res[qcount - 1] = false;
}
// Change the screen after 1.5 seconds
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (qcount == 10) {
Intent intent = new Intent(GameWordActivity2.this, GameResultActivity.class);
intent.putExtra("result", res);
intent.putExtra("type", 0);
intent.putExtra("gameDifficulty", getIntent().getIntExtra("gameDifficulty", 0));
startActivity(intent);
finish();
} else {
// tv_wgame_tvqst.setText("Q" + (qcount + 1) + " " + cardBookList.get(qst_num[qcount]).getName());
tv_wgame_tvqst.setText("Q" + (qcount + 1) + " ");
SetQuestion(qcount);
qcount++;
}
}
}, 1500);
// finish();
}
});
}
use of com.alphago.alphago.model.CardBook in project Alphago by Onedelay.
the class CardBookListActivity method onCardClick.
@Override
public void onCardClick(Object data) {
if (data instanceof CardBook) {
Intent intent = new Intent(this, CardListActivity.class);
intent.putExtra("label", ((CardBook) data).getName());
intent.putExtra("labelId", ((CardBook) data).getId());
startActivity(intent);
}
}
Aggregations