package com.sheep.gamegroup.util;

import android.content.Context;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.footer.ClassicsFooter;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;

/**
 * SmartRefreshLayout
 * Created by ljy on 2018/9/18.
 */

public class RefreshUtil {

    private static RefreshUtil refreshUtil;

    public static RefreshUtil newInstance(){
        if(refreshUtil == null)
            refreshUtil = new RefreshUtil();
        return refreshUtil;
    }

    /**
     * SmartRefreshLayout初始化一些参数和信息
     */
    public void initRefresh(){
        ClassicsFooter.REFRESH_FOOTER_LOADING = "羊羊努力加载中...";//"正在加载...";
        ClassicsFooter.REFRESH_FOOTER_PULLING = "上拉加载更多";
        ClassicsFooter.REFRESH_FOOTER_RELEASE = "释放立即加载";
        ClassicsFooter.REFRESH_FOOTER_REFRESHING = "正在加载...";
        ClassicsFooter.REFRESH_FOOTER_FINISH = "加载完成";
        ClassicsFooter.REFRESH_FOOTER_FAILED = "加载失败";
        ClassicsFooter.REFRESH_FOOTER_NOTHING = "全部加载完成";
    }

    /**
     * public parameter
     */
    public void publicParameterLoadMore(SmartRefreshLayout refreshLayout, Context context){
        refreshLayout.setEnableRefresh(true);//是否启用下拉刷新功能
        refreshLayout.setEnableLoadMore(true);//是否启用上拉加载功能
        //设置 Header 为 贝塞尔雷达 样式
        refreshLayout.setRefreshHeader(new ClassicsHeader(context));
        //设置 Footer 为 球脉冲 样式
        refreshLayout.setRefreshFooter(new ClassicsFooter(context).setDrawableSize(20));
        refreshLayout.setEnableAutoLoadMore(true);
    }
    public void publicParameter(SmartRefreshLayout refreshLayout, Context context){
        refreshLayout.setEnableRefresh(true);//是否启用下拉刷新功能
        refreshLayout.setEnableLoadMore(false);//是否启用上拉加载功能
        //设置 Header 为 贝塞尔雷达 样式
        refreshLayout.setRefreshHeader(new ClassicsHeader(context));
        //设置 Footer 为 球脉冲 样式
        refreshLayout.setRefreshFooter(new ClassicsFooter(context).setDrawableSize(20));
        refreshLayout.setEnableAutoLoadMore(false);
    }
}
