Android Open Source - android-chess Save Game Dlg






From Project

Back to project page android-chess.

License

The source code is released under:

MIT License

If you think the Android project android-chess listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package jwtc.android.chess;
//from  w  w w . j  av  a  2  s  . c  om
import java.util.Calendar;
import android.app.DatePickerDialog;
import android.app.Dialog;
import android.content.ContentValues;
import android.view.View;
import android.widget.Button;
import android.widget.DatePicker;
import android.widget.EditText;
import android.widget.RatingBar;
import jwtc.chess.PGNColumns;
/**
 * 
 */
public class SaveGameDlg extends Dialog {

  private EditText _editWhite, _editBlack, _editEvent;
  
  private RatingBar _rateRating;
  private Button _butSave, _butCancel, _butSaveCopy, _butDate;
  private main _parent;
  private String _sPGN;
  private int _year, _month, _day;
  private DatePickerDialog _dlgDate;
  
  public SaveGameDlg(main context) {
    super(context);

    _parent = context;    
    setContentView(R.layout.savegame);
    
    setTitle(R.string.title_save_game);
    
    _rateRating = (RatingBar)findViewById(R.id.RatingBarSave);
    
    _editEvent = (EditText)findViewById(R.id.EditTextSaveEvent);
    _editWhite = (EditText)findViewById(R.id.EditTextSaveWhite);
        _editBlack = (EditText)findViewById(R.id.EditTextSaveBlack);
                
        _butDate = (Button)findViewById(R.id.ButtonSaveDate);
        _butDate.setOnClickListener(new View.OnClickListener() {
          public void onClick(View arg0) {
            _dlgDate.show();
          }
      });
        
        _butSave = (Button)findViewById(R.id.ButtonSaveSave);
        _butSave.setOnClickListener(new View.OnClickListener() {
          public void onClick(View arg0) {
            dismiss();
            save(false);
          }
      });
        
        _butSaveCopy = (Button)findViewById(R.id.ButtonSaveCopy);
        _butSaveCopy.setOnClickListener(new View.OnClickListener() {
          public void onClick(View arg0) {
            dismiss();
            save(true);
          }
      });
        
        _butCancel = (Button)findViewById(R.id.ButtonSaveCancel);
        _butCancel.setOnClickListener(new View.OnClickListener() {
          public void onClick(View arg0) {
            dismiss();
          }
        });
  }
  
  public void save(boolean bCopy){
    ContentValues values = new ContentValues();
    
    Calendar c = Calendar.getInstance();
    c.set(_year, _month-1, _day, 0, 0);
        values.put(PGNColumns.DATE, c.getTimeInMillis());
        values.put(PGNColumns.WHITE, _editWhite.getText().toString());
        values.put(PGNColumns.BLACK, _editBlack.getText().toString());
        values.put(PGNColumns.PGN, _sPGN);
        values.put(PGNColumns.RATING, _rateRating.getRating());
        values.put(PGNColumns.EVENT, _editEvent.getText().toString());

        _parent.saveGame(values, bCopy);
  }

  public void setItems(String sEvent, String sWhite, String sBlack, Calendar cal, String sPGN, float fRating, boolean bCopy){
    
    _rateRating.setRating(fRating);
    _editEvent.setText(sEvent);
    _editWhite.setText(sWhite);
        _editBlack.setText(sBlack);
        
        _year = cal.get(Calendar.YEAR);
        _month = cal.get(Calendar.MONTH) + 1;
        _day = cal.get(Calendar.DAY_OF_MONTH);
        
        _butDate.setText(_year + "." + _month + "." + _day);
        
        _dlgDate = new DatePickerDialog(_parent, new DatePickerDialog.OnDateSetListener() {

      public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
        _year = year;
        _month = monthOfYear + 1;
        _day = dayOfMonth;
        _butDate.setText(_year + "." + _month + "." + _day);
        
      }}, _year, _month-1, _day);
        
        _sPGN = sPGN;
        
         _butSaveCopy.setEnabled(bCopy);
        
  }

}




Java Source Code List

jwtc.android.chess.ChessFieldView.java
jwtc.android.chess.ChessImageView.java
jwtc.android.chess.ChessPreferences.java
jwtc.android.chess.ChessViewBase.java
jwtc.android.chess.ChessView.java
jwtc.android.chess.GamesListView.java
jwtc.android.chess.HtmlActivity.java
jwtc.android.chess.ImageCacheObject.java
jwtc.android.chess.MyBaseActivity.java
jwtc.android.chess.MyPGNProvider.java
jwtc.android.chess.PGNView.java
jwtc.android.chess.SaveGameDlg.java
jwtc.android.chess.UI.java
jwtc.android.chess.convergence.Connection.java
jwtc.android.chess.convergence.ConvergenceActivity.java
jwtc.android.chess.convergence.RestServer.java
jwtc.android.chess.iconifiedlist.IconifiedTextListAdapter.java
jwtc.android.chess.iconifiedlist.IconifiedTextView.java
jwtc.android.chess.iconifiedlist.IconifiedText.java
jwtc.android.chess.ics.CustomCommands.java
jwtc.android.chess.ics.ICSChatDlg.java
jwtc.android.chess.ics.ICSChessView.java
jwtc.android.chess.ics.ICSClient.java
jwtc.android.chess.ics.ICSConfirmDlg.java
jwtc.android.chess.ics.ICSMatchDlg.java
jwtc.android.chess.ics.TelnetSocket.java
jwtc.android.chess.ics.TimesealInputStream.java
jwtc.android.chess.ics.TimesealOutputStream.java
jwtc.android.chess.ics.TimesealPipe.java
jwtc.android.chess.ics.TimesealingSocket.java
jwtc.android.chess.puzzle.ChessViewPractice.java
jwtc.android.chess.puzzle.ChessViewPuzzle.java
jwtc.android.chess.puzzle.MyPuzzleProvider.java
jwtc.android.chess.puzzle.practice.java
jwtc.android.chess.puzzle.puzzle.java
jwtc.android.chess.tools.FileListView.java
jwtc.android.chess.tools.PGNProcessor.java
jwtc.android.chess.tools.importactivity.java
jwtc.android.chess.tools.pgntool.java
jwtc.android.chess.main.java
jwtc.android.chess.options.java
jwtc.android.chess.setup.java
jwtc.android.chess.start.java
jwtc.android.timeseal.TimesealingSocket.java
jwtc.android.timeseal.streams.a.java
jwtc.android.timeseal.streams.b.java
jwtc.android.timeseal.streams.c.java
jwtc.chess.ChessPuzzleProvider.java
jwtc.chess.GameControl.java
jwtc.chess.JNI.java
jwtc.chess.Move.java
jwtc.chess.PGNColumns.java
jwtc.chess.PGNEntry.java
jwtc.chess.PGNProvider.java
jwtc.chess.Pos.java
jwtc.chess.Valuation.java
jwtc.chess.algorithm.SearchAlgorithmRunner.java
jwtc.chess.algorithm.UCIWrapper.java
jwtc.chess.board.BoardConstants.java
jwtc.chess.board.BoardHashKeys.java
jwtc.chess.board.BoardMembers.java
jwtc.chess.board.BoardStatics.java
jwtc.chess.board.ChessBoard.java