| | |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ImageView; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.enums.UnitType; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.ui.bean.DeviceBean; |
| | | import com.hdl.photovoltaic.widget.SwipeLayout; |
| | | import com.hdl.photovoltaic.ui.bean.CloudInverterDeviceBean; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class DeviceInfoAdapter extends RecyclerView.Adapter<DeviceInfoAdapter.MyViewHolder> { |
| | | |
| | | List<DeviceBean> mList; |
| | | List<CloudInverterDeviceBean> mList; |
| | | |
| | | Context mContext; |
| | | |
| | |
| | | |
| | | @Override |
| | | public void onBindViewHolder(@NonNull MyViewHolder holder, int position) { |
| | | DeviceBean deviceBean = this.mList.get(position); |
| | | CloudInverterDeviceBean deviceBean = this.mList.get(position); |
| | | |
| | | holder.homeNameTv.setText(deviceBean.getHomeNameAndDeviceName()); |
| | | holder.device_details_sn_tv.setText(deviceBean.getOsn()); |
| | | holder.device_label_run_state_value_tv.setText(deviceBean.getSystemStatusDesc()); |
| | | holder.device_label_power_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(deviceBean.getPowerPvNow(), UnitType.kW)); |
| | | holder.device_label_day_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(deviceBean.getPowerPvNow(), UnitType.kWh)); |
| | | holder.device_label_power_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(deviceBean.getOutputActivePower(), UnitType.kW, false)); |
| | | holder.device_label_day_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(deviceBean.getTotalElectricityPvToday(), UnitType.kWh, false)); |
| | | holder.device_label_location_tv.setText(deviceBean.getHomeAddress()); |
| | | setTextViewStyle(holder.device_label_state_tv, deviceBean.getDeviceStatus()); |
| | | holder.itemView.setTag(position); |
| | |
| | | this.mOnclickListener = onClickListener; |
| | | } |
| | | |
| | | public void setList(List<DeviceBean> newData) { |
| | | public void setList(List<CloudInverterDeviceBean> newData) { |
| | | if (this.mList == null) { |
| | | this.mList = new ArrayList<>(); |
| | | } else { |
| | |
| | | */ |
| | | private void setTextViewStyle(TextView textView, int state_value) { |
| | | String text = mContext.getString(R.string.my_power_station_operation); |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_06b92a); |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ff38c494); |
| | | switch (state_value) { |
| | | case 1: { |
| | | text = mContext.getString(R.string.my_power_station_connecting); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); |
| | | } |
| | | break; |
| | | case 2: { |
| | | text = mContext.getString(R.string.my_power_station_malfunction); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); |
| | | } |
| | | break; |
| | | case 3: { |
| | |
| | | break; |
| | | case 4: { |
| | | text = mContext.getString(R.string.my_power_station_off_line); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); |
| | | } |
| | | break; |
| | | |
| | | |
| | | } |
| | | textView.setText(text); |
| | | // textView.setText(text); |
| | | textView.setBackground(drawable); |
| | | |
| | | |
| | |
| | | super(itemView); |
| | | device_icon_iv = itemView.findViewById(R.id.device_details_image_iv); |
| | | homeNameTv = itemView.findViewById(R.id.device_details_name_tv); |
| | | device_details_sn_tv = itemView.findViewById(R.id.device_details_sn_tv); |
| | | device_details_sn_tv = itemView.findViewById(R.id.device_details_value_tv); |
| | | device_label_run_state_value_tv = itemView.findViewById(R.id.device_label_run_state_value_tv); |
| | | device_label_power_value_tv = itemView.findViewById(R.id.device_label_power_value_tv); |
| | | device_label_day_value_tv = itemView.findViewById(R.id.device_label_day_value_tv); |
| | | device_label_location_tv = itemView.findViewById(R.id.device_label_location_tv); |
| | | |
| | | device_label_state_tv = itemView.findViewById(R.id.device_label_state_tv); |
| | | device_label_state_tv = itemView.findViewById(R.id.device_state_tv); |
| | | |
| | | } |
| | | } |
| | | |
| | | public interface OnClickListener { |
| | | void onClick(int position, DeviceBean deviceBean); |
| | | void onClick(int position, CloudInverterDeviceBean deviceBean); |
| | | |
| | | } |
| | | } |