mac
2024-05-15 cae6ff870b1e9f1278a8fa21ab1013e68569607a
app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java
@@ -1,7 +1,7 @@
package com.hdl.photovoltaic.ui.home;
import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulColumnChart;
import static com.hdl.photovoltaic.ui.home.aachart.CustomStyleChartComposer.configureColorfulColumnChart;
import android.os.Bundle;
import android.text.TextUtils;
@@ -9,6 +9,7 @@
import androidx.appcompat.content.res.AppCompatResources;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import com.bigkoo.pickerview.builder.TimePickerBuilder;
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
@@ -32,6 +33,7 @@
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.home.aachart.BasicChartComposer;
import com.hdl.photovoltaic.utils.TimeUtils;
import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
@@ -52,7 +54,7 @@
    FragmentHomePageBinding viewBinding;
    AAChartView aaChartView;
    AutoSizeMyAAChart aaChartView;
    AAChartModel aaChartModel;
@@ -72,14 +74,15 @@
    @Override
    public void onBindView(Bundle savedInstanceState) {
        //初始化
        initView();
        //初始化界面监听器
        initEvent();
        //读取数据
        readDate();
    }
    /**
     * 读取数据
@@ -119,13 +122,13 @@
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
                viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.v1.setVisibility(View.GONE);
                viewBinding.v2.setVisibility(View.VISIBLE);
@@ -148,16 +151,16 @@
                }
                timeType = TimeType.month;
                viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
                viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.v1.setVisibility(View.GONE);
                viewBinding.v2.setVisibility(View.GONE);
@@ -180,16 +183,16 @@
                }
                timeType = TimeType.year;
                viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
                viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.v1.setVisibility(View.VISIBLE);
                viewBinding.v2.setVisibility(View.GONE);
@@ -210,13 +213,13 @@
                }
                timeType = TimeType.all;
                viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
                viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
                viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
                viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
@@ -264,6 +267,17 @@
                viewBinding.yearMonthDayTv.setText(time);
            }
        });
        //设置下拉箭头颜色
        viewBinding.srl.setColorSchemeResources(R.color.text_FF245EC3);
        viewBinding.srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                viewBinding.srl.setRefreshing(false);
                readDate();
            }
        });
    }
    /**
@@ -307,12 +321,12 @@
                .setTitleText(_mActivity.getString(R.string.time_selectd))//标题文字
                .setOutSideCancelable(true)//点击屏幕,点在控件外部范围时,是否取消显示
                .isCyclic(false)//是否循环滚动
                .setTitleColor(_mActivity.getColor(R.color.text_90000000))//标题文字颜色
                .setTitleColor(_mActivity.getColor(R.color.text_E6000000))//标题文字颜色
                .setSubmitColor(_mActivity.getColor(R.color.text_38C494))//确定按钮文字颜色
                .setCancelColor(_mActivity.getColor(R.color.text_40000000))//取消按钮文字颜色
                .setCancelColor(_mActivity.getColor(R.color.text_66000000))//取消按钮文字颜色
                .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)// 如果不设置的话,默认是系统时间*/
                .setTextColorCenter(_mActivity.getColor(R.color.text_E6000000)).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。
@@ -327,7 +341,7 @@
     * 图表加载
     */
    private void setUpAAChartView() {
        aaChartView = viewBinding.AAChartView;
        aaChartView = viewBinding.autoSizeMyAAChart;
        aaChartView.callBack = this;
        if (TimeType.day.equals(timeType)) {
            aaChartModel = BasicChartComposer.configureAreaChart("Pv发电功率", fieldNames, fieldValues);
@@ -337,6 +351,7 @@
            aaChartModel = configureColorfulColumnChart("Pv发电功率", fieldNames, fieldValues);
        }
        aaChartView.aa_drawChartWithChartModel(aaChartModel);
    }
    private void initView() {
@@ -360,11 +375,11 @@
        viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494));
        viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_38C494));
        viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
        viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
        viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
        viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
        viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
        viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
        viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000));
        viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000));
        viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000));
        viewBinding.v1.setVisibility(View.GONE);
        viewBinding.v2.setVisibility(View.VISIBLE);
        viewBinding.v3.setVisibility(View.VISIBLE);