| | |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.widget.ImageView; |
| | | import android.widget.LinearLayout; |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.TextView; |
| | | |
| | |
| | | |
| | | import com.bumptech.glide.load.resource.bitmap.RoundedCorners; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.enums.PowerStationStatus; |
| | | import com.hdl.photovoltaic.enums.UnitType; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.ui.bean.HouseIdBean; |
| | |
| | | private List<HouseIdBean> mList; |
| | | private final Context mContext; |
| | | private OnclickListener noOnclickListener;//点击了的监听器 |
| | | |
| | | String mPowerStationStatus; |
| | | |
| | | /** |
| | | * 收集SwipeLayout数组,要一键全部打开; |
| | |
| | | HouseIdBean houseIdBean = this.mList.get(position); |
| | | holder.homeNameTv.setText(houseIdBean.getHomeName().trim()); |
| | | //装机容量 |
| | | String capacity = mContext.getString(R.string.my_power_station_installed_capacity) + houseIdBean.getInstalledCapacity() + HdlDeviceLogic.kW; |
| | | String capacity = HdlCommonLogic.getBigDecimal(houseIdBean.getInstalledCapacity()).toString(); |
| | | holder.capacityTv.setText(capacity); |
| | | String kw = "0"; |
| | | try { |
| | | if (houseIdBean.getPower().contains(".")) { |
| | | int indexOf = houseIdBean.getPower().indexOf("."); |
| | | houseIdBean.setPower(houseIdBean.getPower().substring(0, indexOf)); |
| | | } |
| | | int intValue = Integer.parseInt(houseIdBean.getPower()); |
| | | int k = intValue / 1000; |
| | | int w = intValue % 1000; |
| | | kw = k + "." + w; |
| | | } catch (Exception ignored) { |
| | | kw = "0.0"; |
| | | } |
| | | //发电功率 |
| | | String power = mContext.getString(R.string.power_station_generated_power) + kw + HdlDeviceLogic.kW; |
| | | holder.powerTv.setText(power); |
| | | holder.power_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getPower())); |
| | | holder.power_kw_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getPower(), UnitType.kW)); |
| | | //当日发电量 |
| | | holder.day_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getTodayElectricity())); |
| | | holder.day_kwh_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getTodayElectricity(), UnitType.kWh)); |
| | | //电池容量 |
| | | holder.month_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getBatteryCapacity())); |
| | | holder.month_kwh_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getBatteryCapacity(), UnitType.kWh)); |
| | | |
| | | holder.plant_details_location_tv.setText(houseIdBean.getHomeAddress()); |
| | | holder.item_parent_rl.setTag(position); |
| | | setTextViewStyle(holder.stateTv, houseIdBean.getPowerStationStatus()); |
| | | GlideUtils.getRoundedCornersImage(mContext, houseIdBean.getPowerStationImage(), holder.homeIconIv, new RoundedCorners(6), false); |
| | | |
| | | HdlLogLogic.print("--->电站名称:" + houseIdBean.getHomeName() + "--->图片url:" + houseIdBean.getPowerStationImage(), false); |
| | | GlideUtils.getRoundedCornersImage(mContext, houseIdBean.getPowerStationImage(), holder.homeIconIv, 6); |
| | | // HdlLogLogic.print("---电站名称:" + houseIdBean.getHomeName() + "---图片url:" + houseIdBean.getPowerStationImage(), false); |
| | | holder.item_parent_rl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | |
| | | } |
| | | }); |
| | | //移动电站位置 |
| | | holder.move_home_iv.setOnClickListener(new View.OnClickListener() { |
| | | holder.move_home_ll.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | try { |
| | |
| | | } |
| | | } |
| | | }); |
| | | holder.del_home_ll.setVisibility(View.GONE); |
| | | if (houseIdBean.getDeliverStatus().equals("UNDELIVERED")) { |
| | | //未交付完要显示删除按钮 |
| | | holder.del_home_ll.setVisibility(View.VISIBLE); |
| | | } |
| | | //删除电站 |
| | | holder.del_home_iv.setOnClickListener(new View.OnClickListener() { |
| | | holder.del_home_ll.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | try { |
| | |
| | | } |
| | | |
| | | |
| | | public void setList(List<HouseIdBean> newData) { |
| | | public void setList(List<HouseIdBean> newData, String powerStationStatus) { |
| | | mPowerStationStatus = powerStationStatus; |
| | | if (this.mList == null) { |
| | | this.mList = new ArrayList<>(); |
| | | } else { |
| | |
| | | * 设备在线 但是当前处于故障 状态:故障 |
| | | * 设备在线(有上报过数据,没有故障) 状态:在线 |
| | | * 设备离线 状态:离线 |
| | | * @param state_value 电站状态(1:正常(运行),2:离线,3:连接中,4:故障) |
| | | * @param state_value 电站状态(1:正常(运行),2:离线,3:连接中,4:故障,5:离线有故障) |
| | | */ |
| | | 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); |
| | | switch (state_value) { |
| | | case 1: { |
| | | text = mContext.getString(R.string.my_power_station_operation); |
| | | |
| | | String text = mContext.getString(R.string.my_power_station_operation); |
| | | Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ff38c494); |
| | | if (mPowerStationStatus.equals(PowerStationStatus.All)) { |
| | | switch (state_value) { |
| | | case 1: { |
| | | text = mContext.getString(R.string.my_power_station_operation); |
| | | } |
| | | break; |
| | | |
| | | case 2: { |
| | | text = mContext.getString(R.string.my_power_station_off_line); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); |
| | | } |
| | | break; |
| | | case 3: { |
| | | text = mContext.getString(R.string.my_power_station_connecting); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); |
| | | } |
| | | break; |
| | | case 4: |
| | | case 5: { |
| | | text = mContext.getString(R.string.my_power_station_malfunction); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); |
| | | } |
| | | //5:离线有故障Offline_fault |
| | | break; |
| | | // case 5: { |
| | | // text = mContext.getString(R.string.Offline_fault); |
| | | // drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); |
| | | // } |
| | | // break; |
| | | } |
| | | break; |
| | | case 2: { |
| | | text = mContext.getString(R.string.my_power_station_off_line); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9); |
| | | } |
| | | break; |
| | | case 3: { |
| | | text = mContext.getString(R.string.my_power_station_connecting); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300); |
| | | } |
| | | break; |
| | | case 4: { |
| | | text = mContext.getString(R.string.my_power_station_malfunction); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); |
| | | } |
| | | break; |
| | | } else if (mPowerStationStatus.equals(PowerStationStatus.malfunction)) { |
| | | text = mContext.getString(R.string.my_power_station_malfunction); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_fff55252); |
| | | } else if (mPowerStationStatus.equals(PowerStationStatus.off)) { |
| | | text = mContext.getString(R.string.my_power_station_off_line); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_state_ffb9b9b9); |
| | | } else if (mPowerStationStatus.equals(PowerStationStatus.connecting)) { |
| | | text = mContext.getString(R.string.my_power_station_connecting); |
| | | drawable = AppCompatResources.getDrawable(mContext, R.drawable.device_satte_ffb300); |
| | | } |
| | | textView.setText(text); |
| | | // textView.setText(text); |
| | | textView.setBackground(drawable); |
| | | |
| | | |
| | |
| | | public ImageView homeIconIv;//住宅图片 |
| | | public TextView homeNameTv;//住宅名称 |
| | | public TextView capacityTv;//装机容量 |
| | | public TextView powerTv;//发电功率 |
| | | public TextView power_value_tv;//发电功率 |
| | | public TextView power_kw_unit;//发电功率单位 |
| | | public TextView day_value_tv;//当日发电量 |
| | | public TextView day_kwh_unit;//当日发电量单位 |
| | | public TextView month_value_tv;//当月发电量 |
| | | public TextView month_kwh_unit;//当月发电量单位 |
| | | public TextView stateTv;//电站状态(连接中,运行,离线,故障); |
| | | public RelativeLayout item_parent_rl;//条目父容器 |
| | | public ImageView move_home_iv;//移动电站位置 |
| | | public ImageView del_home_iv;//删除电站 |
| | | public LinearLayout move_home_ll;//移动电站位置 |
| | | public LinearLayout del_home_ll;//删除电站 |
| | | public TextView plant_details_location_tv;//电站地址 |
| | | public SwipeLayout item_parent_swipeLayout;//父容器 |
| | | |
| | | public MyViewHolder(@NonNull View itemView) { |
| | | super(itemView); |
| | | homeIconIv = itemView.findViewById(R.id.device_details_image_iv); |
| | | homeNameTv = itemView.findViewById(R.id.device_details_name_tv); |
| | | capacityTv = itemView.findViewById(R.id.device_details_sn_tv); |
| | | powerTv = itemView.findViewById(R.id.power_type_tv); |
| | | stateTv = itemView.findViewById(R.id.fragment_house_list_line_state_tv); |
| | | capacityTv = itemView.findViewById(R.id.device_details_value_tv); |
| | | power_value_tv = itemView.findViewById(R.id.power_value_tv); |
| | | power_kw_unit = itemView.findViewById(R.id.power_kw_unit); |
| | | day_value_tv = itemView.findViewById(R.id.day_value_tv); |
| | | day_kwh_unit = itemView.findViewById(R.id.day_kwh_unit); |
| | | month_value_tv = itemView.findViewById(R.id.month_value_tv); |
| | | month_kwh_unit = itemView.findViewById(R.id.month_kwh_unit); |
| | | stateTv = itemView.findViewById(R.id.device_state_tv); |
| | | item_parent_rl = itemView.findViewById(R.id.item_parent_rl); |
| | | move_home_iv = itemView.findViewById(R.id.move_home_iv); |
| | | del_home_iv = itemView.findViewById(R.id.del_home_iv); |
| | | move_home_ll = itemView.findViewById(R.id.move_ll); |
| | | del_home_ll = itemView.findViewById(R.id.del_ll); |
| | | plant_details_location_tv = itemView.findViewById(R.id.plant_details_location_tv); |
| | | item_parent_swipeLayout = itemView.findViewById(R.id.item_parent_swipeLayout); |
| | | } |
| | | } |