From 705006fe0c1187ace53ee6505f71ba98fe4b44e6 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期五, 26 四月 2024 18:27:45 +0800 Subject: [PATCH] 2024年04月26日18:26:42 --- app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java | 250 ++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 200 insertions(+), 50 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java index 283afbf..d0474e4 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java @@ -53,10 +53,13 @@ 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; @@ -67,10 +70,13 @@ 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; @@ -90,12 +96,12 @@ FragmentHomePageBinding viewBinding; - AAChartView aaChartView1; + AAChartView aaChartView; - AAChartModel aaChartModel1; - AAChartView aaChartView2; + AAChartModel aaChartModel; - AAChartModel aaChartModel2; + + private TimeType timeType = TimeType.day;//鏃堕棿绫诲瀷(榛樿锛氬ぉ) @Override @@ -106,30 +112,169 @@ @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(); @@ -147,12 +292,12 @@ // 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))//鏍囬鏂囧瓧棰滆壊 @@ -163,54 +308,51 @@ .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鏂囧瓧锛宖alse鍒欐瘡椤筰tem鍏ㄩ儴閮藉甫鏈塴abel銆� .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) { @@ -344,4 +486,12 @@ } } } + + + public enum TimeType { + day, + month, + year, + lifecycle + } } \ No newline at end of file -- Gitblit v1.8.0