package com.sheep.gamegroup.view.activity;

import android.app.Activity;
import android.support.design.widget.TabLayout;
import android.support.v4.view.ViewPager;

import com.sheep.gamegroup.absBase.BaseActivity;
import com.sheep.gamegroup.util.CommonUtil;
import com.sheep.gamegroup.util.UMConfigUtils;
import com.sheep.gamegroup.view.adapter.TitleFragmentListAdapter;
import com.sheep.gamegroup.view.fragment.FgtSignRankings;
import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;

import butterknife.BindView;

/**
 * 本月排行榜
 */

public class SignRankingsAct extends BaseActivity {

    Activity activity;


    @BindView(R.id.sign_ViewPager)
    ViewPager signViewPager;
    @BindView(R.id.sign_tab)
    TabLayout indicator;

    @Override
    protected int getLayoutId() {
        return R.layout.sign_rankings_layout;
    }

    @Override
    public void initView() {
        activity = this;
        TitleBarUtils
                .getInstance()
                .setShowOrHide(this, true)
                .setTitle(activity, "本月排行榜")
                .setTitleFinish(activity);
    }


    @Override
    public void initListener() {
        TitleFragmentListAdapter mAdapter = new TitleFragmentListAdapter(getSupportFragmentManager());
        mAdapter.add(FgtSignRankings.getInstance(0), "累计打卡");
        mAdapter.add(FgtSignRankings.getInstance(1), "连续打卡");
        signViewPager.setAdapter(mAdapter);
        indicator.setupWithViewPager(signViewPager);

        signViewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int i, float v, int i1) {

            }

            @Override
            public void onPageSelected(int i) {
                switch (i) {
                    case 0:
                        selectLeft();
                        break;
                    case 1:
                        selectRight();
                        break;
                }
            }

            @Override
            public void onPageScrollStateChanged(int i) {

            }
        });
        CommonUtil.getInstance().reflex(indicator, activity);
    }

    @Override
    public void initData() {
    }


    private void selectLeft() {
        UMConfigUtils.Event.PUNCH_ACCUMULATIVE_LIST.onEvent();
    }

    private void selectRight() {
        UMConfigUtils.Event.PUNCH_CONTINUATION.onEvent();
    }

}
