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));
}
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());
}
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);
}
}
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();
}
}
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());
}
Aggregations