AllTopicActivity.java 4.52 KB
Newer Older
konghaorui committed
1 2 3 4 5 6 7 8 9 10
package com.yidianling.dynamic.topic;

import android.os.Bundle;
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.view.View;
import android.widget.ImageView;

konghaorui committed
11
import com.ydl.ydlcommon.bean.StatusBarOptions;
konghaorui committed
12 13 14
import com.yidianling.dynamic.R;
import com.ydl.ydlcommon.base.BaseActivity;

konghaorui committed
15 16
import org.jetbrains.annotations.NotNull;

konghaorui committed
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
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;

konghaorui committed
35 36 37 38 39 40
    @NotNull
    @Override
    public StatusBarOptions getStatusViewOptions() {
        return new StatusBarOptions(true, true);
    }

konghaorui committed
41 42 43 44
    //    private  HotTopicFragment hottopic_fragmen;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
konghaorui committed
45
        setContentView(R.layout.dynamic_activity_all_topic);
konghaorui committed
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
        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:
konghaorui committed
91 92
//                        topic_tab_all_tv.setTextColor(getResources().getColor(R.color.dynamic_title_green));
//                        topic_tab_all_hint_tv.setBackgroundColor(getResources().getColor(R.color.dynamic_title_green));
konghaorui committed
93 94 95
//
//                        break;
//                    case 1:
konghaorui committed
96 97
//                        topic_tab_hot_tv.setTextColor(getResources().getColor(R.color.dynamic_title_green));
//                        topic_tab_hot_hint_tv.setBackgroundColor(getResources().getColor(R.color.dynamic_title_green));
konghaorui committed
98 99 100 101 102 103 104 105 106 107 108 109 110 111
//
//                        break;
//
//                }
            }

            @Override
            public void onPageScrollStateChanged(int state) {

            }
        });
    }

//    private void resetText() {
konghaorui committed
112 113 114 115
//        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));
konghaorui committed
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
//    }

    @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() {

    }
}