// Path: android/JBox/app/src/main/java/com/jiguang/jbox/data/model/Channel.java
// @Table(name = "Channel")
// public class Channel extends Model {
// 
//     @Column(name = "DevKey")
//     public String devKey;
// 
//     @Column(name = "Name")
//     public String name;
// 
//     @Column(name = "UnreadCount")
//     public int unreadCount; // 未读消息数。
// 
//     @Column(name = "IsSubscribe")
//     public boolean isSubscribe;    // 默认为订阅。
// 
//     public Channel() {
//         super();
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == null) {
//             return false;
//         }
//         if (!(obj instanceof Channel)) {
//             return false;
//         }
//         Channel objChannel = (Channel) obj;
//         return objChannel.name.equals(name) && objChannel.isSubscribe == this.isSubscribe;
//     }
// }
// 
// Path: android/JBox/app/src/main/java/com/jiguang/jbox/util/ViewHolder.java
// public class ViewHolder {
// 
//     @SuppressWarnings("unchecked")
//     public static <T extends View> T get(View view, int id) {
//         SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
//         if (viewHolder == null) {
//             viewHolder = new SparseArray<>();
//             view.setTag(viewHolder);
//         }
//         View childView = viewHolder.get(id);
//         if (childView == null) {
//             childView = view.findViewById(id);
//             viewHolder.put(id, childView);
//         }
//         return (T) childView;
//     }
// }


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.jiguang.jbox.R;
import com.jiguang.jbox.data.model.Channel;
import com.jiguang.jbox.util.ViewHolder;
import java.util.List;

    void replaceData(List<Channel> channels) {
        mChannels = channels;
    }

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

    @Override
    public Channel getItem(int i) {
        return mChannels.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View convertView, ViewGroup viewGroup) {
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
            convertView = inflater.inflate(R.layout.item_subscribe_channel, viewGroup, false);
        }

        Channel channel = getItem(i);
        String name = channel.name;

// Path: android/JBox/app/src/main/java/com/jiguang/jbox/data/model/Channel.java
// @Table(name = "Channel")
// public class Channel extends Model {
// 
//     @Column(name = "DevKey")
//     public String devKey;
// 
//     @Column(name = "Name")
//     public String name;
// 
//     @Column(name = "UnreadCount")
//     public int unreadCount; // 未读消息数。
// 
//     @Column(name = "IsSubscribe")
//     public boolean isSubscribe;    // 默认为订阅。
// 
//     public Channel() {
//         super();
//     }
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (obj == null) {
//             return false;
//         }
//         if (!(obj instanceof Channel)) {
//             return false;
//         }
//         Channel objChannel = (Channel) obj;
//         return objChannel.name.equals(name) && objChannel.isSubscribe == this.isSubscribe;
//     }
// }
// 
// Path: android/JBox/app/src/main/java/com/jiguang/jbox/util/ViewHolder.java
// public class ViewHolder {
// 
//     @SuppressWarnings("unchecked")
//     public static <T extends View> T get(View view, int id) {
//         SparseArray<View> viewHolder = (SparseArray<View>) view.getTag();
//         if (viewHolder == null) {
//             viewHolder = new SparseArray<>();
//             view.setTag(viewHolder);
//         }
//         View childView = viewHolder.get(id);
//         if (childView == null) {
//             childView = view.findViewById(id);
//             viewHolder.put(id, childView);
//         }
//         return (T) childView;
//     }
// }


// Path: android/JBox/app/src/main/java/com/jiguang/jbox/ui/channel/SubChannelListAdapter.java
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.TextView;
import com.jiguang.jbox.R;
import com.jiguang.jbox.data.model.Channel;
import com.jiguang.jbox.util.ViewHolder;
import java.util.List;


    void replaceData(List<Channel> channels) {
        mChannels = channels;
    }

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

    @Override
    public Channel getItem(int i) {
        return mChannels.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(final int i, View convertView, ViewGroup viewGroup) {
        if (convertView == null) {
            LayoutInflater inflater = LayoutInflater.from(viewGroup.getContext());
            convertView = inflater.inflate(R.layout.item_subscribe_channel, viewGroup, false);
        }

        Channel channel = getItem(i);
        String name = channel.name;

        TextView tvHead = ViewHolder.get(convertView, R.id.tv_head);