package com.vikashkothary.life.ui.main;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.NavigationView;
import android.support.v4.view.GravityCompat;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;

import com.vikashkothary.life.R;
import com.vikashkothary.life.ui.base.BaseActivity;
import com.vikashkothary.life.ui.ribot.RibotFragment;
import com.vikashkothary.life.ui.login.LoginActivity;
import com.vikashkothary.life.ui.stream.StreamFragment;

import butterknife.BindView;
import butterknife.ButterKnife;

import static com.vikashkothary.life.ui.creation.CreationActivity.startCreation;
import static com.vikashkothary.life.ui.settings.SettingsActivity.startSettings;

public class MainActivity extends BaseActivity implements NavigationView.OnNavigationItemSelectedListener {

    @BindView(R.id.toolbar)
    Toolbar toolbar;
    @BindView(R.id.drawer_layout)
    DrawerLayout drawer;
    @BindView(R.id.nav_view)
    NavigationView navigationView;

    public static void startMain(Context context) {
        Intent intent = new Intent(context, MainActivity.class);
        context.startActivity(intent);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activityComponent().inject(this);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);

        setupActivity();

//        if (savedInstanceState == null);
    }

    private void setupActivity() {
        setSupportActionBar(toolbar);
        ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
                this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
        drawer.setDrawerListener(toggle);
        toggle.syncState();

        navigationView.setNavigationItemSelectedListener(this);
        navigationView.getHeaderView(0).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                startActivity(new Intent(getApplicationContext(), LoginActivity.class));
            }
        });
    }

    @Override
    public void onBackPressed() {
        if (drawer.isDrawerOpen(GravityCompat.START)) {
            drawer.closeDrawer(GravityCompat.START);
        } else {
            super.onBackPressed();
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.options_main, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.action_new:
                startCreation(this);
                return true;
            case R.id.action_search:
                return false;
            case R.id.action_settings:
                startSettings(this);
                return true;
            default:
                return super.onOptionsItemSelected(item);
        }
    }

    @Override
    public boolean onNavigationItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.nav_home:
                StreamFragment.attachFragment(this);
                break;
            case R.id.nav_level_physical:
                RibotFragment.attachFragment(this);
                break;
        }
        drawer.closeDrawer(GravityCompat.START);
        return true;
    }
}

@@ -1071,17 +1071,18 @@
 Toolbar 
-t
+mT
 oolbar;%0A
@@ -1132,17 +1132,18 @@
 rLayout 
-d
+mD
 rawer;%0A 
@@ -1189,17 +1189,18 @@
 ionView 
-n
+mN
 avigatio
@@ -1612,119 +1612,8 @@
 );%0A%0A
-        setupActivity();%0A%0A//        if (savedInstanceState == null);%0A    %7D%0A%0A    private void setupActivity() %7B%0A
     
@@ -1636,17 +1636,18 @@
 tionBar(
-t
+mT
 oolbar);
@@ -1739,17 +1739,19 @@
 is, 
-d
+mD
 rawer, 
-t
+mT
 oolb
@@ -1826,25 +1826,26 @@
 e);%0A        
-d
+mD
 rawer.setDra
@@ -1894,33 +1894,34 @@
 ate();%0A%0A        
-n
+mN
 avigationView.se
@@ -1967,17 +1967,18 @@
         
-n
+mN
 avigatio
@@ -2297,17 +2297,18 @@
     if (
-d
+mD
 rawer.is
@@ -2346,33 +2346,34 @@
 ) %7B%0A            
-d
+mD
 rawer.closeDrawe
@@ -3451,17 +3451,18 @@
         
-d
+mD
 rawer.cl

Rename global variables in MainActivity