| | |
| | | import android.content.Intent; |
| | | import android.graphics.Color; |
| | | import android.os.Bundle; |
| | | import android.provider.Settings; |
| | | import android.view.View; |
| | | import android.view.ViewGroup; |
| | | import android.view.WindowManager; |
| | | import android.widget.Toast; |
| | | |
| | | import androidx.appcompat.content.res.AppCompatResources; |
| | | |
| | | import com.bigkoo.pickerview.builder.TimePickerBuilder; |
| | | import com.bigkoo.pickerview.listener.OnTimeSelectListener; |
| | |
| | | import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType; |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.config.AppConfigManage; |
| | | 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.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.utils.TimeUtils; |
| | | import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; |
| | | |
| | | import org.greenrobot.eventbus.EventBus; |
| | |
| | | |
| | | FragmentHomePageBinding viewBinding; |
| | | |
| | | AAChartView aaChartView1; |
| | | AAChartView aaChartView; |
| | | |
| | | AAChartModel aaChartModel1; |
| | | AAChartView aaChartView2; |
| | | AAChartModel aaChartModel; |
| | | |
| | | AAChartModel aaChartModel2; |
| | | |
| | | private TimeType timeType = TimeType.day;//时间类型(默认:天) |
| | | |
| | | |
| | | @Override |
| | |
| | | |
| | | @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); |
| | | // } |
| | | // }); |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | | initEvent(); |
| | | |
| | | } |
| | | |
| | | private void timeSelectedView(){ |
| | | private void initEvent() { |
| | | //时间选择器 |
| | | 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) { |
| | | timeType = TimeType.day; |
| | | |
| | | 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.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.v1.setVisibility(View.GONE); |
| | | viewBinding.v2.setVisibility(View.VISIBLE); |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | |
| | | |
| | | setUpAAChartView(1); |
| | | |
| | | } |
| | | }); |
| | | //月 |
| | | viewBinding.monthTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | timeType = TimeType.month; |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | 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.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.v1.setVisibility(View.GONE); |
| | | viewBinding.v2.setVisibility(View.GONE); |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | |
| | | setUpAAChartView(2); |
| | | |
| | | |
| | | } |
| | | }); |
| | | //年 |
| | | viewBinding.yearTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | timeType = TimeType.year; |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | 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.v1.setVisibility(View.VISIBLE); |
| | | viewBinding.v2.setVisibility(View.GONE); |
| | | viewBinding.v3.setVisibility(View.GONE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | |
| | | setUpAAChartView(2); |
| | | } |
| | | }); |
| | | //生命期 |
| | | viewBinding.lifeCycleTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | timeType = TimeType.lifecycle; |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | |
| | | viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494)); |
| | | viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_38C494)); |
| | | |
| | | viewBinding.v1.setVisibility(View.VISIBLE); |
| | | viewBinding.v2.setVisibility(View.VISIBLE); |
| | | viewBinding.v3.setVisibility(View.GONE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.GONE); |
| | | |
| | | setUpAAChartView(2); |
| | | |
| | | } |
| | | }); |
| | | //上一步 |
| | | viewBinding.lastStepIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | } |
| | | }); |
| | | //下一步 |
| | | viewBinding.nextStepIv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | private void initView() { |
| | | String dataStr = TimeUtils.getDateTimestamp(System.currentTimeMillis(), TimeUtils.zhDateFormat); |
| | | if (!UserConfigManage.getInstance().isZh()) { |
| | | dataStr = TimeUtils.getDateTimestamp(System.currentTimeMillis(), TimeUtils.enDateFormat); |
| | | } |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | 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.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_40000000)); |
| | | viewBinding.v1.setVisibility(View.GONE); |
| | | viewBinding.v2.setVisibility(View.VISIBLE); |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 时间选择器 |
| | | */ |
| | | private void selectedTimePickerBuilder() { |
| | | //时间选择器 |
| | | Calendar selectedDate = Calendar.getInstance(); |
| | | Calendar startDate = Calendar.getInstance(); |
| | |
| | | // tvTime.setText(getTime(date)); |
| | | } |
| | | }) |
| | | .setType(new boolean[]{true, false, false, false, false, false})// 默认全部显示 |
| | | .setCancelText("取消")//取消按钮文字 |
| | | .setSubmitText("确定")//确认按钮文字 |
| | | .setType(new boolean[]{true, true, true, false, false, false})// 默认全部显示 |
| | | .setCancelText(_mActivity.getString(R.string.loading_cancel))//取消按钮文字 |
| | | .setSubmitText(_mActivity.getString(R.string.loading_affirm))//确认按钮文字 |
| | | .setContentTextSize(18)//滚轮文字大小 |
| | | .setTitleSize(18)//标题文字大小 |
| | | .setTitleText("时间选择")//标题文字 |
| | | .setTitleText(_mActivity.getString(R.string.time_selectd))//标题文字 |
| | | .setOutSideCancelable(true)//点击屏幕,点在控件外部范围时,是否取消显示 |
| | | .isCyclic(false)//是否循环滚动 |
| | | .setTitleColor(_mActivity.getColor(R.color.text_90000000))//标题文字颜色 |
| | |
| | | .setTextColorCenter(_mActivity.getColor(R.color.text_90000000)) |
| | | .setDate(selectedDate)// 如果不设置的话,默认是系统时间*/ |
| | | .setRangDate(startDate, endDate)//起始终止年月日设定 |
| | | .setLabel("年", "月", "日", "时", "分", "秒")//默认设置为年月日时分秒 |
| | | .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.succeed))//默认设置为年月日时分秒 |
| | | .isCenterLabel(false) //是否只显示中间选中项的label文字,false则每项item全部都带有label。 |
| | | .isDialog(false)//是否显示为对话框样式 |
| | | .setItemVisibleCount(17)//对话框高度 |
| | | .setItemVisibleCount(7)//对话框高度 |
| | | .setDividerColor(_mActivity.getColor(R.color.text_E1E1E1)) |
| | | .setDecorView(viewBinding.wwwwww) |
| | | // .setLineSpacingMultiplier(3f)// |
| | | .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); |
| | | aaChartView = viewBinding.AAChartView; |
| | | aaChartView.callBack = this; |
| | | aaChartModel = configureAAChartModel(); |
| | | aaChartView.aa_drawChartWithChartModel(aaChartModel); |
| | | } else if (value == 2) { |
| | | // aaChartView2 = viewBinding.AAChartView2; |
| | | aaChartView2.callBack = this; |
| | | aaChartModel2 = configureColorfulColumnChart();// configureTheAAChartModel("colorfulColumnChart"); |
| | | aaChartView2.aa_drawChartWithChartModel(aaChartModel2); |
| | | aaChartView = viewBinding.AAChartView; |
| | | aaChartView.callBack = this; |
| | | aaChartModel = configureColorfulColumnChart();// configureTheAAChartModel("colorfulColumnChart"); |
| | | aaChartView.aa_drawChartWithChartModel(aaChartModel); |
| | | } |
| | | } |
| | | |
| | | private AAChartModel configureAAChartModel() { |
| | | // Intent intent = getIntent(); |
| | | String chartType = AAChartType.Area; |
| | | int position = 0; |
| | | aaChartModel1 = BasicChartComposer.configureAreaChart(); |
| | | aaChartModel = BasicChartComposer.configureAreaChart(); |
| | | configureTheStyleForDifferentTypeChart(chartType, position); |
| | | // configureViewsVisibility(chartType); |
| | | return aaChartModel1; |
| | | return aaChartModel; |
| | | } |
| | | |
| | | private void configureTheStyleForDifferentTypeChart(String chartType, int position) { |
| | | if ((chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Line)) |
| | | && (position == 4 || position == 5)) { |
| | | aaChartModel1 = BasicChartComposer.configureStepAreaChartAndStepLineChart(); |
| | | aaChartModel = BasicChartComposer.configureStepAreaChartAndStepLineChart(); |
| | | } else if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) { |
| | | |
| | | aaChartModel1 = BasicChartComposer.configureColumnChartAndBarChart(); |
| | | aaChartModel = BasicChartComposer.configureColumnChartAndBarChart(); |
| | | } else if (chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Areaspline)) { |
| | | aaChartModel1 = BasicChartComposer.configureAreaChartAndAreasplineChartStyle(chartType); |
| | | aaChartModel = BasicChartComposer.configureAreaChartAndAreasplineChartStyle(chartType); |
| | | } else if (chartType.equals(AAChartType.Line) || chartType.equals(AAChartType.Spline)) { |
| | | aaChartModel1 = BasicChartComposer.configureLineChartAndSplineChartStyle(chartType); |
| | | aaChartModel = BasicChartComposer.configureLineChartAndSplineChartStyle(chartType); |
| | | } |
| | | aaChartModel1.chartType = chartType; |
| | | aaChartModel.chartType = chartType; |
| | | } |
| | | |
| | | private AAChartModel configureTheAAChartModel(String chartType) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public enum TimeType { |
| | | day, |
| | | month, |
| | | year, |
| | | lifecycle |
| | | } |
| | | } |