Back to project page Do-not-get-annoyed.
The source code is released under:
Apache License
If you think the Android project Do-not-get-annoyed 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 mn100013d.pmu; /*from ww w . ja v a 2s. co m*/ import mn100013d.pmu.exceptions.PlayerNotRegisteredException; import mn100013d.pmu.services.FragmentProvider; import mn100013d.pmu.services.SoundService; import android.content.Intent; import android.os.Bundle; import android.support.v4.app.Fragment; import android.util.Log; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; import android.view.animation.AnimationUtils; import android.view.animation.OvershootInterpolator; import android.widget.EditText; import android.widget.RadioButton; import android.widget.RadioGroup; public class GameTypeFragment extends Fragment { public static final String RED_NAME = "mn100013d.pmu.RED_NAME"; public static final String RED_OPTION = "mn100013d.pmu.RED_OPTION"; public static final String BLUE_NAME = "mn100013d.pmu.BLUE_NAME"; public static final String BLUE_OPTION = "mn100013d.pmu.BLUE_OPTION"; public static final String GREEN_NAME = "mn100013d.pmu.GREEN_NAME"; public static final String GREEN_OPTION = "mn100013d.pmu.GREEN_OPTION"; public static final String YELLOW_NAME = "mn100013d.pmu.YELLOW_NAME"; public static final String YELLOW_OPTION = "mn100013d.pmu.YELLOW_OPTION"; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_gametype, container, false); //Grabbing all the touches so they don't get delegated to Fragments below rootView.findViewById(R.id.relative_layout_game_type_holder).setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { return true; } }); final RadioGroup redGroup = ((RadioGroup)rootView.findViewById(R.id.red_group)); final RadioGroup blueGroup = ((RadioGroup)rootView.findViewById(R.id.blue_group)); final RadioGroup greenGroup = ((RadioGroup)rootView.findViewById(R.id.green_group)); final RadioGroup yellowGroup = ((RadioGroup)rootView.findViewById(R.id.yellow_group)); rootView.findViewById(R.id.bt_start_game).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { final String redName = ((EditText)rootView.findViewById(R.id.red_name)).getText().toString(); final String blueName = ((EditText)rootView.findViewById(R.id.blue_name)).getText().toString(); final String greenName = ((EditText)rootView.findViewById(R.id.green_name)).getText().toString(); final String yellowName = ((EditText)rootView.findViewById(R.id.yellow_name)).getText().toString(); Log.i("Nikola", redName); Log.i("Nikola", blueName); Log.i("Nikola", greenName); Log.i("Nikola", yellowName); Intent i = new Intent(getActivity(), NewGameActivity.class); i.putExtra(RED_NAME, redName); i.putExtra(BLUE_NAME, blueName); i.putExtra(GREEN_NAME, greenName); i.putExtra(YELLOW_NAME, yellowName); int optionId = redGroup.getCheckedRadioButtonId(); RadioButton rOption = (RadioButton) rootView.findViewById(optionId); String sOption = rOption.getText().toString(); i.putExtra(RED_OPTION, sOption); optionId = blueGroup.getCheckedRadioButtonId(); rOption = (RadioButton) rootView.findViewById(optionId); sOption = rOption.getText().toString(); i.putExtra(BLUE_OPTION, sOption); optionId = greenGroup.getCheckedRadioButtonId(); rOption = (RadioButton) rootView.findViewById(optionId); sOption = rOption.getText().toString(); i.putExtra(GREEN_OPTION, sOption); optionId = yellowGroup.getCheckedRadioButtonId(); rOption = (RadioButton) rootView.findViewById(optionId); sOption = rOption.getText().toString(); i.putExtra(YELLOW_OPTION, sOption); try { SoundService.getInstance().stop(SoundService.JINGLE); } catch (PlayerNotRegisteredException e) { // TODO Auto-generated catch block e.printStackTrace(); } startActivity(i); } }); return rootView; } @Override public Animation onCreateAnimation(int transit, boolean enter, int nextAnim) { Animation anim = null; if (enter) anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_in_left); else { anim = AnimationUtils.loadAnimation(getActivity(), R.anim.slide_out_right); } anim.setInterpolator(new OvershootInterpolator(3f)); return anim; } /* (non-Javadoc) * @see android.support.v4.app.Fragment#onPause() */ @Override public void onPause() { FragmentProvider.getInstance().remove(this); super.onPause(); } }