package com.naijab.nextzytimeline.ui.main;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.ActionBar;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;

import com.naijab.nextzytimeline.R;
import com.naijab.nextzytimeline.base.BaseMvpActivity;
import com.naijab.nextzytimeline.ui.main.home.HomeFragment;
import com.naijab.nextzytimeline.ui.people.addform.AddPeopleActivity;

public class MainActivity extends BaseMvpActivity<MainActivityInterface.Presenter>
        implements MainActivityInterface.View {
    private Toolbar toolbar;
    private FloatingActionButton fab;

    public MainActivity() {
        super();
    }

    @Override
    public MainActivityInterface.Presenter createPresenter() {
        return MainActivityPresenter.create();
    }

    @Override
    public int getLayoutView() {
        return R.layout.activity_main;
    }

    @Override
    public void bindView() {
        toolbar = (Toolbar) findViewById(R.id.toolbar);
        fab = (FloatingActionButton) findViewById(R.id.fab);
    }

    @Override
    public void setupInstance() {
    }

    @Override
    public void setupView() {
        setupToolbar();
        setupFragment();
        setupFab();
    }

    private void setupFragment() {
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.container, HomeFragment.newInstance())
                .commit();
    }

    private void setupFab() {
        fab.setOnClickListener(fabListener);
    }

    private View.OnClickListener fabListener = new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            goToAddPeople();
        }
    };

    private void goToAddPeople(){
        Intent intent = new Intent(MainActivity.this, AddPeopleActivity.class);
        startActivity(intent);
        overridePendingTransition( R.anim.fade_in, R.anim.fade_out );
    }

    private void setupToolbar() {
        setSupportActionBar(toolbar);
        ActionBar actionbar = getSupportActionBar();
        if (actionbar != null) {
            actionbar.setDisplayHomeAsUpEnabled(false);
            actionbar.setDisplayShowTitleEnabled(false);
        }
    }

    @Override
    public void initialize() {
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu_home_people, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
            case R.id.menu_english:
                setLanguage("en");
                return true;
            case R.id.menu_thai:
                setLanguage("th");
                return true;
        }
        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState) {
        super.onRestoreInstanceState(savedInstanceState);
    }


}


@@ -427,27 +427,24 @@
 ne.base.Base
-Mvp
 Activity;%0Aim
@@ -614,19 +614,16 @@
 Base
-Mvp
 Activity
 %3CMai
@@ -622,339 +622,172 @@
 vity
-%3CMainActivityInterface.Presenter%3E%0A        implements MainActivityInterface.View %7B%0A    private Toolbar toolbar;%0A    private FloatingActionButton fab;%0A%0A    public MainActivity() %7B%0A        super();%0A    %7D%0A%0A    @Override%0A    public MainActivityInterface.Presenter createPresenter() %7B%0A        return MainActivityPresenter.create();%0A    %7D
+ %7B%0A%0A    private static final String ENGLISH = %22en%22;%0A    private static final String THAI = %22th%22;%0A%0A    private Toolbar toolbar;%0A    private FloatingActionButton fab;
 %0A%0A  
@@ -1211,32 +1211,84 @@
 upFab();%0A    %7D%0A%0A
+    @Override%0A    public void initialize() %7B%0A    %7D%0A%0A
     private void
@@ -2239,60 +2239,8 @@
  %7D%0A%0A
-    @Override%0A    public void initialize() %7B%0A    %7D%0A%0A
     
@@ -2609,20 +2609,23 @@
 anguage(
-%22en%22
+ENGLISH
 );%0A     
@@ -2709,20 +2709,20 @@
 anguage(
-%22th%22
+THAI
 );%0A     
@@ -3086,12 +3086,11 @@
 %0A    %7D%0A%0A
-%0A
 %7D%0A%0A

Edit MainActivity