package anabalica.github.io.meowletters;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.TextView;


/**
 * This is the Game Over activity. When there are no more free spots for letters to appear, the
 * game ends.
 *
 * @author Ana Balica
 */
public class GameOverActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game_over);
        Intent intent = getIntent();
        String score = intent.getStringExtra(GameActivity.SCORE);

        TextView finalScore = (TextView) findViewById(R.id.finalScore);
        finalScore.setText("Score " + score);
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.menu_game_over, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();

        //noinspection SimplifiableIfStatement
        if (id == R.id.action_settings) {
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    /**
     * Start a new game
     */
    public void startNewGame(View view) {
        Intent intent = new Intent(this, GameActivity.class);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        this.startActivity(intent);
    }
}

@@ -1558,24 +1558,327 @@
 em);%0A    %7D%0A%0A
+    /**%0A     * Launch menu on 'Back' press%0A     */%0A    public void onBackPressed() %7B%0A        Intent intent = new Intent(this, MainActivity.class);%0A        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);%0A        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);%0A        this.startActivity(intent);%0A    %7D%0A%0A
     /**%0A    

handle Back button from GameOverActivity