Search in sources :

Example 1 with TTSHelper

use of com.alphago.alphago.util.TTSHelper in project Alphago by Onedelay.

the class WordDetailActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_word_detail);
    learnLabel = findViewById(R.id.learn_label);
    learnImage = findViewById(R.id.learn_image);
    tts = new TTSHelper(this);
    String label = getIntent().getStringExtra("label");
    String filePath = getIntent().getStringExtra("filePath");
    learnLabel.setText(label);
    Picasso.with(this).load(new File(filePath)).centerInside().fit().into(learnImage);
    findViewById(btn_learn_exit).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            finish();
        }
    });
    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());
        }
    });
}
Also used : TTSHelper(com.alphago.alphago.util.TTSHelper) File(java.io.File) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Example 2 with TTSHelper

use of com.alphago.alphago.util.TTSHelper 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 3 with TTSHelper

use of com.alphago.alphago.util.TTSHelper in project Alphago by Onedelay.

the class ImageRecognitionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_image_recognition);
    imageFile = (File) getIntent().getSerializableExtra("imageFile");
    if (imageFile.exists()) {
        ImageView myImage = (ImageView) findViewById(R.id.image_recognition);
        Picasso.with(getBaseContext()).load(imageFile).centerInside().fit().into(myImage);
    }
    final String categoryName = getIntent().getStringExtra("category");
    final String maxLabel = getIntent().getStringExtra("max_label");
    final int catID = getIntent().getIntExtra("cate_ID", 0);
    final int ID = getIntent().getIntExtra("ID", 0);
    TextView textView = (TextView) findViewById(R.id.result_recog);
    textView.setText(maxLabel);
    final DbHelper dbHelper = new DbHelper(getBaseContext());
    tts = new TTSHelper(this);
    findViewById(R.id.btn_pronounce).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (maxLabel.equals("usb"))
                tts.speak("U.S.B");
            else
                tts.speak(maxLabel);
        }
    });
    findViewById(R.id.btn_retry).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            new ImageSelectionMethodDialog().show(getSupportFragmentManager(), "dialog");
        }
    });
    saveBtn = (Button) findViewById(R.id.btn_save);
    saveBtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!v.isSelected()) {
                saveBtn.setText("SAVED");
                v.setSelected(true);
                String filePath = storeImageFile(imageFile, maxLabel);
                Toast.makeText(getBaseContext(), "저장되었습니다!", Toast.LENGTH_SHORT).show();
                dbHelper.insertImage(maxLabel, catID, ID, filePath, true);
            } else {
                Toast.makeText(getBaseContext(), "이미 저장되었습니다.", Toast.LENGTH_SHORT).show();
            }
        }
    });
    findViewById(R.id.btn_home).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            Intent intent = new Intent(ImageRecognitionActivity.this, MainActivity.class);
            startActivity(intent);
            finish();
        }
    });
    findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            new RequestImageTrainingFragment().show(getFragmentManager(), "dialog");
        }
    });
}
Also used : Intent(android.content.Intent) ImageView(android.widget.ImageView) TextView(android.widget.TextView) View(android.view.View) TextView(android.widget.TextView) TTSHelper(com.alphago.alphago.util.TTSHelper) ImageView(android.widget.ImageView) RequestImageTrainingFragment(com.alphago.alphago.fragment.RequestImageTrainingFragment) DbHelper(com.alphago.alphago.database.DbHelper) ImageSelectionMethodDialog(com.alphago.alphago.fragment.ImageSelectionMethodDialog)

Aggregations

View (android.view.View)3 ImageView (android.widget.ImageView)3 TextView (android.widget.TextView)3 TTSHelper (com.alphago.alphago.util.TTSHelper)3 DbHelper (com.alphago.alphago.database.DbHelper)2 Intent (android.content.Intent)1 ImageSelectionMethodDialog (com.alphago.alphago.fragment.ImageSelectionMethodDialog)1 RequestImageTrainingFragment (com.alphago.alphago.fragment.RequestImageTrainingFragment)1 CardBook (com.alphago.alphago.model.CardBook)1 Category (com.alphago.alphago.model.Category)1 File (java.io.File)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1