package com.shortsands.audioplayer;

import android.os.Bundle;
//import android.support.design.widget.FloatingActionButton;
//import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
//import android.view.View;
import android.view.Menu;
import android.view.MenuItem;

public class MainActivity extends AppCompatActivity {

    private static String TAG = "MainActivity";
    AudioBibleController controller = null;

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

        //FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        //fab.setOnClickListener(new View.OnClickListener() {
        //    @Override
        //    public void onClick(View view) {
        //        Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
        //                .setAction("Action", null).show();
        //    }
        //});

        this.controller = new AudioBibleController(this);
        this.controller.present();
    }

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

    @Override
    public void onResume() {
        super.onResume();
        Log.d(TAG, "*** onResume is called.");
    }

    /**
     * onPause is called here when the App is quit by using any of the three
     * buttons at the bottom.
     */
    @Override
    public void onPause() {
        super.onPause();
        Log.d(TAG, "*** onPause is called.");
        this.controller.appHasExited();
    }
}

@@ -60,118 +60,8 @@
 le;%0A
-//import android.support.design.widget.FloatingActionButton;%0A//import android.support.design.widget.Snackbar;%0A
 impo
@@ -176,36 +176,8 @@
 og;%0A
-//import android.view.View;%0A
 impo
@@ -645,503 +645,8 @@
 ar);
-%0A%0A        //FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);%0A        //fab.setOnClickListener(new View.OnClickListener() %7B%0A        //    @Override%0A        //    public void onClick(View view) %7B%0A        //        Snackbar.make(view, %22Replace with your own action%22, Snackbar.LENGTH_LONG)%0A        //                .setAction(%22Action%22, null).show();%0A        //    %7D%0A        //%7D);%0A%0A        this.controller = new AudioBibleController(this);%0A        this.controller.present();
 %0A   
@@ -1490,24 +1490,118 @@
  called.%22);%0A
+        this.controller = new AudioBibleController(this);%0A        this.controller.present();%0A%0A
     %7D%0A%0A    /
@@ -1708,16 +1708,36 @@
 e bottom
+, or the lock button
 .%0A     *
@@ -1843,32 +1843,75 @@
 e is called.%22);%0A
+        if (this.controller != null) %7B%0A    
         this.con
@@ -1930,20 +1930,30 @@
 asExited();%0A
+        %7D%0A
     %7D%0A%7D%0A

Change App to restart properly on each restart.