package com.sheep.gamegroup.model.entity;

import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.TextView;

import com.sheep.jiuyan.samllsheep.SheepApp;

/**
 * Created by realicing on 2018/11/8.
 * realicing@sina.com
 * 包含标题的list--搜索中的热门搜索与搜索历史用到
 */
public class TitleInfoList implements Comparable<TitleInfoList> {
    public TitleInfoList(String name, RecyclerView.Adapter adapter) {
        this.name = name;
        this.adapter = adapter;
    }

    private int sort;

    public int getSort() {
        return sort;
    }

    public TitleInfoList setSort(int sort) {
        this.sort = sort;
        return this;
    }

    private String name;
    private RecyclerView.Adapter adapter;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }


    public RecyclerView.Adapter getAdapter() {
        return adapter;
    }

    //水平
    public static final int LAYOUT_MANAGER_STYLE_VERTICAL = 0;
    //垂直
    public static final int LAYOUT_MANAGER_STYLE_HORIZONTAL = 1;
    private int layoutManagerStyle = LAYOUT_MANAGER_STYLE_VERTICAL;
    //设置水平滑动
    public TitleInfoList setHorizontal() {
        layoutManagerStyle = LAYOUT_MANAGER_STYLE_HORIZONTAL;
        return this;
    }

    public void setAdapter(RecyclerView.Adapter adapter) {
        this.adapter = adapter;
    }

    public RecyclerView.LayoutManager getLayoutManager() {
        switch (layoutManagerStyle){
            case LAYOUT_MANAGER_STYLE_HORIZONTAL:
                return new LinearLayoutManager(SheepApp.getInstance(), LinearLayoutManager.HORIZONTAL, false);
            case LAYOUT_MANAGER_STYLE_VERTICAL:
            default:
                return new LinearLayoutManager(SheepApp.getInstance());
        }
    }
    private boolean showTopLine = true;//默认显示上面的线

    public boolean isShowTopLine() {
        return showTopLine;
    }

    public TitleInfoList setShowTopLine(boolean showTopLine) {
        this.showTopLine = showTopLine;
        return this;
    }

    private boolean showBottomLine;

    public boolean isShowBottomLine() {
        return showBottomLine;
    }

    public TitleInfoList setShowBottomLine(boolean showBottomLine) {
        this.showBottomLine = showBottomLine;
        return this;
    }

    @Override
    public int compareTo(@NonNull TitleInfoList item) {
        return sort - item.getSort();
    }
}
