mac
2024-04-22 89e91f91b49676be534eb0005d02beae7b8343ba
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
package com.hdl.photovoltaic.ui.home;
 
 
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
 
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.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;
 
/**
 * 首页模块
 */
 
public class HomePageFragment extends CustomBaseFragment implements AAChartView.AAChartViewCallBack {
 
    FragmentHomePageBinding viewBinding;
 
    AAChartView aaChartView;
 
    AAChartModel aaChartModel;
 
 
    @Override
    public Object getContentView() {
        viewBinding = FragmentHomePageBinding.inflate(getLayoutInflater());
        return viewBinding.getRoot();
    }
 
    @Override
    public void onBindView(Bundle savedInstanceState) {
        setUpAAChartView();
        viewBinding.test.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
 
            }
        });
    }
 
    private void setUpAAChartView() {
        aaChartView = viewBinding.AAChartView;
        aaChartView.callBack = this;
        aaChartModel = configureAAChartModel();
        aaChartView.aa_drawChartWithChartModel(aaChartModel);
    }
 
    private AAChartModel configureAAChartModel() {
//        Intent intent = getIntent();
//        String chartType = intent.getStringExtra("chartType");
//        int position = intent.getIntExtra("position", 0);
 
        aaChartModel = BasicChartComposer.configureAreaChart();
//        configureTheStyleForDifferentTypeChart(chartType, position);
//        configureViewsVisibility(chartType);
 
        return aaChartModel;
    }
 
    private void configureTheStyleForDifferentTypeChart(String chartType, int position) {
        if ((chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Line))
                && (position == 4 || position == 5)) {
            aaChartModel = BasicChartComposer.configureStepAreaChartAndStepLineChart();
        } else if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) {
 
            aaChartModel = BasicChartComposer.configureColumnChartAndBarChart();
        } else if (chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Areaspline)) {
            aaChartModel = BasicChartComposer.configureAreaChartAndAreasplineChartStyle(chartType);
        } else if (chartType.equals(AAChartType.Line) || chartType.equals(AAChartType.Spline)) {
            aaChartModel = BasicChartComposer.configureLineChartAndSplineChartStyle(chartType);
        }
        aaChartModel.chartType = chartType;
    }
 
    @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("正在点击【首页】");
 
            }
        }
    }
}