package com.sheep.gamegroup.view.fragment;

import android.support.v7.widget.RecyclerView;

import com.sheep.gamegroup.model.api.ApiService;
import com.sheep.gamegroup.model.entity.BaseMessage;
import com.sheep.gamegroup.model.entity.NoviceGuidance;
import com.sheep.gamegroup.view.adapter.AdpNoviceGuidance;
import com.sheep.jiuyan.samllsheep.SheepApp;
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;

import org.afinal.simplecache.ApiKey;

import io.reactivex.Observable;

/**
 * Created by realicing on 2018/11/9.
 * realicing@sina.com
 * 新手引导
 */
public class FgtUserNoviceGuidance extends BaseListFragment2<NoviceGuidance> {
    @Override
    public void initView() {
        TitleBarUtils.getInstance()
                .setShowOrHide(getActivity(), true)
                .setTitle(getActivity(), "新手引导")
                .setTitleFinish(getActivity());
        view_list.setLoadingMoreEnabled(false);
    }

    private AdpNoviceGuidance adapter;
    @Override
    protected RecyclerView.Adapter getAdapter() {
        adapter = new AdpNoviceGuidance(SheepApp.getInstance(), list);
        return adapter;
    }

    @Override
    protected String getKey(int page, int per_page) {
        return ApiKey.novice_guidance;
    }

    @Override
    protected Observable<BaseMessage> getApi(ApiService apiService) {
        return apiService.getNoviceGuidance();
    }

    @Override
    protected Class<NoviceGuidance> getTClass() {
        return NoviceGuidance.class;
    }

    @Override
    public void notifyDataSetChanged() {
        if(adapter != null){
            adapter.beforeNotifyDataSetChanged();
        }
        super.notifyDataSetChanged();
//        if(!list.isEmpty())
//            view_list.setPullRefreshEnabled(false);
    }
//
//    @Override
//    public void onPause() {
//        super.onPause();
//        if(adapter != null){
//            try {
//                adapter.onPause();
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//    }
//
//    @Override
//    public void onDestroy() {
//        super.onDestroy();
//        if(adapter != null){
//            try {
//                adapter.onDestroy();
//            } catch (Exception e) {
//                e.printStackTrace();
//            }
//        }
//    }
}
