package com.example.iot_controlhost.ui.dialog;

import android.content.Context;
import android.util.Pair;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.iot_controlhost.R;
import com.example.iot_controlhost.adapter.LogAdapter;
import com.example.iot_controlhost.adapter.MessageAdapter;
import com.example.iot_controlhost.base.BaseDialog;
import com.example.iot_controlhost.databinding.DialogLogBinding;
import com.example.iot_controlhost.databinding.DialogMessageBinding;
import com.example.iot_controlhost.databinding.ItemLogBinding;
import com.example.iot_controlhost.databinding.ItemMsgTitleBinding;
import com.example.iot_controlhost.model.Log;
import com.example.iot_controlhost.model.net.AirConditionList;
import com.example.iot_controlhost.ui.view.CustomSpinnerAdapter;
import com.example.iot_controlhost.utils.DialogUtil;
import com.example.iot_controlhost.utils.database.LogDBManager;
import com.example.iot_controlhost.utils.log.MyLog;
import com.example.iot_controlhost.utils.network.Url;
import com.example.iot_controlhost.utils.network.XHttpManager;
import com.example.iot_controlhost.utils.network.XHttpShorthand;
import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
import com.xuexiang.rxutil2.rxjava.task.RxAsyncTask;

import org.xutils.http.RequestParams;
import org.xutils.x;

import java.util.List;

/**
 * 弹窗
 */
public class MessageDialog extends BaseDialog<DialogMessageBinding> {

    List<Log> logs;
    MessageAdapter adapter;

    public MessageDialog(Context mContext) {
        super(mContext);
        adapter = new MessageAdapter(logs, ItemMsgTitleBinding.class,binding);
        binding.rvMsg.setAdapter(adapter);

        refreshData();

        binding.btnQuery.setOnClickListener(view -> {
            refreshData();
        });

    }

    private void refreshData() {
//        DialogUtil.showLoadingDialog(mContext, "正在加载最新消息，请稍等...");
//        RequestParams params = XHttpManager.getInstance().getRequestParams(Url.getAirConditionerModelList);
//        x.http().get(params, new XHttpShorthand<AirConditionList>() {
//            @Override
//            public void success(AirConditionList model) {
//
//            }
//
//            @Override
//            public void error(Throwable e) {
//                errorTips("无法获取消息列表");
//            }
//        });
    }

}
