From 5dfed3cf524a2bcacc19643c9af6d9fedc182420 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 06 八月 2024 09:03:12 +0800
Subject: [PATCH] 2024年08月06日09:03:10

---
 app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java |   63 ++++++++++++++++++++++++-------
 1 files changed, 48 insertions(+), 15 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 bc40105..c056421 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
@@ -4,10 +4,18 @@
 import static com.hdl.photovoltaic.ui.home.aachart.CustomStyleChartComposer.configureColorfulColumnChart;
 
 import android.os.Bundle;
+import android.os.SystemClock;
+import android.text.SpannableString;
+import android.text.Spanned;
 import android.text.TextUtils;
+import android.text.style.AbsoluteSizeSpan;
+import android.text.style.ClickableSpan;
+import android.text.style.ForegroundColorSpan;
+import android.text.style.StyleSpan;
 import android.view.View;
 
 
+import androidx.annotation.NonNull;
 import androidx.appcompat.content.res.AppCompatResources;
 import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 
@@ -18,10 +26,10 @@
 import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView;
 import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.HDLApp;
 import com.hdl.photovoltaic.R;
 import com.hdl.photovoltaic.base.CustomBaseFragment;
 import com.hdl.photovoltaic.config.ConstantManage;
-import com.hdl.photovoltaic.config.UserConfigManage;
 import com.hdl.photovoltaic.databinding.FragmentHomePageBinding;
 import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
 import com.hdl.photovoltaic.enums.PowerStationStatus;
@@ -42,6 +50,7 @@
 import com.hdl.photovoltaic.ui.home.aachart.BasicChartComposer;
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.utils.TimeUtils;
+import com.hdl.photovoltaic.utils.UnitConversionUtils;
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
 
 import org.greenrobot.eventbus.EventBus;
@@ -81,7 +90,6 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-
         //鍒濆鍖�
         initView();
         //鍒濆鍖栫晫闈㈢洃鍚櫒
@@ -120,7 +128,7 @@
         viewBinding.homeAllIl.parentLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.All);
 
             }
         });
@@ -128,18 +136,21 @@
         viewBinding.homeFaultsIl.parentLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.malfunction);
             }
         });
         //绂荤嚎
         viewBinding.homeOfflineIl.parentLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.off);
             }
         });
         //寰呮帴鍏�
         viewBinding.homeConnectedIl.parentLl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
+                HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.connecting);
             }
         });
         //鏃堕棿閫夋嫨鍣�
@@ -159,7 +170,8 @@
                     return;
                 }
                 timeType = TimeType.day;
-
+                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));
 
@@ -192,6 +204,8 @@
                     return;
                 }
                 timeType = TimeType.month;
+                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));
 
@@ -224,6 +238,8 @@
                     return;
                 }
                 timeType = TimeType.year;
+                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));
 
@@ -254,6 +270,8 @@
                     return;
                 }
                 timeType = TimeType.all;
+                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));
 
@@ -285,6 +303,7 @@
                 String timeDateFormat = TimeUtils.getTimeDateFormat(timeType);
                 Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat);
                 String time = TimeUtils.subtractDayMonthYearFromDate(calendar, 1, timeDateFormat, timeType);
+                //涓嶉渶瑕侀檺鍒舵渶灏忔棩鏈燂紝鍥犱负鏄煡璇㈣处鍙蜂笅鎵�鏈夌數绔欙紝鏃犳硶鐭ラ亾鏈�灏忓缓绔欐棩鏈�
                 viewBinding.yearMonthDayTv.setText(time);
                 getStatistics();
 
@@ -327,6 +346,7 @@
      * 鏃堕棿閫夋嫨鍣�
      */
     private void selectedTimePickerBuilder() {
+
         String currDate = viewBinding.yearMonthDayTv.getText().toString();
         //鏃堕棿閫夋嫨鍣�
         Calendar selectedDate = TimeUtils.stringToCalendar(currDate, TimeUtils.getTimeDateFormat(timeType));
@@ -388,10 +408,8 @@
         aaChartView.callBack = this;
         if (TimeType.day.equals(timeType)) {
             aaChartModel = BasicChartComposer.configureAreaChart(getString(R.string.pv_power), fieldNames, fieldValues);
-        } else if (TimeType.month.equals(timeType)
-                || TimeType.year.equals(timeType)
-                || TimeType.all.equals(timeType)) {
-            aaChartModel = configureColorfulColumnChart(getString(R.string.pv_power), fieldNames, fieldValues);
+        } else if (TimeType.month.equals(timeType) || TimeType.year.equals(timeType) || TimeType.all.equals(timeType)) {
+            aaChartModel = configureColorfulColumnChart(getString(R.string.generation), fieldNames, fieldValues);
         }
         aaChartView.aa_drawChartWithChartModel(aaChartModel);
 
@@ -408,11 +426,11 @@
         String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType));
         viewBinding.yearMonthDayTv.setText(dataStr);
 
-        String installed_capacity = getString(R.string.installed_capacity) + "(" + UnitType.kWp + ")";
+        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 + ")";
+        String generation = getString(R.string.generation) + "/" + UnitType.kWh;
         viewBinding.homePageStationInfoRl1TitleTv.setText(generation);
 
         viewBinding.homePageStationInfoRl2DayIc.dataTypeTv.setText(R.string.day_power_generation);
@@ -460,10 +478,10 @@
                 // 鍙栨秷绮樻�т簨浠�
                 EventBus.getDefault().removeStickyEvent(eventBus);
                 HdlLogLogic.print("姝e湪鐐瑰嚮銆愰椤点��");
-
             }
         }
     }
+
 
     /**
      * 鐢电珯鐘舵�佹瑙�
@@ -504,8 +522,19 @@
                             return;
                         }
                         viewBinding.infoRl1Text1Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity()));
-                        viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getPower()));
-                        viewBinding.infoRl1FText1Tv.setText(dataOverBean.getPowerRatio());
+                        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);
+
+                        viewBinding.infoRl1FText1Tv.setText(spannableString);
 
                         viewBinding.homePageStationInfoRl2DayIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTodayElectricity()));
                         viewBinding.homePageStationInfoRl2MonIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getMonthElectricity()));
@@ -540,7 +569,11 @@
                         Object[] values = new Object[list.size()];
                         for (int i = 0; i < list.size(); i++) {
                             keys[i] = list.get(i).getFieldName();
-                            values[i] = HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//鑾峰彇鏁存暟閮ㄥ垎
+                            if (TimeType.day.equals(timeType)) {
+                                values[i] = HdlCommonLogic.divideByOneThousandAndFormat(list.get(i).getFieldValue());// HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//鑾峰彇鏁存暟閮ㄥ垎
+                            } else {
+                                values[i] = HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue());
+                            }
                         }
                         fieldNames = keys;
                         fieldValues = values;
@@ -569,7 +602,7 @@
                 }
                 viewBinding.socialContributionData1Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getCoal())));
                 viewBinding.socialContributionData2Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getCo2())));
-                viewBinding.socialContributionData3Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getTreePlanting())));
+                viewBinding.socialContributionData3Tv.setText(HdlCommonLogic.convertString(socialContributionBean.getTreePlanting()));
             }
 
             @Override

--
Gitblit v1.8.0