Back to project page Briscola.
The source code is released under:
GNU General Public License
If you think the Android project Briscola listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.gmail.craptik.briscola; /*w ww .jav a 2 s . c om*/ import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.FrameLayout; import android.widget.RadioButton; import android.widget.RadioGroup; import android.widget.TextView; public class CalleeSelectActivity extends Activity { private Player callee; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_callee_select); } @Override public void onResume() { super.onResume(); GameData gameData = NewGameActivity.getGameData(); TextView firstPlayerTextView = (TextView) findViewById(R.id.callee_player_one); firstPlayerTextView.setText(gameData.getPlayers().get(0).getName()); TextView secondPlayerTextView = (TextView) findViewById(R.id.callee_player_two); secondPlayerTextView.setText(gameData.getPlayers().get(1).getName()); TextView thirdPlayerTextView = (TextView) findViewById(R.id.callee_player_three); thirdPlayerTextView.setText(gameData.getPlayers().get(2).getName()); TextView fourthPlayerTextView = (TextView) findViewById(R.id.callee_player_four); fourthPlayerTextView.setText(gameData.getPlayers().get(3).getName()); TextView fifthPlayerTextView = (TextView) findViewById(R.id.callee_player_five); fifthPlayerTextView.setText(gameData.getPlayers().get(4).getName()); callee = gameData.getCallee(); RadioGroup calleeRadioGroup = (RadioGroup) findViewById(R.id.callee_radio_group); for(int i = 0; i < calleeRadioGroup.getChildCount() - 1; i++) { ((RadioButton) ((FrameLayout) calleeRadioGroup.getChildAt(i)).getChildAt(0)).setChecked(false); } if(callee != null) { int ixCallee = gameData.findPlayer(callee); if(ixCallee == -1) { ((RadioButton) ((FrameLayout) calleeRadioGroup.getChildAt(5)).getChildAt(0)).setChecked(true); } else { ((RadioButton) ((FrameLayout) calleeRadioGroup.getChildAt(ixCallee)).getChildAt(0)).setChecked(true); ((RadioButton) ((FrameLayout) calleeRadioGroup.getChildAt(5)).getChildAt(0)).setChecked(false); } } else { ((RadioButton) ((FrameLayout) calleeRadioGroup.getChildAt(5)).getChildAt(0)).setChecked(true); } } public void onCalleeRadioButtonClicked(View view) { RadioGroup calleeRadioGroup = (RadioGroup) findViewById(R.id.callee_radio_group); for(int i = 0; i < calleeRadioGroup.getChildCount(); i++) { ((RadioButton) ((FrameLayout) calleeRadioGroup.getChildAt(i)).getChildAt(0)).setChecked(false); } ((RadioButton) view).setChecked(true); GameData gameData = NewGameActivity.getGameData(); switch(view.getId()) { case R.id.callee_radio_one: { callee = gameData.getPlayers().get(0); break; } case R.id.callee_radio_two: { callee = gameData.getPlayers().get(1); break; } case R.id.callee_radio_three: { callee = gameData.getPlayers().get(2); break; } case R.id.callee_radio_four: { callee = gameData.getPlayers().get(3); break; } case R.id.callee_radio_five: { callee = gameData.getPlayers().get(4); break; } case R.id.callee_radio_no_one: { callee = null; break; } default: { // Really should have each case... callee = null; assert false; break; } } } public void confirm(View view) { GameData gameData = NewGameActivity.getGameData(); gameData.setCallee(callee); finish(); } }