/** Insert a set of flashcards (linked list) in a single transaction. */ private void insertFlashcardSet(Flashcard head) { openDB(); SQLiteStatement stmt = getCompiledStatement(SQL_INSERT_FC); boolean gotError = false; _curDB.beginTransaction(); try { for (Flashcard fc = head; fc != null; fc = Flashcard.Chain.getNext(fc)) { stmt.bindLong(1, _importState.getRandomId()); stmt.bindString(2, fc.getLang1Str()); stmt.bindString(3, fc.getLang2Str()); stmt.execute(); } _curDB.setTransactionSuccessful(); } catch (SQLException e) { gotError = true; MsgDispatcher.sendMessageToUI(MsgType.MSG_SHOW_ERROR_MSG, 0, 0, "unable to insert fc"); } finally { _curDB.endTransaction(); } Flashcard.Chain.releaseChain(head); // tell controller to send us more data if insert went fine. if (!gotError) { MsgDispatcher.sendMessageToController(MsgType.MSG_CONTINUE_IMPORT, 0, 0, null); } }
/** * update the display to show the current flashcard. Either the entire flashcard is shown or just * the first half depending on the value of the {@link #_showEntireCard} variable. */ private void updateDisplay() { Flashcard fc = FlashcardApp.getInstance().getCurrentFlashcard(); if (fc == null) { return; } String lang1Text = fc.getLang1Str(); String lang2Text = ""; if (FlashcardApp.getInstance().isShowEntireCard()) { lang2Text = fc.getLang2Str(); } _topText.setText(StringFormatter.formatEnglishString(lang1Text)); _bottomText.setText(StringFormatter.formatSpanishString(lang2Text)); _statusText.setText( "id: " + fc.getID() + " level: " + fc.getLevel() + " count: " + fc.getRightGuessCount()); }