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(); }
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; }
public LetterTouchListener(Letter model) { _model = model; _oldLetterContext = model.getLetterContext(); }