package com.yidianling.dynamic.topic;

import android.os.Bundle;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;
import androidx.viewpager.widget.ViewPager;
import android.view.View;
import android.widget.ImageView;

import com.ydl.ydlcommon.bean.StatusBarOptions;
import com.yidianling.dynamic.R;
import com.ydl.ydlcommon.base.BaseActivity;

import org.jetbrains.annotations.NotNull;

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

/**
 * 话题
 */
public class AllTopicActivity extends BaseActivity implements View.OnClickListener {
    private ImageView back_iv;
    //    private RelativeLayout topic_tab_all_rel,topic_tab_hot_rel;
//    private TextView topic_tab_all_tv,topic_tab_all_hint_tv,topic_tab_hot_tv,topic_tab_hot_hint_tv;
    private ViewPager topic_tab_vp;

    private FragmentPagerAdapter mAdapter;
    private List<Fragment> mDatas;

    private FragmentManager fragmentManager;
    private AllTopicFragment alltopic_fragment;

    @NotNull
    @Override
    public StatusBarOptions getStatusViewOptions() {
        return new StatusBarOptions(true, true);
    }

    //    private  HotTopicFragment hottopic_fragmen;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dynamic_activity_all_topic);
        initView();
    }

    private void initView() {
        back_iv = (ImageView) findViewById(R.id.topic_title_back_iv);
//        topic_tab_all_rel=(RelativeLayout)findViewById(topic_tab_all_rel);
//        topic_tab_hot_rel=(RelativeLayout)findViewById(topic_tab_hot_rel);
//        topic_tab_all_tv=(TextView)findViewById(topic_tab_all_tv);
//        topic_tab_all_hint_tv=(TextView)findViewById(topic_tab_all_hint_tv);
//        topic_tab_hot_tv=(TextView)findViewById(topic_tab_hot_tv);
//        topic_tab_hot_hint_tv=(TextView)findViewById(topic_tab_hot_hint_tv);
        topic_tab_vp = (ViewPager) findViewById(R.id.topic_tab_vp);
        back_iv.setOnClickListener(this);
//        topic_tab_all_rel.setOnClickListener(this);
//        topic_tab_hot_rel.setOnClickListener(this);

        alltopic_fragment = new AllTopicFragment();
//        hottopic_fragmen=new HotTopicFragment();
        mDatas = new ArrayList<Fragment>();
        mDatas.add(alltopic_fragment);
//        mDatas.add(hottopic_fragmen);
        mAdapter = new FragmentPagerAdapter(getSupportFragmentManager()) {

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

            @Override
            public Fragment getItem(int arg0) {
                return mDatas.get(arg0);
            }
        };
        topic_tab_vp.setAdapter(mAdapter);
        topic_tab_vp.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
            @Override
            public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

            }

            @Override
            public void onPageSelected(int position) {
//                resetText();
//                switch (position) {
//                    case 0:
//                        topic_tab_all_tv.setTextColor(getResources().getColor(R.color.platform_main_theme));
//                        topic_tab_all_hint_tv.setBackgroundColor(getResources().getColor(R.color.platform_main_theme));
//
//                        break;
//                    case 1:
//                        topic_tab_hot_tv.setTextColor(getResources().getColor(R.color.platform_main_theme));
//                        topic_tab_hot_hint_tv.setBackgroundColor(getResources().getColor(R.color.platform_main_theme));
//
//                        break;
//
//                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

//    private void resetText() {
//        topic_tab_all_tv.setTextColor(getResources().getColor(R.color.dynamic_text_gray));
//        topic_tab_all_hint_tv.setBackgroundColor(getResources().getColor(R.color.dynamic_white));
//        topic_tab_hot_tv.setTextColor(getResources().getColor(R.color.dynamic_text_gray));
//        topic_tab_hot_hint_tv.setBackgroundColor(getResources().getColor(R.color.dynamic_white));
//    }

    @Override
    public void onClick(View v) {
        if (v.getId() == R.id.topic_title_back_iv) {
            finish();
        }
    }

    @Override
    protected int layoutResId() {
        return 0;
    }

    @Override
    protected void initDataAndEvent() {

    }
}
