Exemple #1
0
 /**
  * Create or update engSpaUser.
  *
  * @return false if no changes made
  */
 public boolean setUser(String userName, int userLevel, QAStyle qaStyle) {
   userLevel = engSpaQuiz.validateUserLevel(userLevel);
   if (engSpaUser != null
       && engSpaUser.getUserName().equals(userName)
       && engSpaUser.getUserLevel() == userLevel
       && engSpaUser.getQAStyle() == qaStyle) {
     this.statusTextView.setText("no changes made to user");
     return false;
   }
   boolean newLevel = true;
   if (engSpaUser == null) { // i.e. new user
     this.engSpaUser = new EngSpaUser(userName, userLevel, qaStyle);
     engSpaDAO.insertUser(engSpaUser);
   } else { // update to existing user
     newLevel = engSpaUser.getUserLevel() != userLevel;
     engSpaUser.setUserName(userName);
     engSpaUser.setUserLevel(userLevel);
     engSpaUser.setQAStyle(qaStyle);
     engSpaDAO.updateUser(engSpaUser);
   }
   userNameTextView.setText(engSpaUser.getUserName());
   if (newLevel) {
     getEngSpaQuiz().setUserLevel(userLevel);
   }
   onNewLevel(); // strictly only necessary if change level or qaStyle
   return true;
 }
Exemple #2
0
 /** Notification from EngSpaQuiz that the user has moved up to the next level. */
 @Override // QuizEventListener
 public void onNewLevel() {
   /*
    * userLevel can be incremented by EngSpaQuiz when user answered
    * enough questions, or set by user invoking options menu item
    * UserDialog at any time.
    * EngSpaQuiz ->
    * 		[updates engSpaUser.level]
    * 		EngSpaFragment.onNewLevel() [I/F QuizEventListener]
    *
    * UserDialog ->
    * 		MainActivity.onUserUpdate() [I/F UserSettingsListener] ->
    * 			EngSpaFragment.setUser() ->
    * 				EngSpaFragment.onNewLevel() [if level changed]
    */
   if (BuildConfig.DEBUG)
     Log.d(
         engSpaActivity.getTag(), "EngSpaFragment.onNewLevel(" + engSpaUser.getUserLevel() + ")");
   showButtonLayout();
   showUserLevel();
   askQuestion(true);
 }
Exemple #3
0
 private void showUserLevel() {
   String userLevelStr = isUserLevelAll() ? "ALL" : Integer.toString(engSpaUser.getUserLevel());
   this.engSpaActivity.setEngSpaTitle(this.levelStr + " " + userLevelStr);
 }
Exemple #4
0
 public void setUserQAStyle(QAStyle qaStyle) {
   engSpaUser.setQAStyle(qaStyle);
   onNewLevel();
 }