Search in sources :

Example 6 with DbHelper

use of com.alphago.alphago.database.DbHelper 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)

Example 7 with DbHelper

use of com.alphago.alphago.database.DbHelper in project Alphago by Onedelay.

the class CardListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_card_book_list);
    long labelId = getIntent().getLongExtra("labelId", -1);
    String label = getIntent().getStringExtra("label");
    cat = (TextView) findViewById(R.id.cardbook_list_main_label);
    cat.setText(label);
    adapter = new CardAdapter(this);
    recyclerView = (RecyclerView) findViewById(R.id.cardbook_grid);
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    DbHelper dbHelper = new DbHelper(getBaseContext());
    adapter.setList(dbHelper.cardsSelect(labelId));
}
Also used : CardAdapter(com.alphago.alphago.adapter.CardAdapter) DbHelper(com.alphago.alphago.database.DbHelper)

Example 8 with DbHelper

use of com.alphago.alphago.database.DbHelper in project Alphago by Onedelay.

the class CollectionListActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collection_list);
    dbHelper = new DbHelper(getBaseContext());
    adapter = new CollectionAdapter(this);
    recyclerView = (RecyclerView) findViewById(R.id.collection_list);
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    long catId = getIntent().getLongExtra("categoryId", 0);
    adapter.setList(dbHelper.collectionSelect(catId));
}
Also used : CollectionAdapter(com.alphago.alphago.adapter.CollectionAdapter) DbHelper(com.alphago.alphago.database.DbHelper)

Aggregations

DbHelper (com.alphago.alphago.database.DbHelper)8 View (android.view.View)3 Intent (android.content.Intent)2 ImageView (android.widget.ImageView)2 TextView (android.widget.TextView)2 TTSHelper (com.alphago.alphago.util.TTSHelper)2 SharedPreferences (android.content.SharedPreferences)1 RecyclerView (android.support.v7.widget.RecyclerView)1 CardAdapter (com.alphago.alphago.adapter.CardAdapter)1 CardBookAdapter (com.alphago.alphago.adapter.CardBookAdapter)1 CategoryAdapter (com.alphago.alphago.adapter.CategoryAdapter)1 CollectionAdapter (com.alphago.alphago.adapter.CollectionAdapter)1 CollectionCatAdapter (com.alphago.alphago.adapter.CollectionCatAdapter)1 ImageSelectionMethodDialog (com.alphago.alphago.fragment.ImageSelectionMethodDialog)1 LearningSelectionMethodDialog (com.alphago.alphago.fragment.LearningSelectionMethodDialog)1 RequestImageTrainingFragment (com.alphago.alphago.fragment.RequestImageTrainingFragment)1 CardBook (com.alphago.alphago.model.CardBook)1 Category (com.alphago.alphago.model.Category)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1