コード例 #1
0
    @Override
    public void onNext(Word word) {
      Timber.d("Got word " + word + " and this is the subscriber " + this);

      if (RANDOM.nextDouble() <= 0.25 || currentAvailableWords.isEmpty()) {
        word = targetWord;
      }
      if (targetWordLanguage.equals(ENGLISH)) {
        view.showOptionalWord(word.getTextSpa());
        currentDisplayedWord = word.getTextSpa();
      } else {
        view.showOptionalWord(word.getTextEng());
        currentDisplayedWord = word.getTextEng();
      }
    }
コード例 #2
0
 /** Choose the next target word and remove it from the available ones */
 private void chooseTargetWord() {
   targetWord = currentAvailableWords.remove(RANDOM.nextInt(currentAvailableWords.size()));
   String targetTranslation;
   if (RANDOM.nextDouble() < 0.5) {
     targetTranslation = targetWord.getTextEng();
     targetWordLanguage = ENGLISH;
   } else {
     targetTranslation = targetWord.getTextSpa();
     targetWordLanguage = SPANISH;
   }
   bus.post(new NewTargetWordEvent(targetTranslation));
   removeWordUseCase
       .remove(targetWord)
       .compose(schedulerTransformer.applySchedulers())
       .subscribe();
 }
コード例 #3
0
 /** Is the current optional word equal to the target word? */
 private boolean isCurrentTranslationCorrect() {
   return currentDisplayedWord.equals(targetWord.getTextEng())
       || currentDisplayedWord.equals(targetWord.getTextSpa());
 }