From 2289b3b709eeb47599b4fbef3cfd2c345f436cac Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 27 十一月 2024 21:10:18 +0800
Subject: [PATCH] 2024年11月27日21:10:17

---
 app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java |  138 +++++++++++++++++++++++++---------------------
 1 files changed, 75 insertions(+), 63 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
index c056421..6fd51e8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
@@ -125,32 +125,32 @@
         });
 
         //鍏ㄩ儴
-        viewBinding.homeAllIl.parentLl.setOnClickListener(new View.OnClickListener() {
+        viewBinding.homeAllIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.All);
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.All);
 
             }
         });
         //鏁呴殰
-        viewBinding.homeFaultsIl.parentLl.setOnClickListener(new View.OnClickListener() {
+        viewBinding.homeFaultsIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.malfunction);
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.malfunction);
             }
         });
         //绂荤嚎
-        viewBinding.homeOfflineIl.parentLl.setOnClickListener(new View.OnClickListener() {
+        viewBinding.homeOfflineIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.off);
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.off);
             }
         });
         //寰呮帴鍏�
-        viewBinding.homeConnectedIl.parentLl.setOnClickListener(new View.OnClickListener() {
+        viewBinding.homeConnectedIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.connecting);
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.connecting);
             }
         });
         //鏃堕棿閫夋嫨鍣�
@@ -173,16 +173,16 @@
                 viewBinding.unitTv.setText(UnitType.kW);
                 viewBinding.unitTextTv.setText(getString(R.string.pv_power));
                 viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
-                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.v1.setVisibility(View.GONE);
                 viewBinding.v2.setVisibility(View.VISIBLE);
@@ -207,16 +207,16 @@
                 viewBinding.unitTv.setText(UnitType.kWh);
                 viewBinding.unitTextTv.setText(getString(R.string.generation));
                 viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.v1.setVisibility(View.GONE);
                 viewBinding.v2.setVisibility(View.GONE);
@@ -241,16 +241,16 @@
                 viewBinding.unitTv.setText(UnitType.kWh);
                 viewBinding.unitTextTv.setText(getString(R.string.generation));
                 viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.v1.setVisibility(View.VISIBLE);
                 viewBinding.v2.setVisibility(View.GONE);
@@ -273,16 +273,16 @@
                 viewBinding.unitTv.setText(UnitType.kWh);
                 viewBinding.unitTextTv.setText(getString(R.string.generation));
                 viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
 
                 viewBinding.v1.setVisibility(View.VISIBLE);
                 viewBinding.v2.setVisibility(View.VISIBLE);
@@ -417,36 +417,32 @@
 
     private void initView() {
 
-
-        viewBinding.homeAllIl.stationTitleTv.setText(getString(R.string.message_all));
-        viewBinding.homeFaultsIl.stationTitleTv.setText(getString(R.string.my_power_station_malfunction));
-        viewBinding.homeOfflineIl.stationTitleTv.setText(getString(R.string.my_power_station_off_line));
-        viewBinding.homeConnectedIl.stationTitleTv.setText(getString(R.string.to_be_added));
-
         String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType));
         viewBinding.yearMonthDayTv.setText(dataStr);
 
-        String installed_capacity = getString(R.string.string_capacity) + "(" + UnitType.kWp + ")";
-        viewBinding.infoRl1Text2Tv.setText(installed_capacity);
-        String generated_power = getString(R.string.generated_power) + "(" + UnitType.kW + ")";
-        viewBinding.infoRl1Text4Tv.setText(generated_power);
-        String generation = getString(R.string.generation) + "/" + UnitType.kWh;
-        viewBinding.homePageStationInfoRl1TitleTv.setText(generation);
+//        String installed_capacity = getString(R.string.string_capacity) + "(" + UnitType.kWp + ")";
+//        viewBinding.infoRl1Text2Tv.setText(installed_capacity);
+//        String generated_power = getString(R.string.generated_power) + "(" + UnitType.kW + ")";
+//        viewBinding.infoRl1Text4Tv.setText(generated_power);
+//        String generation = getString(R.string.generation) + "/" + UnitType.kWh;
+//        viewBinding.homePageStationInfoRl1TitleTv.setText(generation);
 
-        viewBinding.homePageStationInfoRl2DayIc.dataTypeTv.setText(R.string.day_power_generation);
-        viewBinding.homePageStationInfoRl2MonIc.dataTypeTv.setText(R.string.month_power_generation);
-        viewBinding.homePageStationInfoRl2YearIc.dataTypeTv.setText(R.string.year_power_generation);
-        viewBinding.homePageStationInfoRl2CumulativeIc.dataTypeTv.setText(R.string.cumulative_power_generation);
-
+//        viewBinding.day.setText(R.string.day_power_generation);
+//        viewBinding.month.setText(R.string.month_power_generation);
+//        viewBinding.year.setText(R.string.year_power_generation);
+//        viewBinding.Total.setText(R.string.cumulative_power_generation);
+//
         viewBinding.unitTv.setText(UnitType.kW);
+
+
         viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
-        viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
+        viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
         viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-        viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+        viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
         viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-        viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+        viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
         viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-        viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
+        viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
         viewBinding.v1.setVisibility(View.GONE);
         viewBinding.v2.setVisibility(View.VISIBLE);
         viewBinding.v3.setVisibility(View.VISIBLE);
@@ -493,10 +489,10 @@
                 if (statusOverviewBean == null) {
                     return;
                 }
-                viewBinding.homeAllIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
-                viewBinding.homeFaultsIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
-                viewBinding.homeOfflineIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
-                viewBinding.homeConnectedIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
+                viewBinding.stationAllTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
+                viewBinding.stationFaultsTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
+                viewBinding.stationOfflineTitleTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
+                viewBinding.stationConnectedTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
             }
 
             @Override
@@ -524,22 +520,38 @@
                         viewBinding.infoRl1Text1Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity()));
                         viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getPower(), UnitType.kW, false));
 
-                        String str = dataOverBean.getPowerRatio() + "%";
-                        int startIndex = str.lastIndexOf("%");
-                        int endIndex = str.lastIndexOf("%") + 1;
-                        SpannableString spannableString = new SpannableString(str);
-                        //璁剧疆绗竴閮ㄥ垎鏂囧瓧鐨勫瓧浣撳ぇ灏�
-                        spannableString.setSpan(new AbsoluteSizeSpan((int) UnitConversionUtils.dpToPx(HDLApp.getInstance(), 12)), startIndex, endIndex, 0);
-                        // 鍒涘缓涓�涓狥oregroundColorSpan瀵硅薄锛屽弬鏁版槸棰滆壊鍊�
-                        ForegroundColorSpan colorSpan = new ForegroundColorSpan(HDLApp.getInstance().getColor(R.color.text_191919));
-                        spannableString.setSpan(colorSpan, startIndex, endIndex, 0);
+//                        String str = dataOverBean.getPowerRatio() + "%";
+//                        int startIndex = str.lastIndexOf("%");
+//                        int endIndex = str.lastIndexOf("%") + 1;
+//                        SpannableString spannableString = new SpannableString(str);
+//                        //璁剧疆绗竴閮ㄥ垎鏂囧瓧鐨勫瓧浣撳ぇ灏�
+//                        spannableString.setSpan(new AbsoluteSizeSpan((int) UnitConversionUtils.dpToPx(HDLApp.getInstance(), 12)), startIndex, endIndex, 0);
+//                        // 鍒涘缓涓�涓狥oregroundColorSpan瀵硅薄锛屽弬鏁版槸棰滆壊鍊�
+//                        ForegroundColorSpan colorSpan = new ForegroundColorSpan(HDLApp.getInstance().getColor(R.color.text_66FFFFFF));
+//                        spannableString.setSpan(colorSpan, startIndex, endIndex, 0);
+//                        viewBinding.infoRl1FText1Tv.setText(spannableString);
+                        viewBinding.infoRl1FText1Tv.setText(dataOverBean.getPowerRatio());
+                        try {
+                            int progress = 0;
+                            if (!TextUtils.isEmpty(dataOverBean.getPowerRatio())) {
+                                progress = (int) Double.parseDouble(dataOverBean.getPowerRatio());
+                                if (progress > 100) {
+                                    progress = 100;
+                                }
+                                if (progress < 0) {
+                                    progress = 0;
+                                }
+                                viewBinding.progressBar.setProgress(progress);
+                            }
 
-                        viewBinding.infoRl1FText1Tv.setText(spannableString);
+                        } catch (Exception ignored) {
+                        }
 
-                        viewBinding.homePageStationInfoRl2DayIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTodayElectricity()));
-                        viewBinding.homePageStationInfoRl2MonIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getMonthElectricity()));
-                        viewBinding.homePageStationInfoRl2YearIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getYearElectricity()));
-                        viewBinding.homePageStationInfoRl2CumulativeIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTotalElectricity()));
+                        viewBinding.day.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTodayElectricity()));
+                        viewBinding.month.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getMonthElectricity()));
+                        viewBinding.year.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getYearElectricity()));
+                        viewBinding.Total.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTotalElectricity()));
+
                     }
                 });
             }

--
Gitblit v1.8.0