package com.android.chmo.ui.activity.promote;


import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.android.chmo.R;
import com.android.chmo.base.BaseActivity;
import com.android.chmo.http.RequestCallback;
import com.android.chmo.http.response.PromoteRes;
import com.android.chmo.http.service.UserService;
import com.android.chmo.ui.adpater.PromoteAdapter;
import com.google.gson.Gson;

import butterknife.BindView;

public class PromoteDetailActivity extends BaseActivity {
    @BindView(R.id.recycler_view)
    RecyclerView recyclerView;
    private PromoteRes     promoteRes;
    private PromoteAdapter adapter;

    @Override
    protected int getContentResId() {
        return R.layout.activity_promote_detail;
    }

    @Override
    public void initView() {
        promoteRes = new PromoteRes();
        adapter = new PromoteAdapter(promoteRes, this);
        recyclerView.setLayoutManager(new LinearLayoutManager(this));
        recyclerView.setAdapter(adapter);
        getData();
    }

    void getData() {
        UserService.promoteList(new RequestCallback() {
            @Override
            public void onSuccess(String result) {
                promoteRes = new Gson().fromJson(result, PromoteRes.class);
                adapter.setData(promoteRes);
                adapter.notifyDataSetChanged();
            }

            @Override
            public void onFailure(String error) {
            }
        });
    }
}
