Search in sources :

Example 1 with CardBook

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

the class GameImageActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game_image);
    // 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));
        }
    }
    img_igame_check1 = (ImageView) findViewById(R.id.img_igame_check1);
    img_igame_check2 = (ImageView) findViewById(R.id.img_igame_check2);
    img_igame_check3 = (ImageView) findViewById(R.id.img_igame_check3);
    img_igame_check4 = (ImageView) findViewById(R.id.img_igame_check4);
    btn_igame_exit = (ImageButton) findViewById(R.id.btn_igame_exit);
    btn_igame_next = (ImageButton) findViewById(R.id.btn_igame_next);
    btn_igame_ex1 = (ImageButton) findViewById(R.id.btn_igame_ex1);
    btn_igame_ex2 = (ImageButton) findViewById(R.id.btn_igame_ex2);
    btn_igame_ex3 = (ImageButton) findViewById(R.id.btn_igame_ex3);
    btn_igame_ex4 = (ImageButton) findViewById(R.id.btn_igame_ex4);
    img_igame_tvqst = (ImageView) findViewById(R.id.img_igame_tvqst);
    tv_igame_tvqst = (TextView) findViewById(R.id.tv_igame_tvqst);
    img_igame_qst = (TextView) findViewById(R.id.img_igame_qst);
    final Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    // First Question
    if (qcount == 0) {
        // CreateQuestion(TestData.dataID.length);
        CreateQuestion(cardBookList.size());
        // TestData.dataLabel[qst_num[qcount]]
        img_igame_qst.setText(cardBookList.get(qst_num[qcount]).getName());
        SetQuestion(qcount);
        qcount++;
    }
    btn_igame_exit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(GameImageActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    });
    btn_igame_next.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Show Result
            if (result == true) {
                img_igame_tvqst.setImageResource(R.drawable.img_right);
                res[qcount - 1] = true;
            } else {
                vibe.vibrate(500);
                img_igame_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(GameImageActivity.this, GameResultActivity.class);
                        intent.putExtra("result", res);
                        intent.putExtra("type", 1);
                        startActivity(intent);
                    } else {
                        tv_igame_tvqst.setText("Q" + (qcount + 1));
                        SetQuestion(qcount);
                        qcount++;
                    }
                }
            }, 1500);
        // finish();
        }
    });
}
Also used : Handler(android.os.Handler) Intent(android.content.Intent) Vibrator(android.os.Vibrator) CardBook(com.alphago.alphago.model.CardBook) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 2 with CardBook

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

the class GameWordActivity1 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game_word1);
    // 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_wgame1_exit = (ImageButton) findViewById(R.id.btn_wgame1_exit);
    btn_wgame1_next = (ImageButton) findViewById(R.id.btn_wgame1_next);
    btn_wgame1_ex1 = (Button) findViewById(R.id.btn_wgame1_ex1);
    btn_wgame1_ex2 = (Button) findViewById(R.id.btn_wgame1_ex2);
    img_wgame1_tvqst = (ImageView) findViewById(R.id.img_wgame1_tvqst);
    tv_wgame1_tvqst = (TextView) findViewById(R.id.tv_wgame1_tvqst);
    img_wgame1_qst = (ImageView) findViewById(R.id.img_wgame1_qst);
    img_wgame1_lqst = (TextView) findViewById(R.id.img_wgame1_lqst);
    final Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    // First Question
    if (qcount == 0) {
        // CreateQuestion(TestData.dataID.length);
        CreateQuestion(cardBookList.size());
        SetQuestion(qcount);
        qcount++;
    }
    btn_wgame1_exit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(GameWordActivity1.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    });
    btn_wgame1_next.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // Show Result
            if (result == true) {
                img_wgame1_tvqst.setImageResource(R.drawable.img_right);
                res[qcount - 1] = true;
            } else {
                vibe.vibrate(500);
                img_wgame1_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(GameWordActivity1.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_wgame1_tvqst.setText("Q" + (qcount + 1) + " ");
                        SetQuestion(qcount);
                        qcount++;
                    }
                }
            }, 1500);
        // finish();
        }
    });
}
Also used : Handler(android.os.Handler) Intent(android.content.Intent) Vibrator(android.os.Vibrator) CardBook(com.alphago.alphago.model.CardBook) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View)

Example 3 with CardBook

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

the class GameWordActivity3 method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_game_word3);
    // 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_wgame3_exit = (ImageButton) findViewById(R.id.btn_wgame3_exit);
    btn_wgame3_next = (ImageButton) findViewById(R.id.btn_wgame3_next);
    img_wgame3_tvqst = (ImageView) findViewById(R.id.img_wgame3_tvqst);
    tv_wgame3_tvqst = (TextView) findViewById(R.id.tv_wgame3_tvqst);
    img_wgame3_qst = (ImageView) findViewById(R.id.img_wgame3_qst);
    img_wgame3_lqst = (EditText) findViewById(R.id.img_wgame3_lqst);
    img_wgame3_lqst.setPrivateImeOptions("defaultInputmode=english;");
    final Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
    // First Question
    if (qcount == 0) {
        // CreateQuestion(TestData.dataID.length);
        CreateQuestion(cardBookList.size());
        SetQuestion(qcount);
    // qcount++;
    }
    btn_wgame3_exit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(GameWordActivity3.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    });
    btn_wgame3_next.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // 답 확인
            String answer = cardBookList.get(qst_num[qcount]).getName();
            String input = img_wgame3_lqst.getText().toString();
            input = input.toLowerCase();
            if (input.equals(answer))
                result = true;
            else
                result = false;
            // Show Result
            if (result == true) {
                img_wgame3_tvqst.setImageResource(R.drawable.img_right);
                res[qcount] = true;
                qcount++;
            } else {
                vibe.vibrate(500);
                img_wgame3_tvqst.setImageResource(R.drawable.img_wrong);
                res[qcount] = false;
                qcount++;
            }
            // Change the screen after 1.5 seconds
            new Handler().postDelayed(new Runnable() {

                @Override
                public void run() {
                    if (qcount == 10) {
                        Intent intent = new Intent(GameWordActivity3.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_wgame3_tvqst.setText("Q" + (qcount + 1) + " ");
                        SetQuestion(qcount);
                    // qcount++;
                    }
                }
            }, 1500);
        // finish();
        }
    });
}
Also used : Handler(android.os.Handler) Intent(android.content.Intent) CardBook(com.alphago.alphago.model.CardBook) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) Vibrator(android.os.Vibrator)

Example 4 with CardBook

use of com.alphago.alphago.model.CardBook 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();
    }
}
Also used : Category(com.alphago.alphago.model.Category) ArrayList(java.util.ArrayList) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) CardBook(com.alphago.alphago.model.CardBook) TTSHelper(com.alphago.alphago.util.TTSHelper) ArrayList(java.util.ArrayList) List(java.util.List) DbHelper(com.alphago.alphago.database.DbHelper)

Example 5 with CardBook

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

the class DbHelper method cardbookSelect.

public List<CardBook> cardbookSelect(long categoryId) {
    SQLiteDatabase db = getReadableDatabase();
    String[] projection = { "*" };
    String selection = CardBookEntry.COLUMN_NAME_CATEGORY + " = ?";
    String[] selectionArgs = { String.valueOf(categoryId) };
    Cursor c = db.query(CardBookEntry.TABLE_NAME, projection, selection, selectionArgs, null, null, null);
    List<CardBook> labelList = new ArrayList<>();
    while (c.moveToNext()) {
        long labelId = c.getLong(c.getColumnIndexOrThrow(CardBookEntry._ID));
        String label = c.getString(c.getColumnIndexOrThrow(CardBookEntry.COLUMN_NAME_LABEL));
        String path = c.getString(c.getColumnIndexOrThrow(CardBookEntry.COLUMN_NAME_PATH));
        labelList.add(new CardBook(labelId, label, categoryId, String.valueOf(categoryId), path));
    }
    c.close();
    Collections.reverse(labelList);
    return labelList;
}
Also used : SQLiteDatabase(android.database.sqlite.SQLiteDatabase) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) CardBook(com.alphago.alphago.model.CardBook)

Aggregations

CardBook (com.alphago.alphago.model.CardBook)7 Intent (android.content.Intent)5 View (android.view.View)5 ImageView (android.widget.ImageView)5 TextView (android.widget.TextView)5 Handler (android.os.Handler)4 Vibrator (android.os.Vibrator)4 ArrayList (java.util.ArrayList)2 Cursor (android.database.Cursor)1 SQLiteDatabase (android.database.sqlite.SQLiteDatabase)1 DbHelper (com.alphago.alphago.database.DbHelper)1 Category (com.alphago.alphago.model.Category)1 TTSHelper (com.alphago.alphago.util.TTSHelper)1 List (java.util.List)1