use of com.nolanlawson.keepscore.widget.PlayerColorView in project KeepScore by nolanlawson.
the class DialogHelper method createColorChooserView.
private static View createColorChooserView(Context context, final Callback<PlayerColor> onColorChanged, final PlayerColor selectedColor) {
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Activity.LAYOUT_INFLATER_SERVICE);
final View view = inflater.inflate(R.layout.color_chooser_dialog, null, false);
final List<PlayerColorView> playerColorViews = getSquareImages(view);
for (int i = 0; i < playerColorViews.size(); i++) {
PlayerColorView playerColorView = playerColorViews.get(i);
PlayerColor playerColor = PlayerColor.BUILT_INS[i % PlayerColor.BUILT_INS.length];
playerColorView.setSelected(playerColor.equals(selectedColor));
playerColorView.setPlayerColor(playerColor);
playerColorView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
PlayerColor playerColor = ((PlayerColorView) v).getPlayerColor();
onColorChanged.onCallback(playerColor);
for (PlayerColorView otherSquareImage : playerColorViews) {
otherSquareImage.setSelected(otherSquareImage.getPlayerColor() == playerColor);
}
}
});
}
return view;
}
Aggregations