package com.jdoneill.slopeangle;

import android.os.Bundle;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.google.android.material.snackbar.Snackbar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        FloatingActionButton fab = findViewById(R.id.fab);
        fab.setOnClickListener(view -> Snackbar.make(view, "Unregister Slope Angle", Snackbar.LENGTH_LONG)
                .setAction("Stop", v -> {
                    SlopeAngleSensorFragment sasFrag = (SlopeAngleSensorFragment)getFragmentManager().findFragmentById(R.id.fragment);
                    sasFrag.unregisterListeners();
                }).show());

    }

    @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_main, 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);
    }
}

@@ -335,34 +335,8 @@
 tem;
-%0Aimport android.view.View;
 %0A%0Apu
@@ -1144,89 +1144,8 @@
 ) %7B%0A
-        // Inflate the menu; this adds items to the action bar if it is present.%0A
     
@@ -1311,287 +1311,35 @@
     
-// Handle action bar item clicks here. The action bar will%0A        // automatically handle clicks on the Home/Up button, so long%0A        // as you specify a parent activity in AndroidManifest.xml.%0A        int id = item.getItemId();%0A%0A        //noinspection SimplifiableIfStatement
+int id = item.getItemId();%0A
 %0A   

clean up