package com.diggs.keenan.catchphraseadfree;

import android.media.MediaPlayer;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

public class FanfareActivity extends AppCompatActivity {
    // victory message "Team X Wins!"
    private TextView gameResultView;

    // will play crowd cheering sound
    private MediaPlayer fanfare;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fanfare);

        // display message for winning team
        gameResultView = (TextView)findViewById(R.id.game_result);
        String resultString = getIntent().getStringExtra("winner");
        if (resultString.equals("team_one")) {
            gameResultView.setText(R.string.team_one_wins);
        } else if (resultString.equals("team_two")) {
            gameResultView.setText(R.string.team_two_wins);
        }

        // play fanfare sound
        fanfare = MediaPlayer.create(this, R.raw.victory);
        if (fanfare != null) {
            fanfare.start();
        }

        // press anywhere to destroy activity
        gameResultView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onPause() {
        super.onPause();

        // release media player
        if (fanfare != null) {
            fanfare.release();
            fanfare = null;
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        FullScreenHelper.goFullscreen(this);
    }
}
@@ -350,12 +350,22 @@
  // 
-will
+MediaPlayer to
  pla
@@ -380,16 +380,26 @@
 cheering
+ (fanfare)
  sound%0A 
@@ -1401,32 +1401,60 @@
      %7D);%0A    %7D%0A%0A
+    // release media player%0A
     @Override%0A  
@@ -1510,41 +1510,8 @@
 e();
-%0A%0A        // release media player
 %0A   

update comments in FanfareActivity