From e0ca0f4d1d079557fbb2367d8ca18f5d75f36235 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 10 四月 2025 15:19:48 +0800
Subject: [PATCH] 2025-04-10 15:19:45

---
 app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java |  159 +++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 111 insertions(+), 48 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 092a5ce..4b41efd 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
@@ -8,16 +8,15 @@
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.location.LocationManager;
+import android.os.AsyncTask;
 import android.os.Bundle;
 import android.provider.Settings;
 import android.text.TextUtils;
-import android.util.Log;
 import android.view.View;
 
 
 import androidx.annotation.NonNull;
 import androidx.appcompat.content.res.AppCompatResources;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 
 import com.bigkoo.pickerview.builder.TimePickerBuilder;
 import com.bigkoo.pickerview.listener.OnTimeSelectListener;
@@ -56,6 +55,8 @@
 import com.hdl.photovoltaic.utils.TimeUtils;
 import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
 import com.hdl.photovoltaic.widget.FlashingBoxDialog;
+import com.hdl.photovoltaic.widget.refreshlayout.BGARefreshLayout;
+import com.hdl.photovoltaic.widget.refreshlayout.HDLRefreshViewHolder;
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
 
 import org.greenrobot.eventbus.EventBus;
@@ -65,14 +66,13 @@
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
-import java.util.concurrent.atomic.AtomicInteger;
 
 
 /**
  * 棣栭〉妯″潡
  */
 
-public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack {
+public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack, BGARefreshLayout.BGARefreshLayoutDelegate {
 
     FragmentHomePageBinding viewBinding;
 
@@ -140,29 +140,28 @@
         viewBinding.homeAllIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.All);
-
+                HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.All);
             }
         });
         //鏁呴殰
         viewBinding.homeFaultsIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.malfunction);
+                HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.malfunction);
             }
         });
         //绂荤嚎
         viewBinding.homeOfflineIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.off);
+                HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.off);
             }
         });
         //寰呮帴鍏�
         viewBinding.homeConnectedIl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlCommonLogic.getInstance().postEventBus(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.connecting);
+                HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.connecting);
             }
         });
         //鏃堕棿閫夋嫨鍣�
@@ -185,16 +184,16 @@
                 viewBinding.unitTv.setText(UnitType.kW);
                 viewBinding.unitTextTv.setText(getString(R.string.pv_power));
                 viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
-                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_FFACACAC));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.v1.setVisibility(View.GONE);
                 viewBinding.v2.setVisibility(View.VISIBLE);
@@ -219,16 +218,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_66FFFFFF));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_FFACACAC));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.v1.setVisibility(View.GONE);
                 viewBinding.v2.setVisibility(View.GONE);
@@ -253,16 +252,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_66FFFFFF));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_FFACACAC));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.v1.setVisibility(View.VISIBLE);
                 viewBinding.v2.setVisibility(View.GONE);
@@ -285,16 +284,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_66FFFFFF));
+                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
 
                 viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FFACACAC));
 
                 viewBinding.v1.setVisibility(View.VISIBLE);
                 viewBinding.v2.setVisibility(View.VISIBLE);
@@ -344,15 +343,14 @@
             }
         });
         //璁剧疆涓嬫媺绠ご棰滆壊
-        viewBinding.srl.setColorSchemeResources(R.color.text_FF245EC3);
-        viewBinding.srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
-            @Override
-            public void onRefresh() {
-                viewBinding.srl.setRefreshing(false);
-                readDate();
-            }
-        });
-
+//        viewBinding.rsl.setColorSchemeResources(R.color.text_FF245EC3);
+//        viewBinding.rsl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
+//            @Override
+//            public void onRefresh() {
+//                viewBinding.rsl.setRefreshing(false);
+//                readDate();
+//            }
+//        });
 
     }
 
@@ -399,12 +397,12 @@
 //                .setTitleText(_mActivity.getString(R.string.time_selectd))//鏍囬鏂囧瓧
                 .setOutSideCancelable(true)//鐐瑰嚮灞忓箷锛岀偣鍦ㄦ帶浠跺閮ㄨ寖鍥存椂锛屾槸鍚﹀彇娑堟樉绀�
                 .isCyclic(false)//鏄惁寰幆婊氬姩
-//                .setTitleColor(_mActivity.getColor(R.color.text_E6FFFFFF))//鏍囬鏂囧瓧棰滆壊
-                .setSubmitColor(_mActivity.getColor(R.color.text_E6FFFFFF))//纭畾鎸夐挳鏂囧瓧棰滆壊
+//                .setTitleColor(_mActivity.getColor(R.color.text_FFACACAC))//鏍囬鏂囧瓧棰滆壊
+                .setSubmitColor(_mActivity.getColor(R.color.text_FFACACAC))//纭畾鎸夐挳鏂囧瓧棰滆壊
                 .setCancelColor(_mActivity.getColor(R.color.text_FF8E8E8E))//鍙栨秷鎸夐挳鏂囧瓧棰滆壊
                 .setTitleBgColor(_mActivity.getColor(R.color.text_FF222222))//鏍囬鑳屾櫙棰滆壊 Night mode
                 .setBgColor(_mActivity.getColor(R.color.text_FF222222))//婊氳疆鑳屾櫙棰滆壊 Night mode
-                .setTextColorCenter(_mActivity.getColor(R.color.text_E6FFFFFF)).setDate(selectedDate)// 濡傛灉涓嶈缃殑璇濓紝榛樿鏄郴缁熸椂闂�*/
+                .setTextColorCenter(_mActivity.getColor(R.color.text_FFACACAC)).setDate(selectedDate)// 濡傛灉涓嶈缃殑璇濓紝榛樿鏄郴缁熸椂闂�*/
                 .setRangDate(startDate, endDate)//璧峰缁堟骞存湀鏃ヨ瀹�
                 .setLabel(_mActivity.getString(R.string.year), _mActivity.getString(R.string.month), _mActivity.getString(R.string.day), _mActivity.getString(R.string.hour), _mActivity.getString(R.string.minute), _mActivity.getString(R.string.seconds))//榛樿璁剧疆涓哄勾鏈堟棩鏃跺垎绉�
                 .isCenterLabel(false) //鏄惁鍙樉绀轰腑闂撮�変腑椤圭殑label鏂囧瓧锛宖alse鍒欐瘡椤筰tem鍏ㄩ儴閮藉甫鏈塴abel銆�
@@ -455,21 +453,34 @@
 
 
         viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
-        viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+        viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_FFACACAC));
         viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-        viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+        viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
         viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-        viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+        viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
         viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
-        viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66FFFFFF));
+        viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B));
         viewBinding.v1.setVisibility(View.GONE);
         viewBinding.v2.setVisibility(View.VISIBLE);
         viewBinding.v3.setVisibility(View.VISIBLE);
         viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE);
         viewBinding.autoSizeMyAAChart.setBackgroundColor(_mActivity.getColor(R.color.text_FF1C1C1E));
         setUpAAChartView(true);//鍥捐〃鍔犺浇
+        pullToRefresh();
+
     }
 
+    /**
+     * 涓嬫媺鍒锋柊鐨勯�昏緫
+     */
+    protected void pullToRefresh() {
+        viewBinding.rsl.setDelegate(this);
+        HDLRefreshViewHolder hdlRefreshViewHolder = new HDLRefreshViewHolder(_mActivity, true);
+        hdlRefreshViewHolder.setPullDownImageResource(R.mipmap.loading_44);
+        hdlRefreshViewHolder.setChangeToReleaseRefreshAnimResId(R.drawable.loading_refresh);
+        hdlRefreshViewHolder.setRefreshingAnimResId(R.drawable.loading_refresh_end);
+        viewBinding.rsl.setRefreshViewHolder(hdlRefreshViewHolder);
+    }
 
     @Override
     public void chartViewDidFinishLoad(AAChartView aaChartView) {
@@ -503,7 +514,7 @@
      * 鐢电珯鐘舵�佹瑙�
      */
     private void getStatusOverview() {
-        HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() {
+        HdlResidenceLogic.getInstance().getStatusOverview("", "", "", new CloudCallBeak<StatusOverviewBean>() {
             @Override
             public void onSuccess(StatusOverviewBean statusOverviewBean) {
                 if (statusOverviewBean == null) {
@@ -537,8 +548,9 @@
                         if (dataOverBean == null) {
                             return;
                         }
-                        String capacityValue = HdlCommonLogic.getBigDecimal(dataOverBean.getInstalledCapacity()).toString();
+                        String capacityValue = HdlCommonLogic.divideByOneThousandAndFormat(dataOverBean.getInstalledCapacity()).toString();
                         viewBinding.infoRl1Text1Tv.setText(capacityValue);
+                        viewBinding.kwpUnit.setText(HdlCommonLogic.convertKWPUnit(dataOverBean.getInstalledCapacity()));
                         viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getPower()));
 
 //                        String str = dataOverBean.getPowerRatio() + "%";
@@ -548,7 +560,7 @@
 //                        //璁剧疆绗竴閮ㄥ垎鏂囧瓧鐨勫瓧浣撳ぇ灏�
 //                        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));
+//                        ForegroundColorSpan colorSpan = new ForegroundColorSpan(HDLApp.getInstance().getColor(R.color.text_FF5B5B5B));
 //                        spannableString.setSpan(colorSpan, startIndex, endIndex, 0);
 //                        viewBinding.infoRl1FText1Tv.setText(spannableString);
                         viewBinding.infoRl1FText1Tv.setText(dataOverBean.getPowerRatio());
@@ -599,17 +611,23 @@
                 HdlThreadLogic.runMainThread(new Runnable() {
                     @Override
                     public void run() {
-                        if (list == null || list.size() == 0) {
+                        if (list == null || list.isEmpty()) {
                             return;
                         }
                         String[] keys = new String[list.size()];
                         Object[] values = new Object[list.size()];
                         for (int i = 0; i < list.size(); i++) {
-                            keys[i] = list.get(i).getFieldName();
+                            StatisticsBean statisticsBean = list.get(i);
+                            keys[i] = statisticsBean.getFieldName();
                             if (TimeType.day.equals(timeType)) {
-                                values[i] = HdlCommonLogic.convertBigDecimal(list.get(i).getFieldValue(), 1000);// HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//鑾峰彇鏁存暟閮ㄥ垎
+                                if (statisticsBean.isFuture()) {
+                                    //鏈潵鏃堕棿涓嶆樉绀�
+                                    values[i] = null;
+                                } else {
+                                    values[i] = HdlCommonLogic.convertBigDecimal(statisticsBean.getFieldValue(), 1000);// HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//鑾峰彇鏁存暟閮ㄥ垎
+                                }
                             } else {
-                                values[i] = HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue());
+                                values[i] = HdlCommonLogic.getBigDecimal(statisticsBean.getFieldValue());
                             }
                         }
                         fieldNames = keys;
@@ -727,4 +745,49 @@
         }
 
     }
+
+    @Override
+    public void onBGARefreshLayoutBeginRefreshing(BGARefreshLayout refreshLayout) {
+        new AsyncTask<Void, Void, Void>() {
+
+            @Override
+            protected Void doInBackground(Void... params) {
+                try {
+                    Thread.sleep(2000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                return null;
+            }
+
+            @Override
+            protected void onPostExecute(Void aVoid) {
+                viewBinding.rsl.endRefreshing();
+                //鍔犺浇鏈�鏂版暟鎹畬鎴�
+                readDate();
+            }
+        }.execute();
+    }
+
+    @Override
+    public boolean onBGARefreshLayoutBeginLoadingMore(BGARefreshLayout refreshLayout) {
+        new AsyncTask<Void, Void, Void>() {
+
+            @Override
+            protected Void doInBackground(Void... params) {
+                try {
+                    Thread.sleep(2000);
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                }
+                return null;
+            }
+
+            @Override
+            protected void onPostExecute(Void aVoid) {
+                viewBinding.rsl.endLoadingMore();
+            }
+        }.execute();
+        return true;
+    }
 }

--
Gitblit v1.8.0