Skip to content

Instantly share code, notes, and snippets.

@pbrewczynski
Created June 13, 2013 11:53
Show Gist options
  • Save pbrewczynski/5773111 to your computer and use it in GitHub Desktop.
Save pbrewczynski/5773111 to your computer and use it in GitHub Desktop.
/* IN ONCREATE */
firstPlayerButton = (Button) findViewById(R.id.firstPlayerButton);
//Assign Color to the FIRST PLAYER
firstPlayerColor = r.getColor(R.color.player_one);
firstPlayerButton.setTag(new ColorAndReferenceToTextView(firstPlayerColor, (TextView) findViewById(R.id.firstPlayerResult)));
secondPlayerButton = (Button) findViewById(R.id.secondPlayerButton);
//Assign Color to the SECOND PLAYER
secondPlayerColor = r.getColor(R.color.player_two);
secondPlayerButton.setTag(new ColorAndReferenceToTextView(secondPlayerColor, (TextView) findViewById(R.id.secondPlayerResult)));
firstPlayerButton.setOnTouchListener(touchListenerToButtons);
secondPlayerButton.setOnTouchListener(touchListenerToButtons);
/* --- END OF ONCREATE -- */
private OnTouchListener touchListenerToButtons = new OnTouchListener() {
@Override
public boolean onTouch(View v, MotionEvent e) {
firstPlayerButton.setOnTouchListener(null);
secondPlayerButton.setOnTouchListener(null);
System.out.println("Touched");
System.out.println(e.getPointerCount());
ColorAndReferenceToTextView tg = (ColorAndReferenceToTextView) v.getTag();
controlPanelButton.setBackgroundColor(tg.colorPlayer);
TextView r = tg.resultForPlayer;
int actualValueOfResult = Integer.parseInt(r.getText().toString());
if(isAfterTime) {
r.setText(String.valueOf(actualValueOfResult+1));
} else {
r.setText(String.valueOf(actualValueOfResult-1));
}
return false;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment