package cn.honjow.leanc.ui.Fragment;

import cn.honjow.leanc.adapter.QuestionListAdapter;
import cn.honjow.leanc.ui.Activice.ChoQueActivity;
import cn.droidlover.xdroidmvp.base.SimpleRecAdapter;
import cn.honjow.leanc.model.QuestionItem;
import cn.honjow.leanc.ui.BaseLeancFragment;
import cn.droidlover.xrecyclerview.RecyclerItemCallback;
import cn.droidlover.xrecyclerview.XRecyclerView;

/**
 * Created by honjow311 on 2017/5/17.
 */

public class ChoQueListFragment extends BaseLeancFragment {

    QuestionListAdapter adapter;

    @Override
    public SimpleRecAdapter getAdapter() {

        if (adapter == null) {
            adapter = new QuestionListAdapter(context);
            adapter.setRecItemClick(new RecyclerItemCallback<QuestionItem, QuestionListAdapter.ViewHolder>() {
                @Override
                public void onItemClick(int position, QuestionItem model, int tag, QuestionListAdapter.ViewHolder holder) {
                    super.onItemClick(position, model, tag, holder);
                    switch (tag) {
                        case QuestionListAdapter.TAG_VIEW:
                            ChoQueActivity.launch(context, model);
                            break;
                    }
                }
            });
        }
        return adapter;
    }

    @Override
    public void setLayoutManager(XRecyclerView recyclerView) {
        recyclerView.verticalLayoutManager(context);
    }

    @Override
    public String getType() {
        return "1";
    }

    public static ChoQueListFragment newInstance() {
        return new ChoQueListFragment();
    }
}
