// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/IsReadViewHolder.java
// public class IsReadViewHolder extends RecyclerView.ViewHolder {
// 
//     private ItemIsReadBinding dataBinding;
//     private IsReadAdapter adapter;
//     public IsReadViewHolder(Context context,View itemView) {
//         super(itemView);
//         dataBinding = DataBindingUtil.bind(itemView);
//         LinearLayoutManager manager = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,true);
//         dataBinding.recyclerView.setHasFixedSize(true);
//         dataBinding.recyclerView.setLayoutManager(manager);
//         adapter = new IsReadAdapter(context);
//         List<HaveRead> haveReadList = DBUtils.getInstance(context).getHaveReadList();
//         adapter.addAll(haveReadList);
//         dataBinding.recyclerView.setAdapter(adapter);
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/PopularViewHolder.java
// public class PopularViewHolder extends RecyclerView.ViewHolder implements HomeInterface {
//     private ItemPopularListBinding dataBinding;
//     private PopularListAdapter adapter;
//     private HomePresenter presenter;
// 
//     public PopularViewHolder(Context context, View itemView) {
//         super(itemView);
//         dataBinding = DataBindingUtil.bind(itemView);
//         LinearLayoutManager manager = new LinearLayoutManager(context);
//         manager.setOrientation(LinearLayoutManager.HORIZONTAL);
//         dataBinding.recyclerView.setHasFixedSize(true);
//         dataBinding.recyclerView.setLayoutManager(manager);
//         presenter = new HomePresenter(context);
//         presenter.requestPopularList(this);
//         adapter = new PopularListAdapter(context);
//         dataBinding.recyclerView.setAdapter(adapter);
//     }
// 
//     @Override
//     public void onRequestPopularNewsSuccess(PopularNews news) {
//         adapter.addAll(news);
//     }
// 
//     @Override
//     public void onRequestPopularNewsFailed(String errMsg) {
// 
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/WelcomeViewHolder.java
// public class WelcomeViewHolder extends RecyclerView.ViewHolder {
// 
//     private ItemWelcomeBinding dataBinding;
//     public WelcomeViewHolder(View itemView) {
//         super(itemView);
//         dataBinding = DataBindingUtil.bind(itemView);
//     }
// }


import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.SpanWatcher;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.tyq.jiemian.R;
import com.tyq.jiemian.adapter.VH.IsReadViewHolder;
import com.tyq.jiemian.adapter.VH.PopularViewHolder;
import com.tyq.jiemian.adapter.VH.WelcomeViewHolder;
package com.tyq.jiemian.adapter;



/**
 * Created by tyq on 2016/6/1.
 */
public class MainAdapter extends RecyclerView.Adapter {
    private Context context;
    private LayoutInflater inflater;
    private final static int WELCOME_VIEW = 0;
    private final static int ISREADED_VIEW = 1;
    private final static int POPULAR_VIEW = 2;
    private final static int HISTORY_VIEW = 3;

    public MainAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType){
            case WELCOME_VIEW:
                return new WelcomeViewHolder(inflater.inflate(R.layout.item_welcome,parent,false));
            case ISREADED_VIEW:
// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/IsReadViewHolder.java
// public class IsReadViewHolder extends RecyclerView.ViewHolder {
// 
//     private ItemIsReadBinding dataBinding;
//     private IsReadAdapter adapter;
//     public IsReadViewHolder(Context context,View itemView) {
//         super(itemView);
//         dataBinding = DataBindingUtil.bind(itemView);
//         LinearLayoutManager manager = new LinearLayoutManager(context,LinearLayoutManager.HORIZONTAL,true);
//         dataBinding.recyclerView.setHasFixedSize(true);
//         dataBinding.recyclerView.setLayoutManager(manager);
//         adapter = new IsReadAdapter(context);
//         List<HaveRead> haveReadList = DBUtils.getInstance(context).getHaveReadList();
//         adapter.addAll(haveReadList);
//         dataBinding.recyclerView.setAdapter(adapter);
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/PopularViewHolder.java
// public class PopularViewHolder extends RecyclerView.ViewHolder implements HomeInterface {
//     private ItemPopularListBinding dataBinding;
//     private PopularListAdapter adapter;
//     private HomePresenter presenter;
// 
//     public PopularViewHolder(Context context, View itemView) {
//         super(itemView);
//         dataBinding = DataBindingUtil.bind(itemView);
//         LinearLayoutManager manager = new LinearLayoutManager(context);
//         manager.setOrientation(LinearLayoutManager.HORIZONTAL);
//         dataBinding.recyclerView.setHasFixedSize(true);
//         dataBinding.recyclerView.setLayoutManager(manager);
//         presenter = new HomePresenter(context);
//         presenter.requestPopularList(this);
//         adapter = new PopularListAdapter(context);
//         dataBinding.recyclerView.setAdapter(adapter);
//     }
// 
//     @Override
//     public void onRequestPopularNewsSuccess(PopularNews news) {
//         adapter.addAll(news);
//     }
// 
//     @Override
//     public void onRequestPopularNewsFailed(String errMsg) {
// 
//     }
// }
// 
// Path: app/src/main/java/com/tyq/jiemian/adapter/VH/WelcomeViewHolder.java
// public class WelcomeViewHolder extends RecyclerView.ViewHolder {
// 
//     private ItemWelcomeBinding dataBinding;
//     public WelcomeViewHolder(View itemView) {
//         super(itemView);
//         dataBinding = DataBindingUtil.bind(itemView);
//     }
// }


// Path: app/src/main/java/com/tyq/jiemian/adapter/MainAdapter.java
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.text.SpanWatcher;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import com.tyq.jiemian.R;
import com.tyq.jiemian.adapter.VH.IsReadViewHolder;
import com.tyq.jiemian.adapter.VH.PopularViewHolder;
import com.tyq.jiemian.adapter.VH.WelcomeViewHolder;

package com.tyq.jiemian.adapter;



/**
 * Created by tyq on 2016/6/1.
 */
public class MainAdapter extends RecyclerView.Adapter {
    private Context context;
    private LayoutInflater inflater;
    private final static int WELCOME_VIEW = 0;
    private final static int ISREADED_VIEW = 1;
    private final static int POPULAR_VIEW = 2;
    private final static int HISTORY_VIEW = 3;

    public MainAdapter(Context context) {
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        switch (viewType){
            case WELCOME_VIEW:
                return new WelcomeViewHolder(inflater.inflate(R.layout.item_welcome,parent,false));
            case ISREADED_VIEW:
                return new IsReadViewHolder(context,inflater.inflate(R.layout.item_is_read,parent,false));