mac
2024-04-26 6e7ec3f7ffcab2fbfdf32778970cd72a6845e987
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
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 android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.Toast;
 
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.photovoltaic.R;
import com.hdl.photovoltaic.base.CustomBaseFragment;
import com.hdl.photovoltaic.config.ConstantManage;
import com.hdl.photovoltaic.databinding.FragmentHomePageBinding;
import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
import com.hdl.photovoltaic.other.HdlLogLogic;
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 io.dcloud.common.util.DensityUtils;
 
/**
 * 首页模块
 */
 
public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack {
 
    FragmentHomePageBinding viewBinding;
 
    AAChartView aaChartView1;
 
    AAChartModel aaChartModel1;
    AAChartView aaChartView2;
 
    AAChartModel aaChartModel2;
 
 
    @Override
    public Object getContentView() {
        viewBinding = FragmentHomePageBinding.inflate(getLayoutInflater());
        return viewBinding.getRoot();
    }
 
    @Override
    public void onBindView(Bundle savedInstanceState) {
        viewBinding.homePageStationDataTitleTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                setUpAAChartView(1);
            }
        });
        viewBinding.yearMonthDayTv.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                timeSelectedView();
 
            }
        });
        timeSelectedView();
//        viewBinding.test2.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                setUpAAChartView(2);
//            }
//        });
 
    }
 
    private  void timeSelectedView(){
        //时间选择器
        Calendar selectedDate = Calendar.getInstance();
        Calendar startDate = Calendar.getInstance();
        //startDate.set(2013,1,1);
        Calendar endDate = Calendar.getInstance();
        //endDate.set(2020,1,1);
 
        //正确设置方式
        startDate.set(2024, 1, 1);
        endDate.set(2025, 4, 25);
 
        TimePickerView pvTime = new TimePickerBuilder(_mActivity, new OnTimeSelectListener() {
            @Override
            public void onTimeSelect(Date date, View v) {//选中事件回调
//                        tvTime.setText(getTime(date));
            }
        })
                .setType(new boolean[]{true, false, false, false, false, false})// 默认全部显示
                .setCancelText("取消")//取消按钮文字
                .setSubmitText("确定")//确认按钮文字
                .setContentTextSize(18)//滚轮文字大小
                .setTitleSize(18)//标题文字大小
                .setTitleText("时间选择")//标题文字
                .setOutSideCancelable(true)//点击屏幕,点在控件外部范围时,是否取消显示
                .isCyclic(false)//是否循环滚动
                .setTitleColor(_mActivity.getColor(R.color.text_90000000))//标题文字颜色
                .setSubmitColor(_mActivity.getColor(R.color.text_38C494))//确定按钮文字颜色
                .setCancelColor(_mActivity.getColor(R.color.text_40000000))//取消按钮文字颜色
                .setTitleBgColor(_mActivity.getColor(R.color.text_FFFFFFFF))//标题背景颜色 Night mode
                .setBgColor(_mActivity.getColor(R.color.text_FFFFFFFF))//滚轮背景颜色 Night mode
                .setTextColorCenter(_mActivity.getColor(R.color.text_90000000))
                .setDate(selectedDate)// 如果不设置的话,默认是系统时间*/
                .setRangDate(startDate, endDate)//起始终止年月日设定
                .setLabel("年", "月", "日", "时", "分", "秒")//默认设置为年月日时分秒
                .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。
                .isDialog(false)//是否显示为对话框样式
                .setItemVisibleCount(17)//对话框高度
                .setDividerColor(_mActivity.getColor(R.color.text_E1E1E1))
                .setDecorView(viewBinding.wwwwww)
//                        .setLineSpacingMultiplier(3f)//
                .build();
        pvTime.show();
    }
 
    private void setUpAAChartView(int value) {
        if (value == 1) {
            aaChartView1 = viewBinding.AAChartView;
            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);
        }
    }
 
    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 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);
        }
        aaChartModel1.chartType = chartType;
    }
 
    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();
 
 
        }
        return configureColorfulChart();
    }
 
    @Override
    public void chartViewDidFinishLoad(AAChartView aaChartView) {
 
    }
 
    @Override
    public void chartViewMoveOverEventMessage(AAChartView aaChartView, AAMoveOverEventMessageModel messageModel) {
 
    }
 
 
    @Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
    public void onEventMessage(BaseEventBus eventBus) {
        super.onEventMessage(eventBus);
        if (eventBus == null) {
            return;
        }
        //接收外部点击事件
        if (eventBus.getTopic().equals(ConstantManage.homepage_title_tab_switch)) {
            if (eventBus.getType().equals(HomepageTitleTabSwitch.homepage.toString())) {
                // 取消粘性事件
                EventBus.getDefault().removeStickyEvent(eventBus);
                HdlLogLogic.print("正在点击【首页】");
 
            }
        }
    }
}