频道管理

package com.bwei.headline;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.bawei.channelmanager.bean.ChannelBean;
import com.bawei.channelmanager.ui.ChannelView;

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

public class ChannelActivity extends AppCompatActivity implements View.OnClickListener {

    private ImageView iv_back;
    private TextView edit;
    private ChannelView channe_view;

    // 存放频道的List
    private List<ChannelBean> loveChannel = new ArrayList<>();
    private List<ChannelBean> moreChannel = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_channel);
        initView();
        getServer();
    }

    private void initView() {
        iv_back = (ImageView) findViewById(R.id.iv_back);
        edit = (TextView) findViewById(R.id.edit);
        channe_view = (ChannelView) findViewById(R.id.channe_view);
    }

    private void getServer() {
        iv_back.setOnClickListener(this);
        edit.setOnClickListener(this);

        channe_view.addHead(View.inflate(this,R.layout.channel_head,null));
        channe_view.addMore(View.inflate(this,R.layout.channel_more,null));

        // 初始化数据
        for (int i = 0; i < 20; i++) {
            if(i % 2 == 0) {
                loveChannel.add(new ChannelBean("费晓萱" + i, i, "http://gank.io/api/data/%E7%A6%8F%E5%88%A9/10/1", true));
            } else {
                moreChannel.add(new ChannelBean("曲学超" + i, i, "http://gank.io/api/data/%E7%A6%8F%E5%88%A9/10/1", false));
            }
        }

        // channelView的优化
        channe_view.init(loveChannel, moreChannel, new ChannelView.ChannelCallback() {
            @Override
            public void onMyChannelRemove(ChannelBean channelBean) {

            }

            @Override
            public void moMoreChannelRemove(ChannelBean channelBean) {

            }
        });
    }

    private boolean channelState;

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.iv_back:
                finish();
                break;
            case R.id.edit:
                if (!channelState){
                    edit.setText("完成");
                } else {
                    edit.setText("编辑");
                }
                channe_view.changeMyChannelState();
                channelState = !channelState;
                break;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值