package com.sheep.gamegroup.view.activity;

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.GameEntity;
import com.sheep.gamegroup.model.entity.PlayGameEntity;
import com.sheep.gamegroup.view.adapter.PlayGameItemAdapter;
import com.sheep.jiuyan.samllsheep.utils.TitleBarUtils;

import java.util.Locale;

import rx.Observable;

/**
 * 每日必做和热门
 * Created by ljy on 2018/9/3.
 */

public class ActEverydayPlayGame extends BaseListActivity<GameEntity> {
    private int type;
    @Override
    protected RecyclerView.Adapter getAdapter() {
        return new PlayGameItemAdapter(activity, list);
    }

    @Override
    protected String getKey(int page, int per_page) {
        return type == 0 ?String.format(Locale.CHINA, "app/find?page=%d&per_page=%d&is_hot=%d&daily_play=%d&type=%d", page, per_page, 0, 1, 0)
                :String.format(Locale.CHINA, "app/find?page=%d&per_page=%d&is_hot=%d&daily_play=%d&type=%d", page, per_page, 1, 0, 0);
    }

    @Override
    protected Observable<BaseMessage> getApi(ApiService apiService) {
        return type == 0 ? apiService.playgameDailyOrHotOrTypePlay(page, per_page, 0, 1, 0)
                : apiService.playgameDailyOrHotOrTypePlay(page, per_page, 1, 0, 0);
    }

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

    @Override
    protected int getType() {
        type = getIntent().getIntExtra("type", 0);
        TitleBarUtils
                .getInstance()
                .setTitle(activity, type==0?"每日必做":"近期最热")
                .setTitleFinish(activity);
        return type;
    }
}
