package com.sheep.gamegroup.view.activity;

import android.support.v7.widget.RecyclerView;

import com.sheep.gamegroup.absBase.BaseListActivity2;
import com.sheep.gamegroup.model.api.ApiService;
import com.sheep.gamegroup.model.entity.BaseMessage;
import com.sheep.gamegroup.model.entity.GameEntity;
import com.sheep.gamegroup.model.entity.GameListType;
import com.sheep.gamegroup.util.DataUtil;
import com.sheep.gamegroup.view.adapter.PlayGameItemAdapter;
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;

import java.util.Locale;

import io.reactivex.Observable;

/**
 * Created by realicing on 2018/10/31.
 * realicing@sina.com
 * 猜你喜欢游戏列表
 */
public class ActPlayGameRecommendList extends BaseListActivity2<GameEntity> {

    private GameListType gameListType;
    @Override
    public void initView() {
        gameListType = DataUtil.getObject(getIntent(), GameListType.class);
        TitleBarUtils
                .getInstance()
                .setShowOrHide(this, true)
                .setTitle(this, gameListType.getTitle())
                .setTitleFinish(this);
    }
    @Override
    protected RecyclerView.Adapter getAdapter() {
        return new PlayGameItemAdapter(this, list);
    }

    @Override
    protected String getKey(int page, int per_page) {
        return String.format(Locale.CHINA, "app/find/recommend/list?display_type=%d", gameListType.getDisplay_type());
    }

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

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

    @Override
    public void notifyDataSetChanged() {
        if(!list.isEmpty())
            setNoMore(true);
        super.notifyDataSetChanged();
    }
}
