public ExitWindow() { AlertDialog.Builder dialog = new AlertDialog.Builder(Rekin.getGame()); dialog.setTitle("Exit?"); dialog.setMessage("Confirm to exit?"); dialog.setPositiveButton( "Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); Rekin.getGame().finish(); System.exit(0); } }); dialog.setNegativeButton( "No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.show(); }
@Override public void onClick(View view) { if (view.getId() == R.id.draw_btn) { if (!drawView.getErase()) { final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Brush size:"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(smallBrush); drawView.setLastBrushSize(smallBrush); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(mediumBrush); drawView.setLastBrushSize(mediumBrush); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(largeBrush); drawView.setLastBrushSize(largeBrush); brushDialog.dismiss(); } }); brushDialog.show(); } drawView.setErase(false); } else if (view.getId() == R.id.erase_btn) { if (drawView.getErase()) { final Dialog brushDialog = new Dialog(this); brushDialog.setTitle("Eraser size:"); brushDialog.setContentView(R.layout.brush_chooser); ImageButton smallBtn = (ImageButton) brushDialog.findViewById(R.id.small_brush); smallBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(smallBrush); brushDialog.dismiss(); } }); ImageButton mediumBtn = (ImageButton) brushDialog.findViewById(R.id.medium_brush); mediumBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(mediumBrush); brushDialog.dismiss(); } }); ImageButton largeBtn = (ImageButton) brushDialog.findViewById(R.id.large_brush); largeBtn.setOnClickListener( new OnClickListener() { @Override public void onClick(View v) { drawView.setBrushSize(largeBrush); brushDialog.dismiss(); } }); brushDialog.show(); } drawView.setErase(true); } else if (view.getId() == R.id.new_btn) { AlertDialog.Builder newDialog = new AlertDialog.Builder(this); newDialog.setTitle("New equation"); newDialog.setMessage("Start new equation?"); newDialog.setPositiveButton( "Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { drawView.startNew(); dialog.dismiss(); } }); newDialog.setNegativeButton( "Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); newDialog.show(); } else if (view.getId() == R.id.equals_btn) { // save drawing } }