package com.example.iot_controlhost.adapter;

import com.example.iot_controlhost.base.BaseRecyclerAdapter;
import com.example.iot_controlhost.databinding.ItemWeatherBinding;
import com.example.iot_controlhost.model.net.Weather;

import java.util.List;

/**
 * 天气适配器
 * 用于查看天气
 *
 * @Author：DuanKaiji
 */
public class WeatherAdapter extends BaseRecyclerAdapter<Weather.DataDTO.CastsDTO, ItemWeatherBinding> {

    public WeatherAdapter(List<Weather.DataDTO.CastsDTO> dataList, Class<ItemWeatherBinding> bindingClass) {
        super(dataList, bindingClass);
    }

    @Override
    protected void bindData(ItemWeatherBinding binding, Weather.DataDTO.CastsDTO data) {
        binding.tvDate.setText(data.getDate());
        String day = data.getDayweather() + " " + data.getDaytemp() + "℃\n" + data.getDaypower() + " " + data.getDaywind() + " ";
        binding.tvDay.setText(day);
        String night = data.getNightweather() + " " + data.getNighttemp() + "℃\n" + data.getNightpower() + " " + data.getNightwind() + " ";
        binding.tvNight.setText(night);
    }
}
