app/src/main/java/com/hdl/photovoltaic/other/HdlCommonLogic.java
@@ -74,70 +74,16 @@ return sHdlCommonLogic; } public static String getConvertDoubleUnit(String value) { if (TextUtils.isEmpty(value)) { return UnitType.noValue; } BigDecimal formattedValue = getBigDecimal(value); return formattedValue.toString(); } public static String getConvertDoubleUnit(int value) { if (value == 0) { return UnitType.noValue; } BigDecimal formattedValue = getBigDecimal(value + ""); return formattedValue.toString(); } /** * @param value 值 * @param unit 例如:UnitType.kWh * @return 带单位值返回 * @return 字符串值返回 */ public static String getConvertDoubleUnit(String value, String unit) { public static String convertDoubleValue(String value) { if (TextUtils.isEmpty(value)) { return UnitType.noValue + unit; return UnitType.noValue; } if (unit.equals(UnitType.kW) || unit.equals(UnitType.kWh)) { return divideByOneThousandAndFormat(value).toString() + unit; } return getBigDecimal(value).toString() + unit; } /** * @param value 值 * @param unitValue 例如:UnitType.kWh * @param isUnit true表示有单位返回 * @return 带单位值返回 */ public static String getConvertDoubleUnit(String value, String unitValue, boolean isUnit) { if (TextUtils.isEmpty(value)) { return UnitType.noValue + (isUnit ? unitValue : ""); } if (unitValue.equals(UnitType.kW)) { return divideByOneThousandAndFormat(value).toString() + (isUnit ? unitValue : ""); } return getBigDecimal(value).toString() + (isUnit ? unitValue : ""); } /** * @param value 值 * @param unit 例如:UnitType.kWh * @return 带单位值返回 */ public static String getConvertDoubleUnit(int value, String unit) { if (value == 0) { return UnitType.noValue + unit; } BigDecimal formattedValue = getBigDecimal(value + ""); return formattedValue.toString() + unit; return divideByOneThousandAndFormat(value).toString(); } @@ -155,6 +101,21 @@ } /** * @param value 值 * @param diploidValue 倍数 * @return 字符串 */ public static String convertDoubleValue(String value, int diploidValue) { try { double doubleValue = Double.parseDouble(value); BigDecimal bigDecimal = new BigDecimal(doubleValue); return bigDecimal.divide(new BigDecimal(diploidValue), 2, RoundingMode.HALF_EVEN).toString(); } catch (Exception e) { return "0.00"; } } /** * 除以一千和格式 * * @param value 值 @@ -163,16 +124,13 @@ public static BigDecimal divideByOneThousandAndFormat(String value) { try { double doubleValue = Double.parseDouble(value); int val = 1000; if (doubleValue > 1000 && doubleValue < 1000 * 1000) { val = 1000; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { val = 1000 * 1000; } else if (doubleValue > 1000 * 1000 * 1000) { val = 1000 * 1000 * 1000; int mDoubleValue = doubleValue(value); if (mDoubleValue == 0) { return getBigDecimal(value); } else { BigDecimal bigDecimal = new BigDecimal(doubleValue); return bigDecimal.divide(new BigDecimal(mDoubleValue), 2, RoundingMode.HALF_EVEN); } BigDecimal bigDecimal = new BigDecimal(doubleValue); return bigDecimal.divide(new BigDecimal(val), 2, RoundingMode.HALF_EVEN); } catch (Exception e) { BigDecimal bigDecimal = new BigDecimal(0); return bigDecimal.divide(new BigDecimal(1000), 2, RoundingMode.HALF_EVEN); @@ -184,17 +142,46 @@ * * @param value 值 */ public static int val(String value) { double doubleValue = Double.parseDouble(value); int val = 1000; if (doubleValue > 1000 && doubleValue < 1000 * 1000) { val = 1000; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { val = 1000 * 1000; } else if (doubleValue > 1000 * 1000 * 1000) { val = 1000 * 1000 * 1000; public static int doubleValue(String value) { try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { return 1000; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return 1000 * 1000; } else if (doubleValue > 1000 * 1000 * 1000) { return 1000 * 1000 * 1000; } else { return 0; } } catch (Exception e) { return 0; } return val; } /** * 转换单位 * * @param value 值 * @param unitType 表示是单位(功率,电量) */ public static String convertUnit(String value, String unitType) { try { double doubleValue = Double.parseDouble(value); if (doubleValue > 1000 && doubleValue < 1000 * 1000) { return unitType.equals(UnitType.kW) ? UnitType.mW : UnitType.mWh; } else if (doubleValue > 1000 * 1000 && doubleValue < 1000 * 1000 * 1000) { return unitType.equals(UnitType.kW) ? UnitType.gW : UnitType.gWh; } else if (doubleValue > 1000 * 1000 * 1000) { return unitType.equals(UnitType.kW) ? UnitType.tW : UnitType.tWh; } else { return unitType.equals(UnitType.kW) ? UnitType.kW : UnitType.kWh; } } catch (Exception e) { return unitType.equals(UnitType.kW) ? UnitType.kW : UnitType.kWh; } } /** app/src/main/java/com/hdl/photovoltaic/ui/adapter/DeviceInfoAdapter.java
@@ -47,8 +47,10 @@ 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.getOutputActivePower(), UnitType.kW, false)); holder.device_label_day_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(deviceBean.getTotalElectricityPvToday(), UnitType.kWh, false)); holder.device_label_power_value_tv.setText(HdlCommonLogic.convertDoubleValue(deviceBean.getOutputActivePower(), 1000)); holder.device_label_power_unit.setText(HdlCommonLogic.convertUnit(deviceBean.getOutputActivePower(), UnitType.kW)); holder.device_label_day_value_tv.setText(HdlCommonLogic.convertDoubleValue(deviceBean.getTotalElectricityPvToday())); holder.device_label_day_unit.setText(HdlCommonLogic.convertUnit(deviceBean.getOutputActivePower(), UnitType.kWh)); holder.device_label_location_tv.setText(deviceBean.getHomeAddress()); setTextViewStyle(holder.device_label_state_tv, deviceBean.getDeviceStatus()); holder.itemView.setTag(position); @@ -134,7 +136,9 @@ public TextView device_details_sn_tv;//mac public TextView device_label_run_state_value_tv;//设备运行状态 public TextView device_label_power_value_tv;//有功功率 public TextView device_label_power_unit;//有功功率单位 public TextView device_label_day_value_tv;//当日发电量 public TextView device_label_day_unit;//当日发电量单位 public TextView device_label_location_tv;//电站地址 public TextView device_label_state_tv;//设备状态(1:连接中,2:故障,3:正常(运行),4:离线) @@ -146,7 +150,9 @@ 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_power_unit = itemView.findViewById(R.id.device_label_power_unit); device_label_day_value_tv = itemView.findViewById(R.id.device_label_day_value_tv); device_label_day_unit = itemView.findViewById(R.id.device_label_day_unit); device_label_location_tv = itemView.findViewById(R.id.device_label_location_tv); device_label_state_tv = itemView.findViewById(R.id.device_state_tv); app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -61,14 +61,18 @@ HouseIdBean houseIdBean = this.mList.get(position); holder.homeNameTv.setText(houseIdBean.getHomeName().trim()); //装机容量 String capacity = HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getInstalledCapacity(), UnitType.kWp, false); String capacity = HdlCommonLogic.getBigDecimal(houseIdBean.getInstalledCapacity()).toString(); holder.capacityTv.setText(capacity); //发电功率 holder.power_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getPower(), UnitType.kW, false)); 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.getConvertDoubleUnit(houseIdBean.getTodayElectricity(), UnitType.kWh, false)); 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.getConvertDoubleUnit(houseIdBean.getMonthElectricity(), UnitType.kWh, false)); holder.month_value_tv.setText(HdlCommonLogic.convertDoubleValue(houseIdBean.getMonthElectricity())); holder.month_kwh_unit.setText(HdlCommonLogic.convertUnit(houseIdBean.getMonthElectricity(), UnitType.kWh)); holder.plant_details_location_tv.setText(houseIdBean.getHomeAddress()); holder.item_parent_rl.setTag(position); setTextViewStyle(holder.stateTv, houseIdBean.getPowerStationStatus()); @@ -216,8 +220,11 @@ public TextView homeNameTv;//住宅名称 public TextView capacityTv;//装机容量 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 LinearLayout move_home_ll;//移动电站位置 @@ -231,8 +238,11 @@ homeNameTv = itemView.findViewById(R.id.device_details_name_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_ll = itemView.findViewById(R.id.move_ll); app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
@@ -513,8 +513,9 @@ if (dataOverBean == null) { return; } viewBinding.infoRl1Text1Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity())); viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getPower(), UnitType.kW, false)); String capacityValue = HdlCommonLogic.getBigDecimal(dataOverBean.getInstalledCapacity()).toString(); viewBinding.infoRl1Text1Tv.setText(capacityValue); viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getPower())); // String str = dataOverBean.getPowerRatio() + "%"; // int startIndex = str.lastIndexOf("%"); @@ -543,10 +544,14 @@ } catch (Exception ignored) { } viewBinding.day.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTodayElectricity())); viewBinding.month.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getMonthElectricity())); viewBinding.year.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getYearElectricity(), UnitType.kW)); viewBinding.Total.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTotalElectricity(), UnitType.kW)); viewBinding.day.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTodayElectricity())); viewBinding.dayUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getTodayElectricity(), UnitType.kWh)); viewBinding.month.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getMonthElectricity())); viewBinding.monthUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getMonthElectricity(), UnitType.kWh)); viewBinding.year.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getYearElectricity())); viewBinding.yearUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getYearElectricity(), UnitType.kWh)); viewBinding.Total.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTotalElectricity())); viewBinding.TotalUnit.setText(HdlCommonLogic.convertUnit(dataOverBean.getTotalElectricity(), UnitType.kWh)); } }); app/src/main/java/com/hdl/photovoltaic/ui/me/BindMailActivity.java
@@ -15,6 +15,7 @@ import com.hdl.photovoltaic.databinding.ActivityBindMailBinding; import com.hdl.photovoltaic.listener.CloudCallBeak; import com.hdl.photovoltaic.other.HdlAccountLogic; import com.hdl.photovoltaic.other.HdlCommonLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; @@ -99,6 +100,7 @@ viewBinding.toolbarTopRl.topTitleTv.setText(R.string.set_change_bind_mail); viewBinding.toolbarTopRl.topBackLl.setVisibility(View.VISIBLE); checkClearIconShowOrNot(viewBinding.bindMailEt.getText().toString()); HdlCommonLogic.getInstance().setSpan(viewBinding.bindMailVerificationTv, viewBinding.bindMailVerificationTv.getText().toString(), true, null); } /** app/src/main/java/com/hdl/photovoltaic/ui/me/BindPhoneActivity.java
@@ -15,6 +15,7 @@ import com.hdl.photovoltaic.databinding.ActivityBindPhoneBinding; import com.hdl.photovoltaic.listener.CloudCallBeak; import com.hdl.photovoltaic.other.HdlAccountLogic; import com.hdl.photovoltaic.other.HdlCommonLogic; import com.hdl.photovoltaic.other.HdlLogLogic; import com.hdl.photovoltaic.other.HdlThreadLogic; import com.sahooz.library.countrypicker.Country; @@ -108,12 +109,14 @@ private void initView() { viewBinding.toolbarTopRl.topTitleTv.setText(R.string.set_change_bind_phone_number); viewBinding.toolbarTopRl.topBackLl.setVisibility(View.VISIBLE); checkClearIconShowOrNot(viewBinding.bindPhoneEt.getText().toString()); try { Country.load(this); } catch (Exception e) { e.printStackTrace(); } HdlCommonLogic.getInstance().setSpan(viewBinding.bindPhoneVerificationTv, viewBinding.bindPhoneVerificationTv.getText().toString(), true, null); } /** app/src/main/res/layout/dialog_flashing_box.xml
@@ -8,8 +8,8 @@ android:id="@+id/tip_parent_cl" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginStart="@dimen/dp_128" android:layout_marginEnd="@dimen/dp_128" android:layout_marginStart="@dimen/dp_100" android:layout_marginEnd="@dimen/dp_100" android:background="@drawable/dialog_flashing_box" android:gravity="center" android:paddingTop="@dimen/dp_16" app/src/main/res/layout/fragment_home_page.xml
@@ -564,7 +564,8 @@ android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/day" /> android:text="@string/day" android:textStyle="bold" /> <View android:id="@+id/v_1" @@ -579,7 +580,8 @@ android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/month" /> android:text="@string/month" android:textStyle="bold" /> <View android:id="@+id/v_2" @@ -594,7 +596,8 @@ android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/year" /> android:text="@string/year" android:textStyle="bold" /> <View android:id="@+id/v_3" @@ -609,7 +612,8 @@ android:layout_height="match_parent" android:layout_weight="1" android:gravity="center" android:text="@string/life_cycle" /> android:text="@string/life_cycle" android:textStyle="bold" /> </LinearLayout> <!--时间切换控件--> app/src/main/res/layout/item_device_details.xml
@@ -162,7 +162,7 @@ android:textSize="@dimen/text_14" /> <TextView android:id="@+id/day_kwp_unit" android:id="@+id/device_label_power_unit" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginStart="3dp" @@ -217,7 +217,7 @@ android:textSize="@dimen/text_14" /> <TextView android:id="@+id/month_kwp_unit" android:id="@+id/device_label_day_unit" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginStart="3dp" app/src/main/res/layout/item_plant_details.xml
@@ -128,7 +128,7 @@ android:textSize="@dimen/text_14" /> <TextView android:id="@+id/power_kwp_unit" android:id="@+id/power_kw_unit" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginStart="3dp" @@ -186,12 +186,12 @@ <TextView android:id="@+id/day_kwp_unit" android:id="@+id/day_kwh_unit" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginStart="3dp" android:gravity="bottom" android:text="kW" android:text="kWh" android:textColor="@color/text_66FFFFFF" android:textSize="@dimen/text_10" /> </LinearLayout> @@ -242,12 +242,12 @@ android:textSize="@dimen/text_14" /> <TextView android:id="@+id/month_kwp_unit" android:id="@+id/month_kwh_unit" android:layout_width="wrap_content" android:layout_height="match_parent" android:layout_marginStart="3dp" android:gravity="bottom" android:text="kW" android:text="kWh" android:textColor="@color/text_66FFFFFF" android:textSize="@dimen/text_10" /> </LinearLayout> app/src/main/res/values-en/strings.xml
@@ -19,7 +19,7 @@ <string name="home_login_input_phone"> Enter your mobile number</string> <string name="home_login_email_address">Email address</string> <string name="home_login_input_psw"> Enter password</string> <string name="home_login_register"> Register</string> <string name="home_login_register"> Sign up</string> <string name="home_login_forget_password">Forget password</string> <string name="home_login_change_password">Change password</string> <string name="home_login_logoin">Log in</string> @@ -32,9 +32,9 @@ <string name="home_login_error_6_16_str"> Does not meet minimum security requirements, must be 6-16 characters.</string> <string name="home_login_error_password_6"> Cannot be less than 6 characters.</string> <string name="home_login_error_password_16"> Cannot be more than 16 characters.</string> <string name="home_login_input_6_16"> Enter a 6-16 character password</string> <string name="home_login_confirm_psw"> Confirm your password again</string> <string name="home_login_phone">Phone number</string> <string name="home_login_input_6_16"> Enter a 6—16 digit password</string> <string name="home_login_confirm_psw"> Confirm password again</string> <string name="home_login_phone">Phone</string> <string name="home_login_email">Email</string> <string name="home_login_input_mail"> Enter your email address</string> <string name="home_login_national_region"> Select country/region</string> @@ -63,7 +63,7 @@ <string name="home_login_change_name_succeed">successfully updated</string> <string name="verification">Verification code</string> <string name="home_phone_number">Country code</string> <string name="home_chinese_mainland">Mainland china</string> <string name="home_chinese_mainland">China</string> <string name="home_password_changed_successfully_log_in">The password has been successfully changed. Please log in again.</string> <string name="home_old_password_not_new_password">The original password and the new password should not be identical.</string> <string name="home_account_registered_successfully">Registered successfully.</string> @@ -110,7 +110,7 @@ <!--我的--> <string name="me">Me</string> <string name="me_set">Settings</string> <string name="me_set">Setting</string> <string name="me_regard">About</string> <string name="set_account">Account security</string> <string name="set_nickname">Nickname</string> @@ -127,12 +127,12 @@ <string name="set_temperature_unit">Temperature unit</string> <string name="set_logout">Log out</string> <string name="set_privacy">Privacy settings</string> <string name="set_nickname_modification">Nickname modification</string> <string name="set_nickname_modification">Modify username</string> <string name="set_user_management">User management</string> <string name="set_message_center">Message center</string> <string name="me_personal_data">Personal information</string> <string name="me_personal_data_portrait">profile photo</string> <string name="me_personal_data_user_name">Username</string> <string name="me_personal_data_portrait">Profile photo</string> <string name="me_personal_data_user_name">User name</string> <string name="me_personal_data_role">Role</string> <string name="me_personal_data_super_admin">Super administrator</string> <string name="me_personal_data_photograph">Take a photo</string> @@ -184,7 +184,7 @@ <string name="loading_not_supported">Sorry, not supported yet</string> <string name="loading_title_tip">Prompt</string> <string name="loading_app_restart">Confirm to restart the App</string> <string name="loading_log_out">Confirm logout?</string> <string name="loading_log_out">Confirm log out?</string> <!-- 权限 --> @@ -229,17 +229,17 @@ <string name="alarm_all_device_inverter">Inverter</string> <string name="alarm_all_device_bms">BMS control box</string> <string name="alarm_all_device_battery_cell">Battery unit</string> <string name="alarm_all_device_load_centre">Smart load centre</string> <string name="alarm_all_device_load_centre">Smart load center</string> <string name="alarm_all_grade">All grades</string> <string name="alarm_all_grade_malfunction">malfunction</string> <string name="alarm_all_grade_malfunction">Fault</string> <string name="alarm_all_grade_warning">warning</string> <string name="alarm_all_grade_tip">hint</string> <string name="alarm_all_grade_tip">Prompt</string> <string name="alarm_all_time">All time</string> <string name="alarm_all_time_same_day">Today</string> <string name="alarm_all_time_3">Last 3 Days</string> <string name="alarm_all_time_7">Last 7 Days</string> <string name="alarm_all_time_30">Last 30 Days</string> <string name="alarm_device">Equipment alarm</string> <string name="alarm_device">Equipment warning</string> <string name="alarm_record">Alarm record</string> <string name="power_station_editing">Power station editing</string> <string name="switch_power_station">Do you want to switch the %s power station?</string> @@ -309,12 +309,12 @@ <string name="number"></string> <string name="device_off">Device Offline!</string> <string name="summarize">Summary</string> <string name="qr_code_business_card">QR Code</string> <string name="qr_code_business_card">QR code</string> <string name="save_qr_code_successfully">Succeed to save QC code</string> <string name="failed_to_save_qr_code">failed to save QC code</string> <string name="staff_management">Staff account management</string> <string name="alarm">alarm</string> <string name="add_power_station">Additional power station</string> <string name="add_power_station">Add power station</string> <string name="add_power_station_failing">Adding power station failed</string> <string name="add_power_station_succeed">Adding the power station succeeded</string>