package br.ufg.inf.adopet.activities;

import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.Toolbar;

import br.ufg.inf.adopet.R;
import br.ufg.inf.adopet.adapters.PagerAdapter;

public class MainActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener{

    private TabLayout mTabLayout;
    private ViewPager mViewPager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle(getString(R.string.app_name));

        mTabLayout = (TabLayout) findViewById(R.id.tabLayout);
        this.setUpTabs();
        mTabLayout.setTabGravity(TabLayout.GRAVITY_CENTER);

        mViewPager = (ViewPager) findViewById(R.id.pager);


        PagerAdapter pager = new PagerAdapter(getSupportFragmentManager(),mTabLayout.getTabCount(),false);
        mViewPager.setAdapter(pager);

        mTabLayout.addOnTabSelectedListener(this);

        setSupportActionBar(toolbar);
    }

    @Override
    public void onTabSelected(TabLayout.Tab tab) {
        mViewPager.setCurrentItem(tab.getPosition());
    }

    @Override
    public void onTabUnselected(TabLayout.Tab tab) {

    }

    @Override
    public void onTabReselected(TabLayout.Tab tab) {

    }

    private void setUpTabs(){

        String[] tabs = getResources().getStringArray(R.array.tabs);

        for (String tab : tabs){
            mTabLayout.addTab(mTabLayout.newTab().setText(tab));
        }

    }
}

@@ -767,16 +767,73 @@
 _name));
+%0A        toolbar.setNavigationIcon(R.mipmap.ic_launcher);
 %0A%0A      
@@ -1178,24 +1178,505 @@
 ter(pager);%0A
+        mViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() %7B%0A            @Override%0A            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) %7B%0A%0A            %7D%0A%0A            @Override%0A            public void onPageSelected(int position) %7B%0A                mTabLayout.getTabAt(position).select();%0A            %7D%0A%0A            @Override%0A            public void onPageScrollStateChanged(int state) %7B%0A%0A            %7D%0A        %7D);
 %0A        mTa

add listener for ViewPager and app icon toolbar