From b9cc7390e8e8ce64c41c26fb369c98ce669d660c Mon Sep 17 00:00:00 2001 From: wjc <1243177876@qq.com> Date: 星期三, 07 五月 2025 15:02:30 +0800 Subject: [PATCH] Merge branch '1.2.0' --- app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java | 124 ++++++++++++++++++++++++++++++++--------- 1 files changed, 97 insertions(+), 27 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 d576529..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 @@ -8,6 +8,7 @@ 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; @@ -16,7 +17,6 @@ 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; @@ -55,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; @@ -70,7 +72,7 @@ * 棣栭〉妯″潡 */ -public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack { +public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack, BGARefreshLayout.BGARefreshLayoutDelegate { FragmentHomePageBinding viewBinding; @@ -139,7 +141,6 @@ @Override public void onClick(View v) { HdlCommonLogic.getInstance().postEventBusSticky(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.All); - } }); //鏁呴殰 @@ -342,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(); +// } +// }); } @@ -466,8 +466,21 @@ 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) { @@ -501,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) { @@ -535,10 +548,11 @@ if (dataOverBean == null) { return; } - String capacityValue = HdlCommonLogic.divideByOneThousandAndFormat(dataOverBean.getInstalledCapacity()).toString(); + 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())); + viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.convertDoubleValue(dataOverBean.getPower(), UnitType.kW)); + viewBinding.kwUnit.setText(HdlCommonLogic.convertKWUnit(dataOverBean.getPower())); // String str = dataOverBean.getPowerRatio() + "%"; // int startIndex = str.lastIndexOf("%"); @@ -567,14 +581,14 @@ } catch (Exception ignored) { } - 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)); + 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())); } }); @@ -598,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.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()); + if (statisticsBean.isFuture()) { + //鏈潵鏃堕棿涓嶆樉绀� + values[i] = null; + } else { + values[i] = HdlCommonLogic.getBigDecimal(statisticsBean.getFieldValue()); + } } } fieldNames = keys; @@ -726,4 +751,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