Beispiel #1
0
  public void onLetterContextChanged(Letter source) {
    if (_letterStateTables.get(_playerIdx) == null) initLetterStateTable(_playerIdx);
    Hashtable<String, LetterContext> letterState = _letterStateTables.get(_playerIdx);
    letterState.put(String.valueOf(source.getLetter()), source.getLetterContext());

    if (source.getLetter() == _letter) _letterContext = source.getLetterContext();
  }
Beispiel #2
0
    public boolean onTouch(View v, MotionEvent event) {
      if (_playerIdx != _activePlayerIdx) return false;

      LetterContext letterContext = _model.getLetterContext();
      if (_selectCountTable.get(_playerIdx) == null) _selectCountTable.put(_playerIdx, 0);
      int selectCount = _selectCountTable.get(_playerIdx);

      if (event.getAction() == MotionEvent.ACTION_DOWN) {
        _oldLetterContext = letterContext;
        _model.setLetterContext(LetterContext.PRESSED);
      } else {
        switch (_oldLetterContext) {
          case NEUTRAL:
            _model.setLetterContext(LetterContext.ELIMINATED);
            break;
          case ELIMINATED:
            if (selectCount < 4) {
              _model.setLetterContext(LetterContext.SELECTED);
              _selectCountTable.put(_playerIdx, selectCount + 1);
            } else _model.setLetterContext(LetterContext.NEUTRAL);
            break;
          case SELECTED:
            _model.setLetterContext(LetterContext.NEUTRAL);
            _selectCountTable.put(_playerIdx, selectCount - 1);
            break;
          default:
            break;
        }
        _oldLetterContext = letterContext;
      }

      onLetterContextChanged(_model); // Updates letter context table right away
      WordController.getInstance(_playerIdx).fireLetterContextChangeEvent(_model);

      return false;
    }
Beispiel #3
0
 public LetterTouchListener(Letter model) {
   _model = model;
   _oldLetterContext = model.getLetterContext();
 }