/** update the level and count for the given flashcard in the database. */ private void updateFlashcard(Flashcard fc) { openDB(); _curDB.beginTransaction(); try { // Delete old entry if any. SQLiteStatement dStmt = getCompiledStatement(SQL_DELETE_FCS); dStmt.bindString(1, fc.getLang1Str()); dStmt.execute(); // insert new state entry. SQLiteStatement iStmt = getCompiledStatement(SQL_INSERT_FCS); iStmt.bindString(1, fc.getLang1Str()); iStmt.bindLong(2, fc.getLevel()); iStmt.bindLong(3, fc.getRightGuessCount()); iStmt.execute(); _curDB.setTransactionSuccessful(); } catch (SQLException e) { MsgDispatcher.sendMessageToUI( MsgType.MSG_SHOW_ERROR_MSG, 0, 0, "unable to update id=" + fc.getID()); } finally { _curDB.endTransaction(); } // this flashcard is no longer used by anyone so release it. fc.release(); }
/** * 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()); }