package com.sheep.gamegroup.view.activity;


import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.View;

import com.sheep.gamegroup.absBase.BaseActivity;
import com.sheep.gamegroup.view.adapter.ViewPagerFragmentAdapter;
import com.sheep.gamegroup.view.fragment.FgtMsgCenter;
import com.sheep.gamegroup.view.fragment.FgtMsgReply;
import com.sheep.jiuyan.samllsheep.R;
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;

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

import butterknife.BindView;

/**
 * Created by realicing on 2018/04/.
 * realicing@sina.com
 * 描述:消息Activity，展示消息中心和互动消息两个模块
 */
public class ActMsg extends BaseActivity {
    @BindView(R.id.act_msg_vp)
    ViewPager act_msg_vp;
    @BindView(R.id.title_tab_oval_0)
    View title_tab_oval_0;
    @BindView(R.id.title_tab_oval_1)
    View title_tab_oval_1;

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

    private List<Fragment> fragmentList = new ArrayList<>();
    private List<View> ovalList = new ArrayList<>();

    @Override
    public void initView() {
        TitleBarUtils.getInstance()
                .setShowOrHide(this, true)
                .setTitleFinish(this)
                .addMsgTab(this, act_msg_vp);
        fragmentList.add(new FgtMsgCenter());
        fragmentList.add(new FgtMsgReply());
        ViewPagerFragmentAdapter mViewPagerFragmentAdapter = new ViewPagerFragmentAdapter(getSupportFragmentManager(), fragmentList);
        act_msg_vp.setAdapter(mViewPagerFragmentAdapter);
        act_msg_vp.setCurrentItem(0, false);
        act_msg_vp.setOffscreenPageLimit(mViewPagerFragmentAdapter.getCount());
        ovalList.add(title_tab_oval_0);
        ovalList.add(title_tab_oval_1);
        for (View view : ovalList) {
            view.setVisibility(View.INVISIBLE);
        }
    }

    //设置小红点的显示与隐藏
    public void updateMsgOval(int index, boolean hasMsgNotRead) {
        ovalList.get(index).setVisibility(hasMsgNotRead ? View.VISIBLE : View.INVISIBLE);
    }
}

