Search in sources :

Example 1 with DbHelper

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

the class CardBookListActivity method onCreate.

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

Example 2 with DbHelper

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

the class CollectionActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_collection);
    dbHelper = new DbHelper(getBaseContext());
    adapter = new CollectionCatAdapter(this);
    recyclerView = (RecyclerView) findViewById(R.id.collection_list);
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    adapter.setList(dbHelper.categoryAllSelect());
}
Also used : CollectionCatAdapter(com.alphago.alphago.adapter.CollectionCatAdapter) DbHelper(com.alphago.alphago.database.DbHelper)

Example 3 with DbHelper

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

the class StartActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_start);
    dbHelper = new DbHelper(getBaseContext());
    PermissionUtils.checkPermissions(this, REQUEST_PERMISSONS, Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.CAMERA);
    SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE);
    if (!sharedPreferences.getBoolean("Default", false)) {
        downloadFile();
    } else {
        controlStartActivity(0);
    }
}
Also used : SharedPreferences(android.content.SharedPreferences) DbHelper(com.alphago.alphago.database.DbHelper)

Example 4 with DbHelper

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

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

the class CardBookActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_card_book);
    final Intent intent = new Intent(this, WordLearningActivity.class);
    dbHelper = new DbHelper(getBaseContext());
    btnLearning = (Button) findViewById(R.id.btn_learning);
    btnLearning.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (!isSelectMode) {
                new LearningSelectionMethodDialog().show(getSupportFragmentManager(), "dialog");
            } else {
                intent.putExtra("category_select_list", selectList);
                intent.putExtra("learning_type", LearningSelectionMethodDialog.TYPE_ALBUM);
                startActivity(intent);
                cancelLearning(dbHelper);
            }
        }
    });
    adapter = new CategoryAdapter(this);
    recyclerView = (RecyclerView) findViewById(R.id.cardbook_grid);
    recyclerView.setAdapter(adapter);
    recyclerView.setHasFixedSize(true);
    // recyclerView.setLayoutManager(new GridLayoutManager(this, 3));
    adapter.setList(dbHelper.categorySelect());
}
Also used : CategoryAdapter(com.alphago.alphago.adapter.CategoryAdapter) LearningSelectionMethodDialog(com.alphago.alphago.fragment.LearningSelectionMethodDialog) Intent(android.content.Intent) DbHelper(com.alphago.alphago.database.DbHelper) RecyclerView(android.support.v7.widget.RecyclerView) View(android.view.View)

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