use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class QuizActivity method onSaveInstanceState.
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Card currentCard = getCurrentCard();
if (currentCard != null) {
outState.putInt(EXTRA_START_CARD_ID, currentCard.getId());
}
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class StudyActivity method onPostInit.
@Override
public void onPostInit() {
super.onPostInit();
if (filterCategoryId != -1) {
filterCategory = getDbOpenHelper().getCategoryDao().queryForId(filterCategoryId);
}
/* Run the learnQueue init in a separate thread */
if (startCardId != -1) {
Card card = queueManager.dequeuePosition(startCardId);
queueManager.remove(card);
setCurrentCard(card);
} else {
Card card = queueManager.dequeue();
queueManager.remove(card);
setCurrentCard(card);
}
refreshStatInfo();
// If the db does not contain any cards. Show no item dialog.
if (getCurrentCard() == null) {
showNoItemDialog();
return;
}
setupGradeButtons();
displayCard(false);
initialized = true;
setTitle(getDbName());
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class PreviewEditActivity method onPostInit.
@Override
public void onPostInit() {
super.onPostInit();
Card currentCard = null;
// If category is set, it will override the card id.
if (activeCategoryId != -1) {
currentCategory = getDbOpenHelper().getCategoryDao().queryForId(activeCategoryId);
currentCard = getDbOpenHelper().getCardDao().queryFirstOrdinal(currentCategory);
} else if (startCardId != -1) {
currentCard = getDbOpenHelper().getCardDao().queryForId(startCardId);
}
// Note curretnCategory should be null.
if (currentCard == null) {
currentCard = getDbOpenHelper().getCardDao().queryFirstOrdinal(currentCategory);
}
totalCardCount = getDbOpenHelper().getCardDao().countOf();
setCurrentCard(currentCard);
composeViews();
// currentCard = .getItem(currentId);
setViewListeners();
if (getCurrentCard() != null) {
updateCardFrontSide();
updateTitle();
}
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class PreviewEditActivity method gotoNext.
private void gotoNext() {
if (getCurrentCard() != null) {
Card nextCard = getDbOpenHelper().getCardDao().queryNextCard(getCurrentCard(), currentCategory);
assert nextCard != null : "Next card is null";
gotoCard(nextCard);
}
}
use of org.liberty.android.fantastischmemo.entity.Card in project AnyMemo by helloworld1.
the class DatabaseUtil method mergeDatabases.
public void mergeDatabases(String destPath, String srcPath) throws Exception {
AnyMemoDBOpenHelper destHelper = AnyMemoDBOpenHelperManager.getHelper(mContext, destPath);
AnyMemoDBOpenHelper srcHelper = AnyMemoDBOpenHelperManager.getHelper(mContext, srcPath);
final CardDao cardDaoDest = destHelper.getCardDao();
final LearningDataDao learningDataDaoSrc = srcHelper.getLearningDataDao();
final CategoryDao categoryDaoSrc = srcHelper.getCategoryDao();
final CardDao cardDaoSrc = srcHelper.getCardDao();
final List<Card> srcCards = cardDaoSrc.queryForAll();
cardDaoSrc.callBatchTasks(new Callable<Void>() {
public Void call() throws Exception {
for (Card c : srcCards) {
// Make sure to create a new ordinal
c.setOrdinal(null);
learningDataDaoSrc.refresh(c.getLearningData());
categoryDaoSrc.refresh(c.getCategory());
}
return null;
}
});
cardDaoDest.createCards(srcCards);
System.out.println("DatabaseUtils release destPath");
AnyMemoDBOpenHelperManager.releaseHelper(destHelper);
System.out.println("DatabaseUtils release srcPath");
AnyMemoDBOpenHelperManager.releaseHelper(srcHelper);
}
Aggregations