package com.wisewoods.eduandroid.ui;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.wisewoods.base.bean.MettingInfo;
import com.wisewoods.base.net.JCallback;
import com.wisewoods.base.page.BaseListActivity;
import com.wisewoods.eduandroid.R;
import com.wisewoods.eduandroid.app.App;
import com.wisewoods.eduandroid.databinding.ActivityMettingHistoryBinding;
import com.wisewoods.eduandroid.ui.adapter.HistoryAdapter;

import retrofit2.Call;
import retrofit2.Response;

public class MettingHistoryActivity extends BaseListActivity<ActivityMettingHistoryBinding> {

    private HistoryAdapter mAdapter;

    @Override
    protected void initListData() {
        rv = binding.rvHistory;
        srf = binding.srf;

        showBarBack(binding.bar.tvTitle, "历史会议", binding.bar.ivBack);


        mAdapter = new HistoryAdapter();
        mAdapter.setOnItemChildClickListener((adapter, view, position) -> {
            if (view.getId() == R.id.tv_detail) {
                MettingDetailActivity.start(mAdapter.getItem(position));
            } else if (view.getId() == R.id.tv_record) {
                JzVideoActivity.start(mAdapter.getItem(position).recordingFiles);
            }
        });

    }

    @Override
    public BaseQuickAdapter getAdapter() {
        return mAdapter;
    }

    @Override
    protected void getData(long page, long size) {
        App.api.selectMeetingsEndList(page, size).enqueue(new JCallback<MettingInfo>() {
            @Override
            public void onS(Response<MettingInfo> response, MettingInfo mettingInfo) {
                getDataSuccess(mettingInfo.data.rows, mettingInfo.data.total);
            }

            @Override
            public void onFailure(Call<MettingInfo> call, Throwable t) {
                super.onFailure(call, t);
                getDataFail();
            }
        });
    }
}
