From e6a0ff5475e271a6b126ab27de6cf9f230b67512 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 23 四月 2025 15:29:29 +0800
Subject: [PATCH] 2025年04月23日15:29:27

---
 app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java |  359 ++++++++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 244 insertions(+), 115 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 15db7ab..bc6ea8d 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
@@ -3,24 +3,20 @@
 
 import static com.hdl.photovoltaic.ui.home.aachart.CustomStyleChartComposer.configureColorfulColumnChart;
 
+import android.Manifest;
+import android.content.Context;
+import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.location.LocationManager;
+import android.os.AsyncTask;
 import android.os.Bundle;
-import android.os.Handler;
-import android.os.Message;
-import android.os.SystemClock;
-import android.text.SpannableString;
-import android.text.Spanned;
+import android.provider.Settings;
 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 android.view.ViewGroup;
 
 
 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;
@@ -33,14 +29,16 @@
 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;
 import com.hdl.photovoltaic.enums.TimeType;
 import com.hdl.photovoltaic.enums.UnitType;
 import com.hdl.photovoltaic.listener.CloudCallBeak;
+import com.hdl.photovoltaic.listener.OnCallBeak;
 import com.hdl.photovoltaic.other.HdlCommonLogic;
-import com.hdl.photovoltaic.other.HdlDeviceLogic;
+import com.hdl.photovoltaic.other.HdlDialogLogic;
 import com.hdl.photovoltaic.other.HdlLogLogic;
 import com.hdl.photovoltaic.other.HdlPowerStationDataStatisticsLogic;
 import com.hdl.photovoltaic.other.HdlResidenceLogic;
@@ -52,15 +50,19 @@
 import com.hdl.photovoltaic.ui.bean.StatusOverviewBean;
 import com.hdl.photovoltaic.ui.home.aachart.BasicChartComposer;
 import com.hdl.photovoltaic.uni.HDLUniMP;
+import com.hdl.photovoltaic.utils.GPSManagerUtils;
+import com.hdl.photovoltaic.utils.PermissionUtils;
 import com.hdl.photovoltaic.utils.TimeUtils;
-import com.hdl.photovoltaic.utils.UnitConversionUtils;
+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;
 import org.greenrobot.eventbus.Subscribe;
 import org.greenrobot.eventbus.ThreadMode;
 
-import java.lang.ref.WeakReference;
 import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
@@ -70,7 +72,7 @@
  * 棣栭〉妯″潡
  */
 
-public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack {
+public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack, BGARefreshLayout.BGARefreshLayoutDelegate {
 
     FragmentHomePageBinding viewBinding;
 
@@ -124,7 +126,13 @@
         viewBinding.homePageStationAddIv.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
-                HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+                requestPermissions(new OnCallBeak() {
+                    @Override
+                    public void onClickCallBeak() {
+//                        UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+//                        HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+                    }
+                });
             }
         });
 
@@ -132,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);
             }
         });
         //鏃堕棿閫夋嫨鍣�
@@ -176,17 +183,17 @@
                 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_E6FFFFFF));
+                viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
+                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);
@@ -211,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_38c494));
-                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
+                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);
@@ -245,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_38c494));
-                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
+                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);
@@ -277,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_38c494));
-                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+                viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
+                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FFACACAC));
 
                 viewBinding.v1.setVisibility(View.VISIBLE);
                 viewBinding.v2.setVisibility(View.VISIBLE);
@@ -325,7 +332,9 @@
                 Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat);
                 String time = TimeUtils.addDayMonthYearToDate(calendar, 1, timeDateFormat, timeType);
                 if (TimeUtils.stringDateToTimestamp(time, timeDateFormat) > TimeUtils.getCurrentTimestamp()) {
-                    HdlThreadLogic.toast(_mActivity, getString(R.string.the_query_date_is_exceeded));
+                    FlashingBoxDialog flashingBoxDialog = new FlashingBoxDialog(_mActivity, 1500);
+                    flashingBoxDialog.setContent(getString(R.string.the_query_date_is_exceeded));
+                    flashingBoxDialog.show();
 
                     return;
                 }
@@ -334,17 +343,17 @@
             }
         });
         //璁剧疆涓嬫媺绠ご棰滆壊
-        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();
+//            }
+//        });
 
     }
+
 
     /**
      * 鏃堕棿閫夋嫨鍣�
@@ -383,23 +392,23 @@
         }).setType(new boolean[]{year, month, day, false, false, false})// 榛樿鍏ㄩ儴鏄剧ず
                 .setCancelText(_mActivity.getString(R.string.loading_cancel))//鍙栨秷鎸夐挳鏂囧瓧
                 .setSubmitText(_mActivity.getString(R.string.loading_affirm))//纭鎸夐挳鏂囧瓧
-                .setContentTextSize(18)//婊氳疆鏂囧瓧澶у皬
-                .setTitleSize(18)//鏍囬鏂囧瓧澶у皬
-                .setTitleText(_mActivity.getString(R.string.time_selectd))//鏍囬鏂囧瓧
+                .setContentTextSize(16)//婊氳疆鏂囧瓧澶у皬
+//                .setTitleSize(18)//鏍囬鏂囧瓧澶у皬
+//                .setTitleText(_mActivity.getString(R.string.time_selectd))//鏍囬鏂囧瓧
                 .setOutSideCancelable(true)//鐐瑰嚮灞忓箷锛岀偣鍦ㄦ帶浠跺閮ㄨ寖鍥存椂锛屾槸鍚﹀彇娑堟樉绀�
                 .isCyclic(false)//鏄惁寰幆婊氬姩
-                .setTitleColor(_mActivity.getColor(R.color.text_E6000000))//鏍囬鏂囧瓧棰滆壊
-                .setSubmitColor(_mActivity.getColor(R.color.text_38C494))//纭畾鎸夐挳鏂囧瓧棰滆壊
-                .setCancelColor(_mActivity.getColor(R.color.text_66000000))//鍙栨秷鎸夐挳鏂囧瓧棰滆壊
-                .setTitleBgColor(_mActivity.getColor(R.color.text_FFFFFFFF))//鏍囬鑳屾櫙棰滆壊 Night mode
-                .setBgColor(_mActivity.getColor(R.color.text_FFFFFFFF))//婊氳疆鑳屾櫙棰滆壊 Night mode
-                .setTextColorCenter(_mActivity.getColor(R.color.text_E6000000)).setDate(selectedDate)// 濡傛灉涓嶈缃殑璇濓紝榛樿鏄郴缁熸椂闂�*/
+//                .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_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銆�
                 .isDialog(false)//鏄惁鏄剧ず涓哄璇濇鏍峰紡
                 .setItemVisibleCount(7)//瀵硅瘽妗嗛珮搴�
-                .setDividerColor(_mActivity.getColor(R.color.text_E1E1E1)).setLineSpacingMultiplier(3f)//
+                .setDividerColor(_mActivity.getColor(R.color.text_1AFFFFFF)).setLineSpacingMultiplier(3f)//
                 .build();
         pvTime.show();
     }
@@ -415,46 +424,12 @@
         } else if (TimeType.month.equals(timeType) || TimeType.year.equals(timeType) || TimeType.all.equals(timeType)) {
             aaChartModel = configureColorfulColumnChart(getString(R.string.generation), fieldNames, fieldValues);
         }
-
-        if(needDelay) {
-            viewBinding.autoSizeMyAAChart.setX(10000);//鐩存帴鎵撳紑鏈夐棯灞忥紝鍦ㄤ笉鏄剧ず鐨勫湴鏂瑰厛鏄剧ず锛屽啀绉诲姩鍒版甯哥殑浣嶇疆銆俆ODO 鍚庣画鎵惧埌鏍规簮闂鍚庡幓鎺夎繖涓敤娉�
-            aaChartView.aa_drawChartWithChartModel(aaChartModel);
-            mHandler.sendEmptyMessageDelayed(100,800);
-        }
-        else{
-            aaChartView.aa_drawChartWithChartModel(aaChartModel);
-        }
-    }
-
-    FHandler mHandler=new FHandler(this);
-
-    private static class FHandler extends Handler{
-        //瀹氫箟寮卞紩鐢ㄥ疄渚�
-        private WeakReference<HomePageFragment> reference;
-
-        //鍦ㄦ瀯閫犳柟娉曚腑浼犲叆闇�瑕佹寔鏈夌殑fragment瀹炰緥
-        public FHandler(HomePageFragment fragment) {
-            reference = new WeakReference<HomePageFragment>(fragment); }
-
-        //閫氳繃澶嶅啓handlerMessage()浠庤�屽喅瀹氬浣曡繘琛屾洿鏂癠I鎿嶄綔
-        @Override
-        public void handleMessage(Message msg) {
-            //鐪佺暐浠g爜
-
-            switch (msg.what){
-                case 100:
-                    if(reference.get()!=null) {
-                        reference.get().viewBinding.autoSizeMyAAChart.setX(0);//绉诲姩鍒版纭殑浣嶇疆
-                    }
-                    break;
-            }
-        }
+        aaChartView.aa_drawChartWithChartOptions(aaChartModel.aa_toAAOptions());
     }
 
     @Override
     public void onDestroy() {
         super.onDestroy();
-        mHandler.removeCallbacksAndMessages(null);
     }
 
     private void initView() {
@@ -477,21 +452,35 @@
         viewBinding.unitTv.setText(UnitType.kW);
 
 
-        viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
-        viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_E6FFFFFF));
+        viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_39383d));
+        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) {
@@ -525,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) {
@@ -533,7 +522,7 @@
                 }
                 viewBinding.stationAllTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal()));
                 viewBinding.stationFaultsTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault()));
-                viewBinding.stationOfflineTitleTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
+                viewBinding.stationOfflineTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline()));
                 viewBinding.stationConnectedTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting()));
             }
 
@@ -559,8 +548,11 @@
                         if (dataOverBean == null) {
                             return;
                         }
-                        viewBinding.infoRl1Text1Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity()));
-                        viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getPower(), UnitType.kW, false));
+                        String capacityValue = HdlCommonLogic.convertDoubleValue(dataOverBean.getInstalledCapacity(), UnitType.kWp);
+                        viewBinding.infoRl1Text1Tv.setText(capacityValue);
+                        viewBinding.kwpUnit.setText(HdlCommonLogic.convertKWPUnit(dataOverBean.getInstalledCapacity()));
+                        viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getPower(), UnitType.kW));
+                        viewBinding.kwUnit.setText(HdlCommonLogic.convertKWUnit(dataOverBean.getPower()));
 
 //                        String str = dataOverBean.getPowerRatio() + "%";
 //                        int startIndex = str.lastIndexOf("%");
@@ -569,7 +561,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());
@@ -589,10 +581,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()));
-                        viewBinding.Total.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTotalElectricity()));
+                        viewBinding.day.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTodayElectricity(), UnitType.kWh));
+                        viewBinding.dayUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getTodayElectricity()));
+                        viewBinding.month.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getMonthElectricity(), UnitType.kWh));
+                        viewBinding.monthUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getMonthElectricity()));
+                        viewBinding.year.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getYearElectricity(), UnitType.kWh));
+                        viewBinding.yearUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getYearElectricity()));
+                        viewBinding.Total.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getTotalElectricity(), UnitType.kWh));
+                        viewBinding.TotalUnit.setText(HdlCommonLogic.convertKWHUnit(dataOverBean.getTotalElectricity()));
 
                     }
                 });
@@ -616,17 +612,28 @@
                 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.divideByOneThousandAndFormat(list.get(i).getFieldValue());// 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());
+                                if (statisticsBean.isFuture()) {
+                                    //鏈潵鏃堕棿涓嶆樉绀�
+                                    values[i] = null;
+                                } else {
+                                    values[i] = HdlCommonLogic.getBigDecimal(statisticsBean.getFieldValue());
+                                }
                             }
                         }
                         fieldNames = keys;
@@ -666,5 +673,127 @@
         });
     }
 
+    @Override
+    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
+        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
+        if (requestCode == PermissionUtils.STATUS_SUCCESS) {
 
-}
\ No newline at end of file
+            for (int i = 0; i < permissions.length; i++) {
+                if (grantResults[i] == PackageManager.PERMISSION_GRANTED) {
+                    switch (permissions[i]) {
+                        case Manifest.permission.ACCESS_FINE_LOCATION: {
+                            UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+                            HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+                            locationUpdates();
+                        }
+                        break;
+                    }
+                } else {
+                    HdlDialogLogic.getInstance().showSettingPermissionDialog(_mActivity, _mActivity.getString(R.string.set_location_permissions));
+                    break;
+                }
+
+            }
+        }
+
+    }
+
+    public void requestPermissions(OnCallBeak onCallBeak) {
+
+        //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
+        //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
+        String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION});
+        if (ary.length > 0) {
+            this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
+        } else {
+
+            UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1);
+            HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null);
+            locationUpdates();
+        }
+//        if (onCallBeak != null) {
+//            onCallBeak.onClickCallBeak();
+//        }
+    }
+
+    /**
+     * 鍒濆鍖栥�愬紑鍚畾浣嶃�戝拰銆愪綅缃俊鎭�戞潈闄�
+     */
+    private void locationUpdates() {
+        // 鍒濆鍖朙ocationManager瀵硅薄
+        LocationManager locationManager = (LocationManager) _mActivity.getSystemService(Context.LOCATION_SERVICE);
+        GPSManagerUtils.getInstance().getLocation(_mActivity);
+        // 鍒ゆ柇璁惧鏄惁鏀寔瀹氫綅鍔熻兘
+        if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
+            // 鎻愮ず鐢ㄦ埛鎵撳紑瀹氫綅鍔熻兘鎴栬�呭紩瀵肩敤鎴峰幓绯荤粺璁剧疆椤甸潰鎵撳紑瀹氫綅鍔熻兘
+            ConfirmationCancelDialog confirmationCancelDialog = new ConfirmationCancelDialog(_mActivity);
+            confirmationCancelDialog.setContent(getString(R.string.system_positioning_switch));
+            confirmationCancelDialog.setConfirmation(getString(R.string.go_to_settings));
+            confirmationCancelDialog.show();
+            confirmationCancelDialog.isHideTitle(true);
+            confirmationCancelDialog.setYesOnclickListener(new ConfirmationCancelDialog.onYesOnclickListener() {
+                @Override
+                public void Confirm() {
+                    confirmationCancelDialog.dismiss();
+                    Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
+                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+                    HDLApp.getInstance().startActivity(intent);
+
+                }
+            });
+            confirmationCancelDialog.setNoOnclickListener(new ConfirmationCancelDialog.onNoOnclickListener() {
+                @Override
+                public void Cancel() {
+                    confirmationCancelDialog.dismiss();
+                }
+            });
+
+        }
+
+    }
+
+    @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