Search in sources :

Example 1 with Card

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());
    }
}
Also used : Card(org.liberty.android.fantastischmemo.entity.Card)

Example 2 with Card

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());
}
Also used : Card(org.liberty.android.fantastischmemo.entity.Card)

Example 3 with Card

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();
    }
}
Also used : Card(org.liberty.android.fantastischmemo.entity.Card)

Example 4 with Card

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);
    }
}
Also used : Card(org.liberty.android.fantastischmemo.entity.Card)

Example 5 with Card

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);
}
Also used : AnyMemoDBOpenHelper(org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper) CategoryDao(org.liberty.android.fantastischmemo.dao.CategoryDao) LearningDataDao(org.liberty.android.fantastischmemo.dao.LearningDataDao) CardDao(org.liberty.android.fantastischmemo.dao.CardDao) Card(org.liberty.android.fantastischmemo.entity.Card)

Aggregations

Card (org.liberty.android.fantastischmemo.entity.Card)95 CardDao (org.liberty.android.fantastischmemo.dao.CardDao)61 SmallTest (android.support.test.filters.SmallTest)43 Test (org.junit.Test)43 AbstractExistingDBTest (org.liberty.android.fantastischmemo.test.AbstractExistingDBTest)41 Category (org.liberty.android.fantastischmemo.entity.Category)30 AnyMemoDBOpenHelper (org.liberty.android.fantastischmemo.common.AnyMemoDBOpenHelper)28 LearningData (org.liberty.android.fantastischmemo.entity.LearningData)25 CategoryDao (org.liberty.android.fantastischmemo.dao.CategoryDao)20 LearningDataDao (org.liberty.android.fantastischmemo.dao.LearningDataDao)13 File (java.io.File)12 ArrayList (java.util.ArrayList)11 SQLException (java.sql.SQLException)9 QueueManager (org.liberty.android.fantastischmemo.queue.QueueManager)9 IOException (java.io.IOException)6 Date (java.util.Date)6 LearnQueueManager (org.liberty.android.fantastischmemo.queue.LearnQueueManager)6 URL (java.net.URL)5 FileWriter (java.io.FileWriter)4 Scheduler (org.liberty.android.fantastischmemo.scheduler.Scheduler)4