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; /* w w w. j ava2 s . c o m*/ import mn100013d.pmu.exceptions.PlayerNotRegisteredException; import mn100013d.pmu.services.FragmentProvider; import mn100013d.pmu.services.SoundService; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; 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.ImageView; public class StartGameFragment extends Fragment { private ImageView newGame; private ImageView settings; private ImageView results; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View rootView = inflater.inflate(R.layout.fragment_start_game, container, false); newGame = (ImageView) rootView.findViewById(R.id.bt_new_game); results = (ImageView) rootView.findViewById(R.id.bt_results); settings = (ImageView) rootView.findViewById(R.id.bt_settings); ImageView zombie = (ImageView) rootView.findViewById(R.id.image_zombie); Animation zombieMove = AnimationUtils.loadAnimation(getActivity(), R.anim.zombie_move_forward); zombie.startAnimation(zombieMove); try { SoundService.getInstance().setContext(getActivity()); SoundService.getInstance().instantiateService(); SoundService.getInstance().play(SoundService.JINGLE, true); } catch (PlayerNotRegisteredException e) { e.printStackTrace(); } newGame.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { SoundService.getInstance().play(SoundService.CLICK_SOUND, false); FragmentProvider.getInstance().changeFragment( FragmentProvider.GAMETYPE); } catch (PlayerNotRegisteredException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); settings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { SoundService.getInstance().play(SoundService.CLICK_SOUND, false); FragmentProvider.getInstance().changeFragment( FragmentProvider.SETTINGS); } catch (PlayerNotRegisteredException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); results.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { try { SoundService.getInstance().play(SoundService.CLICK_SOUND, false); FragmentProvider.getInstance().changeFragment( FragmentProvider.SCORES); } catch (PlayerNotRegisteredException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }); 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; } }