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.GiftBagApp;
import com.sheep.gamegroup.view.adapter.GiftCenterAdapter;
import com.sheep.gamegroup.view.adapter.WelfareAdapter;

import java.util.Locale;

import io.reactivex.Observable;
import rx.functions.Action1;

/**
 * 我的福利--我的礼包
 * Created by realicing on 2018/8/28.
 * realicing@sina.com
 */
public class FgtMyGift extends BaseListFragment2<GiftBagApp> implements Action1<Integer> {
    @Override
    public void call(Integer integer) {
        switch (integer){
            case WelfareAdapter.TO_REFRESH:
                refreshData();
                break;
        }
    }

    @Override
    protected boolean isFirstGetACache() {
        return false;
    }

    @Override
    protected RecyclerView.Adapter getAdapter() {
        return new GiftCenterAdapter(activity, list, this);
    }

    @Override
    protected String getKey(int page, int per_page) {
        return String.format(Locale.CHINA, "app/gift_bag/my_gift_bag?page=%d&per_page=%d", page, per_page);
    }

    @Override
    protected Observable<BaseMessage> getApi(ApiService apiService) {
        return apiService.getMyGiftBagList(page, per_page);
    }

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

}
