コード例 #1
0
  public void OnPause(SharedPreferences.Editor editor) {

    editor.putBoolean("flippedBoard", _view.getFlippedBoard());
    if (_iPos > 0) editor.putInt("puzzlePos", _iPos - 1);
  }
コード例 #2
0
  @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();
    }
  }