From 2b805d413e924bc0a8e80e1280208d9af8d93cb1 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期四, 30 五月 2024 21:12:07 +0800 Subject: [PATCH] 2024年05月30日21:11:54 --- app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java | 102 ++++++++++++++++++++++++++++++--------------------- 1 files changed, 60 insertions(+), 42 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java index b1f0c52..37bfc80 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java @@ -15,6 +15,9 @@ 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; @@ -30,6 +33,8 @@ private List<HouseIdBean> mList; private final Context mContext; private OnclickListener noOnclickListener;//鐐瑰嚮浜嗙殑鐩戝惉鍣� + + String mPowerStationStatus; /** * 鏀堕泦SwipeLayout鏁扮粍,瑕佷竴閿叏閮ㄦ墦寮�; @@ -55,29 +60,19 @@ 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 = mContext.getString(R.string.my_power_station_installed_capacity) + ":" + HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getInstalledCapacity(), UnitType.kWp); 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.getConvertDoubleUnit(houseIdBean.getPower(), UnitType.kW)); + //褰撴棩鍙戠數閲� + holder.day_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getTodayElectricity(), UnitType.kWh)); + //褰撴湀鍙戠數閲� + holder.month_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getMonthElectricity(), 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, new RoundedCorners(12), false); + HdlLogLogic.print("---鐢电珯鍚嶇О:" + houseIdBean.getHomeName() + "---鍥剧墖url:" + houseIdBean.getPowerStationImage(), false); holder.item_parent_rl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -122,7 +117,8 @@ } - 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 { @@ -153,32 +149,48 @@ * 璁惧鍦ㄧ嚎 浣嗘槸褰撳墠澶勪簬鏁呴殰 鐘舵�侊細鏁呴殰 * 璁惧鍦ㄧ嚎锛堟湁涓婃姤杩囨暟鎹紝娌℃湁鏁呴殰锛� 鐘舵�侊細鍦ㄧ嚎 * 璁惧绂荤嚎 鐘舵�侊細绂荤嚎 - * @param state_value 鐢电珯鐘舵��(1:姝e父(杩愯),2:绂荤嚎,3:杩炴帴涓�,4:鏁呴殰) + * @param state_value 鐢电珯鐘舵��(1:姝e父(杩愯),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); + 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.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: + case 5: { + text = mContext.getString(R.string.my_power_station_malfunction); + drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343); + } + //5:绂荤嚎鏈夋晠闅淥ffline_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.state_e34343); + } else if (mPowerStationStatus.equals(PowerStationStatus.off)) { + text = mContext.getString(R.string.my_power_station_off_line); + drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9); } textView.setText(text); textView.setBackground(drawable); @@ -194,11 +206,14 @@ public ImageView homeIconIv;//浣忓畢鍥剧墖 public TextView homeNameTv;//浣忓畢鍚嶇О public TextView capacityTv;//瑁呮満瀹归噺 - public TextView powerTv;//鍙戠數鍔熺巼 + public TextView power_value_tv;//鍙戠數鍔熺巼 + public TextView day_value_tv;//褰撴棩鍙戠數閲� + public TextView month_value_tv;//褰撴湀鍙戠數閲� public TextView stateTv;//鐢电珯鐘舵��(杩炴帴涓�,杩愯,绂荤嚎,鏁呴殰); public RelativeLayout item_parent_rl;//鏉$洰鐖跺鍣� public ImageView move_home_iv;//绉诲姩鐢电珯浣嶇疆 public ImageView del_home_iv;//鍒犻櫎鐢电珯 + public TextView plant_details_location_tv;//鐢电珯鍦板潃 public SwipeLayout item_parent_swipeLayout;//鐖跺鍣� public MyViewHolder(@NonNull View itemView) { @@ -206,11 +221,14 @@ 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); + power_value_tv = itemView.findViewById(R.id.power_value_tv); + day_value_tv = itemView.findViewById(R.id.day_value_tv); + month_value_tv = itemView.findViewById(R.id.month_value_tv); stateTv = itemView.findViewById(R.id.fragment_house_list_line_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); + plant_details_location_tv = itemView.findViewById(R.id.plant_details_location_tv); item_parent_swipeLayout = itemView.findViewById(R.id.item_parent_swipeLayout); } } -- Gitblit v1.8.0