| | |
| | | package com.hdl.photovoltaic.ui.home; |
| | | |
| | | |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.adjustYAxisMaxAndMinValues; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureAreaChartThreshold; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureChartWithShadowStyle; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulColumnChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientAreaChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientColorChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientSplineChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulShadowSplineChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureDiscontinuousDataChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureGradientColorAreasplineChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureHexagonRadarChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureNightingaleRoseChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configurePentagonRadarChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureQuadrangleRadarChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureTriangleRadarChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.connectNullsForSingleAASeriesElement; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customBarChartHoverColorAndSelectColor; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customChartHoverAndSelectHaloStyle; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartMarkerSymbolContent; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customScatterChartMarkerSymbolContent; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.disableSplineChartMarkerHoverEffect; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.doubleLayerPieChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.drawLineChartWithPointsCoordinates; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.largeDataStackingColumnChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.topRoundedCornersStackingColumnChart; |
| | | import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.upsideDownPyramidChart; |
| | | 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.provider.Settings; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | |
| | | |
| | | import androidx.annotation.NonNull; |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | import com.bigkoo.pickerview.builder.TimePickerBuilder; |
| | | import com.bigkoo.pickerview.listener.OnTimeSelectListener; |
| | | import com.bigkoo.pickerview.view.TimePickerView; |
| | | import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel; |
| | | import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView; |
| | | import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel; |
| | | import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType; |
| | | 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; |
| | | 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.HdlDialogLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlPowerStationDataStatisticsLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | import com.hdl.photovoltaic.other.HdlUniLogic; |
| | | import com.hdl.photovoltaic.ui.bean.DataOverBean; |
| | | import com.hdl.photovoltaic.ui.bean.SocialContributionBean; |
| | | import com.hdl.photovoltaic.ui.bean.StatisticsBean; |
| | | 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.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.util.Calendar; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | | * 首页模块 |
| | | */ |
| | | |
| | | public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack { |
| | | public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack, BGARefreshLayout.BGARefreshLayoutDelegate { |
| | | |
| | | FragmentHomePageBinding viewBinding; |
| | | |
| | | AAChartView aaChartView1; |
| | | AutoSizeMyAAChart aaChartView; |
| | | |
| | | AAChartModel aaChartModel1; |
| | | AAChartView aaChartView2; |
| | | AAChartModel aaChartModel; |
| | | |
| | | AAChartModel aaChartModel2; |
| | | AAChartView aaChartView3; |
| | | |
| | | AAChartModel aaChartModel3; |
| | | private String[] fieldNames = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"};//图标X轴坐标值的数组 |
| | | private Object[] fieldValues = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//图标Y轴坐标值的数组 |
| | | |
| | | |
| | | private String timeType = TimeType.day;//时间类型(默认:天) |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | viewBinding.test1.setOnClickListener(new View.OnClickListener() { |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | | initEvent(); |
| | | //读取数据 |
| | | readDate(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 读取数据 |
| | | */ |
| | | private void readDate() { |
| | | HdlThreadLogic.runSubThread(new Runnable() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | setUpAAChartView(1); |
| | | } |
| | | }); |
| | | viewBinding.test2.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | setUpAAChartView(2); |
| | | } |
| | | }); |
| | | viewBinding.test3.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | setUpAAChartView(3); |
| | | public void run() { |
| | | getStatusOverview(); |
| | | getDataOver(); |
| | | getStatistics(); |
| | | getSocialContribution(); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void setUpAAChartView(int value) { |
| | | if (value == 1) { |
| | | aaChartView1 = viewBinding.AAChartView1; |
| | | aaChartView1.callBack = this; |
| | | aaChartModel1 = configureAAChartModel(); |
| | | aaChartView1.aa_drawChartWithChartModel(aaChartModel1); |
| | | } else if (value == 2) { |
| | | aaChartView2 = viewBinding.AAChartView2; |
| | | aaChartView2.callBack = this; |
| | | aaChartModel2 = configureColorfulColumnChart();// configureTheAAChartModel("colorfulColumnChart"); |
| | | aaChartView2.aa_drawChartWithChartModel(aaChartModel2); |
| | | } else if (value == 3) { |
| | | aaChartView3 = viewBinding.AAChartView3; |
| | | aaChartView3.callBack = this; |
| | | aaChartModel3 = configureAAChartModel(); |
| | | aaChartView3.aa_drawChartWithChartModel(aaChartModel3); |
| | | } |
| | | private void initEvent() { |
| | | //电站添加 |
| | | viewBinding.homePageStationAddIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | requestPermissions(new OnCallBeak() { |
| | | @Override |
| | | public void onClickCallBeak() { |
| | | // UserConfigManage.getInstance().setUniBottomSafeDistanceBackgroundColor(1); |
| | | // HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | } |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | //全部 |
| | | viewBinding.homeAllIl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | 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().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().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().postEventBusSticky(ConstantManage.homepage_title_tab_switch, ConstantManage.station_page, PowerStationStatus.connecting); |
| | | } |
| | | }); |
| | | //时间选择器 |
| | | viewBinding.yearMonthDayTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | selectedTimePickerBuilder(); |
| | | |
| | | } |
| | | }); |
| | | //日 |
| | | viewBinding.dayTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (timeType.equals(TimeType.day)) { |
| | | //点击同一个类型 |
| | | 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_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_FF5B5B5B)); |
| | | |
| | | viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | 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_FF5B5B5B)); |
| | | |
| | | viewBinding.v1.setVisibility(View.GONE); |
| | | viewBinding.v2.setVisibility(View.VISIBLE); |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | getStatistics(); |
| | | |
| | | } |
| | | }); |
| | | //月 |
| | | viewBinding.monthTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (timeType.equals(TimeType.month)) { |
| | | //点击同一个类型 |
| | | 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_FF5B5B5B)); |
| | | |
| | | 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_FF5B5B5B)); |
| | | |
| | | viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B)); |
| | | |
| | | viewBinding.v1.setVisibility(View.GONE); |
| | | viewBinding.v2.setVisibility(View.GONE); |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | getStatistics(); |
| | | |
| | | |
| | | } |
| | | }); |
| | | //年 |
| | | viewBinding.yearTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (timeType.equals(TimeType.year)) { |
| | | //点击同一个类型 |
| | | 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_FF5B5B5B)); |
| | | |
| | | viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | 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_FFACACAC)); |
| | | |
| | | viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_FF5B5B5B)); |
| | | |
| | | viewBinding.v1.setVisibility(View.VISIBLE); |
| | | viewBinding.v2.setVisibility(View.GONE); |
| | | viewBinding.v3.setVisibility(View.GONE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | getStatistics(); |
| | | } |
| | | }); |
| | | //生命期 |
| | | viewBinding.lifeCycleTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | if (timeType.equals(TimeType.all)) { |
| | | //点击同一个类型 |
| | | 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_FF5B5B5B)); |
| | | |
| | | viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | 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_FF5B5B5B)); |
| | | |
| | | 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); |
| | | viewBinding.v3.setVisibility(View.GONE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.GONE); |
| | | getStatistics(); |
| | | |
| | | } |
| | | }); |
| | | //上一步 |
| | | viewBinding.lastStepClickLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String currDate = viewBinding.yearMonthDayTv.getText().toString(); |
| | | if (TextUtils.isEmpty(currDate)) { |
| | | return; |
| | | } |
| | | String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); |
| | | Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); |
| | | String time = TimeUtils.subtractDayMonthYearFromDate(calendar, 1, timeDateFormat, timeType); |
| | | //不需要限制最小日期,因为是查询账号下所有电站,无法知道最小建站日期 |
| | | viewBinding.yearMonthDayTv.setText(time); |
| | | getStatistics(); |
| | | |
| | | } |
| | | }); |
| | | //下一步 |
| | | viewBinding.nextStepClickLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | String currDate = viewBinding.yearMonthDayTv.getText().toString(); |
| | | if (TextUtils.isEmpty(currDate)) { |
| | | return; |
| | | } |
| | | String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); |
| | | Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); |
| | | String time = TimeUtils.addDayMonthYearToDate(calendar, 1, timeDateFormat, timeType); |
| | | if (TimeUtils.stringDateToTimestamp(time, timeDateFormat) > TimeUtils.getCurrentTimestamp()) { |
| | | FlashingBoxDialog flashingBoxDialog = new FlashingBoxDialog(_mActivity, 1500); |
| | | flashingBoxDialog.setContent(getString(R.string.the_query_date_is_exceeded)); |
| | | flashingBoxDialog.show(); |
| | | |
| | | return; |
| | | } |
| | | viewBinding.yearMonthDayTv.setText(time); |
| | | getStatistics(); |
| | | } |
| | | }); |
| | | //设置下拉箭头颜色 |
| | | // viewBinding.rsl.setColorSchemeResources(R.color.text_FF245EC3); |
| | | // viewBinding.rsl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { |
| | | // @Override |
| | | // public void onRefresh() { |
| | | // viewBinding.rsl.setRefreshing(false); |
| | | // readDate(); |
| | | // } |
| | | // }); |
| | | |
| | | } |
| | | |
| | | private AAChartModel configureAAChartModel() { |
| | | // Intent intent = getIntent(); |
| | | String chartType = AAChartType.Area; |
| | | int position = 0; |
| | | aaChartModel1 = BasicChartComposer.configureAreaChart(); |
| | | configureTheStyleForDifferentTypeChart(chartType, position); |
| | | // configureViewsVisibility(chartType); |
| | | return aaChartModel1; |
| | | |
| | | /** |
| | | * 时间选择器 |
| | | */ |
| | | private void selectedTimePickerBuilder() { |
| | | |
| | | String currDate = viewBinding.yearMonthDayTv.getText().toString(); |
| | | //时间选择器 |
| | | Calendar selectedDate = TimeUtils.stringToCalendar(currDate, TimeUtils.getTimeDateFormat(timeType)); |
| | | Calendar startDate = Calendar.getInstance(); |
| | | Calendar endDate = TimeUtils.timestampToCalendar(TimeUtils.getCurrentTimestamp()); |
| | | //设置日期【开始】和【结束】 |
| | | startDate.set(2023, 1, 1); |
| | | endDate.set(endDate.get(Calendar.YEAR), endDate.get(Calendar.MONTH), endDate.get(Calendar.DAY_OF_MONTH)); |
| | | boolean day = true; |
| | | boolean month = true; |
| | | boolean year = true; |
| | | if (timeType.equals(TimeType.month)) { |
| | | day = false; |
| | | } else if (timeType.equals(TimeType.year)) { |
| | | day = false; |
| | | month = false; |
| | | } |
| | | TimePickerView pvTime = new TimePickerBuilder(_mActivity, new OnTimeSelectListener() { |
| | | @Override |
| | | public void onTimeSelect(Date date, View v) {//选中事件回调 |
| | | String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); |
| | | String time = TimeUtils.dateToString(date, timeDateFormat); |
| | | if (viewBinding.yearMonthDayTv.getText().toString().equals(time)) { |
| | | //表示同一个时间 |
| | | return; |
| | | } |
| | | viewBinding.yearMonthDayTv.setText(time); |
| | | getStatistics(); |
| | | } |
| | | }).setType(new boolean[]{year, month, day, false, false, false})// 默认全部显示 |
| | | .setCancelText(_mActivity.getString(R.string.loading_cancel))//取消按钮文字 |
| | | .setSubmitText(_mActivity.getString(R.string.loading_affirm))//确认按钮文字 |
| | | .setContentTextSize(16)//滚轮文字大小 |
| | | // .setTitleSize(18)//标题文字大小 |
| | | // .setTitleText(_mActivity.getString(R.string.time_selectd))//标题文字 |
| | | .setOutSideCancelable(true)//点击屏幕,点在控件外部范围时,是否取消显示 |
| | | .isCyclic(false)//是否循环滚动 |
| | | // .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文字,false则每项item全部都带有label。 |
| | | .isDialog(false)//是否显示为对话框样式 |
| | | .setItemVisibleCount(7)//对话框高度 |
| | | .setDividerColor(_mActivity.getColor(R.color.text_1AFFFFFF)).setLineSpacingMultiplier(3f)// |
| | | .build(); |
| | | pvTime.show(); |
| | | } |
| | | |
| | | private void configureTheStyleForDifferentTypeChart(String chartType, int position) { |
| | | if ((chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Line)) |
| | | && (position == 4 || position == 5)) { |
| | | aaChartModel1 = BasicChartComposer.configureStepAreaChartAndStepLineChart(); |
| | | } else if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) { |
| | | |
| | | aaChartModel1 = BasicChartComposer.configureColumnChartAndBarChart(); |
| | | } else if (chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Areaspline)) { |
| | | aaChartModel1 = BasicChartComposer.configureAreaChartAndAreasplineChartStyle(chartType); |
| | | } else if (chartType.equals(AAChartType.Line) || chartType.equals(AAChartType.Spline)) { |
| | | aaChartModel1 = BasicChartComposer.configureLineChartAndSplineChartStyle(chartType); |
| | | /** |
| | | * 图表加载 |
| | | */ |
| | | private void setUpAAChartView(boolean needDelay) { |
| | | aaChartView = viewBinding.autoSizeMyAAChart; |
| | | 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.generation), fieldNames, fieldValues); |
| | | } |
| | | aaChartModel1.chartType = chartType; |
| | | aaChartView.aa_drawChartWithChartOptions(aaChartModel.aa_toAAOptions()); |
| | | } |
| | | |
| | | private AAChartModel configureTheAAChartModel(String chartType) { |
| | | switch (chartType) { |
| | | case "colorfulChart": |
| | | return configureColorfulChart(); |
| | | case "gradientColorfulChart": |
| | | return configureColorfulGradientColorChart(); |
| | | case "discontinuousDataChart": |
| | | return configureDiscontinuousDataChart(); |
| | | case "colorfulColumnChart": |
| | | return configureColorfulColumnChart(); |
| | | case "nightingaleRoseChart": |
| | | return configureNightingaleRoseChart(); |
| | | case "chartWithShadowStyle": |
| | | return configureChartWithShadowStyle(); |
| | | case "colorfulGradientAreaChart": |
| | | return configureColorfulGradientAreaChart(); |
| | | case "colorfulGradientSplineChart": |
| | | return configureColorfulGradientSplineChart(); |
| | | case "gradientColorAreasplineChart": |
| | | return configureGradientColorAreasplineChart(); |
| | | case "SpecialStyleMarkerOfSingleDataElementChart": |
| | | return configureSpecialStyleMarkerOfSingleDataElementChart(); |
| | | case "SpecialStyleColumnOfSingleDataElementChart": |
| | | return configureSpecialStyleColumnOfSingleDataElementChart(); |
| | | case "AreaChartThreshold": |
| | | return configureAreaChartThreshold(); |
| | | case "customScatterChartMarkerSymbolContent": |
| | | return customScatterChartMarkerSymbolContent(); |
| | | case "customLineChartMarkerSymbolContent": |
| | | return customLineChartMarkerSymbolContent(); |
| | | case "TriangleRadarChart": |
| | | return configureTriangleRadarChart(); |
| | | case "QuadrangleRadarChart": |
| | | return configureQuadrangleRadarChart(); |
| | | case "PentagonRadarChart": |
| | | return configurePentagonRadarChart(); |
| | | case "HexagonRadarChart": |
| | | return configureHexagonRadarChart(); |
| | | case "adjustYAxisMaxAndMinValues": |
| | | return adjustYAxisMaxAndMinValues(); |
| | | case "customSpecialStyleDataLabelOfSingleDataElementChart": |
| | | return customSpecialStyleDataLabelOfSingleDataElementChart(); |
| | | case "customBarChartHoverColorAndSelectColor": |
| | | return customBarChartHoverColorAndSelectColor(); |
| | | case "customChartHoverAndSelectHaloStyle": |
| | | return customChartHoverAndSelectHaloStyle(); |
| | | case "customSplineChartMarkerStatesHoverStyle": |
| | | return customSplineChartMarkerStatesHoverStyle(); |
| | | case "splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle": |
| | | return splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(); |
| | | case "customNormalStackingChartDataLabelsContentAndStyle": |
| | | return customNormalStackingChartDataLabelsContentAndStyle(); |
| | | case "upsideDownPyramidChart": |
| | | return upsideDownPyramidChart(); |
| | | case "doubleLayerPieChart": |
| | | return doubleLayerPieChart(); |
| | | case "disableSomeOfLinesMouseTrackingEffect": |
| | | return disableSomeOfLinesMouseTrackingEffect(); |
| | | case "configureColorfulShadowSplineChart": |
| | | return configureColorfulShadowSplineChart(); |
| | | case "configureColorfulDataLabelsStepLineChart": |
| | | return configureColorfulDataLabelsStepLineChart(); |
| | | case "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart": |
| | | return configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(); |
| | | case "disableSplineChartMarkerHoverEffect": |
| | | return disableSplineChartMarkerHoverEffect(); |
| | | case "configureMaxAndMinDataLabelsForChart": |
| | | return configureMaxAndMinDataLabelsForChart(); |
| | | case "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag": |
| | | return customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(); |
| | | case "noMoreGroupingAndOverlapEachOtherColumnChart": |
| | | return noMoreGroupingAndOverlapEachOtherColumnChart(); |
| | | case "noMoreGroupingAndNestedColumnChart": |
| | | return noMoreGroupingAndNestedColumnChart(); |
| | | case "topRoundedCornersStackingColumnChart": |
| | | return topRoundedCornersStackingColumnChart(); |
| | | case "freeStyleRoundedCornersStackingColumnChart": |
| | | return freeStyleRoundedCornersStackingColumnChart(); |
| | | case "customColumnChartBorderStyleAndStatesHoverColor": |
| | | return customColumnChartBorderStyleAndStatesHoverColor(); |
| | | case "customLineChartWithColorfulMarkersAndLines": |
| | | return customLineChartWithColorfulMarkersAndLines(); |
| | | case "customLineChartWithColorfulMarkersAndLines2": |
| | | return customLineChartWithColorfulMarkersAndLines2(); |
| | | case "drawLineChartWithPointsCoordinates": |
| | | return drawLineChartWithPointsCoordinates(); |
| | | case "configureSpecialStyleColumnForNegativeDataMixedPositiveData": |
| | | return configureSpecialStyleColumnForNegativeDataMixedPositiveData(); |
| | | case "configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart": |
| | | return configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(); |
| | | case "connectNullsForSingleAASeriesElement": |
| | | return connectNullsForSingleAASeriesElement(); |
| | | case "lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement": |
| | | return lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(); |
| | | case "customAreasplineChartWithColorfulGradientColorZones": |
| | | return customAreasplineChartWithColorfulGradientColorZones(); |
| | | case "largeDataStackingColumnChart": |
| | | return largeDataStackingColumnChart(); |
| | | @Override |
| | | public void onDestroy() { |
| | | super.onDestroy(); |
| | | } |
| | | |
| | | private void initView() { |
| | | |
| | | 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); |
| | | |
| | | // 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); |
| | | |
| | | |
| | | } |
| | | return configureColorfulChart(); |
| | | 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_FF5B5B5B)); |
| | | viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | 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_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 |
| | |
| | | // 取消粘性事件 |
| | | EventBus.getDefault().removeStickyEvent(eventBus); |
| | | HdlLogLogic.print("正在点击【首页】"); |
| | | |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 电站状态概览 |
| | | */ |
| | | private void getStatusOverview() { |
| | | HdlResidenceLogic.getInstance().getStatusOverview("", "", "", new CloudCallBeak<StatusOverviewBean>() { |
| | | @Override |
| | | public void onSuccess(StatusOverviewBean statusOverviewBean) { |
| | | if (statusOverviewBean == null) { |
| | | return; |
| | | } |
| | | viewBinding.stationAllTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal())); |
| | | viewBinding.stationFaultsTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault())); |
| | | viewBinding.stationOfflineTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline())); |
| | | viewBinding.stationConnectedTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting())); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取统计概览数据(公司维度) |
| | | */ |
| | | private void getDataOver() { |
| | | |
| | | HdlPowerStationDataStatisticsLogic.getInstance().getDataOver(new CloudCallBeak<DataOverBean>() { |
| | | @Override |
| | | public void onSuccess(DataOverBean dataOverBean) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (dataOverBean == null) { |
| | | return; |
| | | } |
| | | 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("%"); |
| | | // int endIndex = str.lastIndexOf("%") + 1; |
| | | // SpannableString spannableString = new SpannableString(str); |
| | | // //设置第一部分文字的字体大小 |
| | | // spannableString.setSpan(new AbsoluteSizeSpan((int) UnitConversionUtils.dpToPx(HDLApp.getInstance(), 12)), startIndex, endIndex, 0); |
| | | // // 创建一个ForegroundColorSpan对象,参数是颜色值 |
| | | // 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()); |
| | | 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); |
| | | } |
| | | |
| | | } catch (Exception ignored) { |
| | | } |
| | | |
| | | 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())); |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 发电量统计(公司维度) |
| | | */ |
| | | private void getStatistics() { |
| | | String currDate = viewBinding.yearMonthDayTv.getText().toString(); |
| | | HdlPowerStationDataStatisticsLogic.getInstance().getStatistics(timeType, currDate, new CloudCallBeak<List<StatisticsBean>>() { |
| | | @Override |
| | | public void onSuccess(List<StatisticsBean> list) { |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | 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++) { |
| | | StatisticsBean statisticsBean = list.get(i); |
| | | keys[i] = statisticsBean.getFieldName(); |
| | | if (TimeType.day.equals(timeType)) { |
| | | if (statisticsBean.isFuture()) { |
| | | //未来时间不显示 |
| | | values[i] = null; |
| | | } else { |
| | | values[i] = HdlCommonLogic.convertBigDecimal(statisticsBean.getFieldValue(), 1000);// HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//获取整数部分 |
| | | } |
| | | } else { |
| | | if (statisticsBean.isFuture()) { |
| | | //未来时间不显示 |
| | | values[i] = null; |
| | | } else { |
| | | values[i] = HdlCommonLogic.getBigDecimal(statisticsBean.getFieldValue()); |
| | | } |
| | | } |
| | | } |
| | | fieldNames = keys; |
| | | fieldValues = values; |
| | | setUpAAChartView(false); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | /** |
| | | * 社会贡献(公司维度) |
| | | */ |
| | | private void getSocialContribution() { |
| | | HdlPowerStationDataStatisticsLogic.getInstance().getSocialContribution(new CloudCallBeak<SocialContributionBean>() { |
| | | @Override |
| | | public void onSuccess(SocialContributionBean socialContributionBean) { |
| | | if (socialContributionBean == null) { |
| | | return; |
| | | } |
| | | viewBinding.socialContributionData1Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getCoal()))); |
| | | viewBinding.socialContributionData2Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getCo2()))); |
| | | viewBinding.socialContributionData3Tv.setText(HdlCommonLogic.convertString(socialContributionBean.getTreePlanting())); |
| | | } |
| | | |
| | | @Override |
| | | public void onFailure(HDLException e) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | @Override |
| | | public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { |
| | | super.onRequestPermissionsResult(requestCode, permissions, grantResults); |
| | | if (requestCode == PermissionUtils.STATUS_SUCCESS) { |
| | | |
| | | 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() { |
| | | // 初始化LocationManager对象 |
| | | 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; |
| | | } |
| | | } |