コード例 #1
0
 public void board_OnClick(View v) {
   // your code here
   String current_word = mBoardGameLogic.getWord();
   m_word.setText(current_word);
   int action_img = 0;
   boolean can_swap = mBoardGameLogic.countSelected() == 2;
   boolean can_check = current_word.length() > 3;
   if (can_swap) action_img = R.drawable.swap;
   else if (can_check) action_img = R.drawable.question;
   m_word.setCompoundDrawablesWithIntrinsicBounds(0, 0, action_img, 0);
   m_word.setEnabled(can_swap || can_check);
 }
コード例 #2
0
 public void word_OnClick(View v) {
   if (mPlayState == STATE_RUNNING && m_text_status.getVisibility() == View.VISIBLE)
     m_text_status.setVisibility(View.INVISIBLE);
   String current_word = mBoardGameLogic.getWord();
   String lower_current_word = current_word.toLowerCase();
   if (mBoardGameLogic.countSelected() == 2) {
     mBoardGameLogic.swap2();
     m_word.setText("");
     m_word.setEnabled(false);
     m_word.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0);
     return;
   }
   /* if(m_answers.contains(lower_current_word)) {
   	showResult(current_word, "repetida", 0xAAFFFF00);
   } else */ {
     boolean is_correct = findWord(lower_current_word);
     int play_score = lower_current_word.length();
     int play_time = 20;
     if (lower_current_word.length() > 5) {
       play_score += 10;
       play_time += 30;
     }
     if (is_correct) {
       m_score += play_score;
       m_allowedTime += play_time;
       m_allowedTime_millis = m_allowedTime * 1000;
       m_answers.add(lower_current_word);
       m_must_reset_word = true;
       showResult(current_word, "certa", 0xAA00FF00);
       // if(m_answers.size() == 1)
       //	mPlayTime.setTextColor(0xFF00FF00);
     } else {
       m_score -= play_score;
       /*
       long millis = System.currentTimeMillis() - mStartTime;
       m_allowedTime -= play_time;
       m_allowedTime_millis = m_allowedTime * 1000;
       long remaining = m_allowedTime-millis;
       if(!mTimeIsBlinking && remaining < 10)
       	m_Handler.postDelayed(mUpdateTimeTask, 0); */
       showResult(current_word, "errada", 0xAAFF0000);
     }
   }
   mScoreText.setText(new Integer(m_score).toString());
   m_word.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.check_button_blank, 0);
   m_word.setEnabled(false);
 }