@Nonnull public PropertyView setIcon(@Nullable Drawable icon) { final ImageView iconView = getIconView(); iconView.setImageDrawable(icon); iconView.setVisibility(icon == null ? GONE : VISIBLE); return this; }
@Nonnull public PropertyView setRightIcon(int iconResId) { if (iconResId != NO_ID) { final ImageView rightIconView = new ImageView(view.getContext()); rightIconView.setImageDrawable(resources.getDrawable(iconResId)); setWidget(rightIconView); } else { setWidget(null); } return this; }
@Override protected boolean requestMove(int from, int to) { if (_arrPGN.size() <= _jni.getNumBoard() - 1) { setMessage("(position allready solved)"); return super.requestMove(from, to); } int move = _arrPGN.get(_jni.getNumBoard() - 1)._move; int theMove = Move.makeMove(from, to); if (Move.equalPositions(move, theMove)) { jumptoMove(_jni.getNumBoard()); updateState(); setMessage("Correct!"); _imgStatus.setImageResource(R.drawable.indicator_ok); /* if(_arrPGN.size() == m_game.getBoard().getNumBoard()-1) play(); else { jumptoMove(m_game.getBoard().getNumBoard()); updateState(); }*/ return true; } else { // check for illegal move setMessage( "Move " + Move.toDbgString(theMove) + (checkIsLegalMove(from, to) ? " is not the expected move" : " is an invalid move")); _imgStatus.setImageResource(R.drawable.indicator_error); m_iFrom = -1; } updateState(); return true; }
@Override public void play() { m_iFrom = -1; Log.i("ChessViewPuzzle", "Numboard = " + _jni.getNumBoard()); _imgStatus.setImageResource(R.drawable.indicator_none); String sPGN; _iPos++; if (_iPos < 1) _iPos = 1; if (_iPos > _num) { setMessage("You completed all puzzles!!!"); return; } if (_seekBar != null) { _seekBar.setProgress(_iPos); } if (_cursor != null) { _cursor.moveToPosition(_iPos - 1); sPGN = _cursor.getString(_cursor.getColumnIndex(MyPuzzleProvider.COL_PGN)); Log.i("ChessViewPuzzle", "init: " + sPGN); loadPGN(sPGN); jumptoMove(0); int turn = _jni.getTurn(); if (turn == BoardConstants.BLACK && false == _view.getFlippedBoard() || turn == BoardConstants.WHITE && _view.getFlippedBoard()) _view.flipBoard(); String sWhite = _mapPGNHead.get("White"); if (sWhite == null) { sWhite = ""; } else { sWhite = sWhite.replace("?", ""); } String sDate = _mapPGNHead.get("Date"); if (sDate == null) { sDate = ""; } else { sDate = sDate.replace("????", ""); sDate = sDate.replace(".??.??", ""); } if (sWhite.length() > 0 && sDate.length() > 0) { sWhite += ", "; } _tvPuzzleText.setText( "# " + _iPos + " - " + sWhite + sDate); // + "\n\n" + _mapPGNHead.get("Event") + ", " + // _mapPGNHead.get("Date").replace(".??.??", "")); // _tvPuzzle.setText("); _imgTurn.setImageResource( (turn == BoardConstants.WHITE ? R.drawable.turnwhite : R.drawable.turnblack)); updateState(); } }