package com.example.ghomi.chapter7_2;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.TextView;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {
    TextView result;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        result = (TextView)findViewById(R.id.result);
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.my_menu, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.open:
               // startActivity(new Intent(this, open.class));
               // Toast.makeText(this, "You clicked on open", Toast.LENGTH_LONG).show();
                result.setText("You clicked on Open");
                return true;
            case R.id.savecurrent:
               // Toast.makeText(this, "You clicked on Save current", Toast.LENGTH_LONG).show();
               // startActivity(new Intent(this, save.class));
                result.setText("You clicked on Save current file");
                return true;
            case R.id.saveall:
               // startActivity(new Intent(this, save.class));
                //Toast.makeText(this, "You clicked on Save all", Toast.LENGTH_LONG).show();
                result.setText("You clicked on Save all files");
                return true;
            case R.id.closecurrent:
               //startActivity(new Intent(this, Close.class));
               // Toast.makeText(this, "You clicked on close current", Toast.LENGTH_LONG).show();
                result.setText("You clicked on Close current file");
                return true;
            case R.id.closeall:
               // startActivity(new Intent(this, save.class));
               // Toast.makeText(this, "You clicked on close all", Toast.LENGTH_LONG).show();
                result.setText("You clicked on Close all files");
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }
}
