package com.example.iot_controlhost.ui.dialog;

import android.content.Context;

import androidx.recyclerview.widget.LinearLayoutManager;

import com.example.iot_controlhost.adapter.WeatherAdapter;
import com.example.iot_controlhost.base.BaseDialog;
import com.example.iot_controlhost.databinding.DialogWeatherBinding;
import com.example.iot_controlhost.databinding.ItemWeatherBinding;
import com.example.iot_controlhost.model.net.Weather;
import com.example.iot_controlhost.utils.DialogUtil;
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 org.xutils.http.RequestParams;
import org.xutils.x;

/**
 * 天气弹窗
 */
public class WeatherDialog extends BaseDialog<DialogWeatherBinding> {

    public WeatherDialog(Context mContext, Weather infos) {
        super(mContext);
        WeatherAdapter adapter = new WeatherAdapter(infos.getData().getCasts(), ItemWeatherBinding.class);
        //初始化界面控件
        binding.rvWeather.setLayoutManager(new LinearLayoutManager(mContext));
        binding.rvWeather.setAdapter(adapter);
        binding.tvAddress.setText(infos.getData().getProvince() + "-" + infos.getData().getCity());

        Weather.DataDTO.CastsDTO today = infos.getData().getCasts().get(0);
        binding.tvDetails.setText(today.getDayweather() + "\t" + today.getDaytemp() + "℃\n"
                + today.getDaypower() + " " + today.getDaywind() + " ");
        binding.tvUpdateTime.setText("更新时间：" + infos.getData().getReporttime());
    }

}
