package org.bits_waves.waves2017.activities;


/**
 * Created by Keshav on 10-Sep-17.
 */

import android.content.Intent;
import android.graphics.Color;
import android.support.design.widget.TabLayout;
import android.support.v7.app.AppCompatActivity;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import android.widget.ImageButton;

import org.bits_waves.waves2017.R;
import org.bits_waves.waves2017.fragment.OurTeam_FragementApp;
import org.bits_waves.waves2017.fragment.OurTeam_FragementWaves;

import java.util.ArrayList;
import java.util.List;

public class OurTeam extends AppCompatActivity {

    private static final String TAG="Our Team";

    @Override
    public void onBackPressed() {
        super.onBackPressed();
        overridePendingTransition(R.transition.left_to_right,R.transition.right_to_left);
    }

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

        View v=getWindow().getDecorView();
        v.setBackgroundColor(Color.GRAY);

        ImageButton back = findViewById(R.id.back_button);
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent it=new Intent(OurTeam.this,MainActivity.class);
                startActivity(it);
                overridePendingTransition(R.transition.left_to_right,R.transition.right_to_left);
            }
        });

        Log.d(TAG,"hello i m done");
        SectionsPagerAdapter mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());


        ViewPager mViewPager = findViewById(R.id.container2);
        setupViewPager(mViewPager);

        //      toolbarImage = (ImageView) findViewById(R.id.toolbar_image2);


        TabLayout tb =  findViewById(R.id.tabLayout);
        tb.setupWithViewPager(mViewPager);


    }

    public void setupViewPager(ViewPager viewpager)
    {
        SectionsPagerAdapter adapter=new SectionsPagerAdapter(getSupportFragmentManager());
        adapter.addFragment(new OurTeam_FragementApp(),"App");
        adapter.addFragment(new OurTeam_FragementWaves(),"Waves");
//        adapter.addFragment(new OurTeam_FragementSponsers(),"Sponsors");
        viewpager.setAdapter(adapter);

    }



    /**
     * A {@link FragmentPagerAdapter} that returns a fragment corresponding to
     * one of the sections/tabs/pages.
     */
    public class SectionsPagerAdapter extends FragmentPagerAdapter {

        public SectionsPagerAdapter(FragmentManager fm) {
            super(fm);
        }


        private final List<Fragment> mfragmentList = new ArrayList<>();
        private final List<String> mfragmentTitleList = new ArrayList<>();


        public void addFragment(Fragment frg, String title) {
            mfragmentList.add(frg);
            mfragmentTitleList.add(title);

        }


        @Override
        public CharSequence getPageTitle(int position) {
            return mfragmentTitleList.get(position);
        }

        @Override


        public Fragment getItem(int position) {
            return mfragmentList.get(position);
        }

        @Override
        public int getCount() {
            return mfragmentList.size();
        }

    }
}

