package com.codepath.apps.twitterApp;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

import com.codepath.apps.twitterApp.fragments.TweetsPagerAdapter;

public class TimelineActivity extends AppCompatActivity {

    public final static String TAG = "TimelineActivity";

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

        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);
        Log.i(TAG, "Found toolbar");

        ViewPager vpPager = (ViewPager) findViewById(R.id.viewpager);
        vpPager.setAdapter(new TweetsPagerAdapter(getSupportFragmentManager(), this));
        TabLayout tabLayout = (TabLayout) findViewById(R.id.sliding_tabs);
        tabLayout.setupWithViewPager(vpPager);
    }

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

//    @Override
//    public boolean onOptionsItemSelected(MenuItem item) {
//        switch (item.getItemId()) {
//            case R.id.miWriteTweet:
//                //TODO: fill in more menu buttons
//            default:
//                return super.onOptionsItemSelected(item);
//        }
//    }

    public void onProfileView(MenuItem item) {
        // launch profile view
        Intent i = new Intent(this, ProfileActivity.class);
        startActivity(i);
    }



}

@@ -712,16 +712,22 @@
         
+final 
 Toolbar 
@@ -858,16 +858,22 @@
         
+final 
 ViewPage
@@ -938,27 +938,45 @@
     
-vpPager.set
+final TweetsPagerAdapter tp
 Adapter
-(
+ = 
 new 
@@ -1028,16 +1028,54 @@
 ), this)
+;%0A        vpPager.setAdapter(tpAdapter
 );%0A     
@@ -1186,24 +1186,600 @@
 er(vpPager);
+%0A%0A        tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() %7B%0A            @Override%0A            public void onTabSelected(TabLayout.Tab tab) %7B%0A                // vpPager.setCurrentItem(tab.getPosition());%0A                toolbar.setTitle(tpAdapter.getPageTitle(tab.getPosition()));%0A                //Set title here using setTitle()%0A            %7D%0A%0A            @Override%0A            public void onTabUnselected(TabLayout.Tab tab) %7B%0A            %7D%0A%0A            @Override%0A            public void onTabReselected(TabLayout.Tab tab) %7B%0A            %7D%0A        %7D);
 %0A    %7D%0A%0A    

Change titles by tab