package com.sheep.gamegroup.view.fragment;

import android.support.v7.widget.RecyclerView;

import com.mdad.sdk.mdsdk.AdManager;
import com.mdad.sdk.mdsdk.GetAdListListener;
import com.mdad.sdk.mdsdk.common.AdData;
import com.sheep.gamegroup.util.ListUtil;
import com.sheep.gamegroup.view.adapter.AdpMiDong;
import com.sheep.jiuyan.samllsheep.SheepApp;

import java.util.List;

/**
 * Created by realicing on 2018/10/18.
 * realicing@sina.com
 * 幂动任务--普通任务
 */
public class FgtMiDongAdTskList extends BaseListFragment<AdData> {

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

    @Override
    public void initData() {
        if (page == 1)
            list.clear();
        AdManager.getInstance(SheepApp.getInstance()).getAdListAsync(activity, new GetAdListListener() {
            @Override
            public void onLoadAdSuccess(final List<AdData> newList) {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        ListUtil.addAll(list, newList);
                        notifyDataSetChanged();
                    }
                });
            }

            @Override
            public void onLoadAdFailure() {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        notifyDataSetChanged();
                    }
                });
            }

            @Override
            public void onAdEmpty() {
                activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        notifyDataSetChanged();
                    }
                });

            }
        }, page, per_page);
    }
}
