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("正在点击【首页】"); } } } }