From b1303ee6ba15d8202f7fe95037267feaa4520fc5 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期日, 28 四月 2024 15:55:48 +0800 Subject: [PATCH] 2024年04月28日15:55:42 --- app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java | 368 ++++++++++++++---------------------- app/src/main/res/layout/fragment_home_page.xml | 69 +++++- app/src/main/res/values/strings.xml | 10 + app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java | 5 app/src/main/res/layout/item_data.xml | 10 app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java | 3 app/src/main/java/com/hdl/photovoltaic/utils/TimeUtils.java | 125 +++++++++++- app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 5 8 files changed, 327 insertions(+), 268 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java index d364f58..efd2bd2 100644 --- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java +++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java @@ -67,6 +67,11 @@ return sHdlDeviceLogic; } + public static final String kWp = "kWp"; + public static final String kWh = "kW.h"; + + public static final String kW = "kW"; + /** * 鑾峰彇褰撳墠浣忓畢鐨勯�嗗彉鍣ㄥ垪琛�(鍖呮嫭浠庣殑閫嗗彉鍣�) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java b/app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java index 8e0a8e1..306aa53 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/home/BasicChartComposer.java @@ -51,6 +51,11 @@ // .data(new Object[]{3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8}); return configureBasicOptions() + .backgroundColor("#EDEFF2") + .legendEnabled(false) + .markerRadius(0) +// .markerSymbol(AAChartSymbolType.Circle) +// .markerSymbolStyle(AAChartSymbolStyleType.Normal) .chartType(AAChartType.Area) .categories(new String[]{"涓�鏈�", "浜屾湀", "涓夋湀", "鍥涙湀", "浜旀湀", "鍏湀", "涓冩湀", "鍏湀", "涔濇湀", "鍗佹湀", "鍗佷竴鏈�", "鍗佷簩鏈�"}) .series(new AASeriesElement[]{element1}); diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java b/app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java index 035b4fd..041828a 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/home/CustomStyleChartComposer.java @@ -195,8 +195,7 @@ ); return new AAChartModel() .chartType(AAChartType.Column) - .title("Colorful Column Chart") - .subtitle("single data array colorful column chart") + .backgroundColor("#EDEFF2") .colorsTheme(new String[]{"#38C494",}) .categories(new String[]{"涓�鏈�", "浜屾湀", "涓夋湀", "鍥涙湀", "浜旀湀", "鍏湀", "涓冩湀", "鍏湀", "涔濇湀", "鍗佹湀", "鍗佷竴鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�", "鍗佷簩鏈�",}) 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 d0474e4..af3f440 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 @@ -1,63 +1,11 @@ package com.hdl.photovoltaic.ui.home; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.adjustYAxisMaxAndMinValues; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureAreaChartThreshold; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureChartWithShadowStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulChart; import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientAreaChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientColorChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientSplineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulShadowSplineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureDiscontinuousDataChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureGradientColorAreasplineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureHexagonRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureNightingaleRoseChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configurePentagonRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureQuadrangleRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureTriangleRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.connectNullsForSingleAASeriesElement; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customBarChartHoverColorAndSelectColor; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customChartHoverAndSelectHaloStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartMarkerSymbolContent; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customScatterChartMarkerSymbolContent; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.disableSplineChartMarkerHoverEffect; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.doubleLayerPieChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.drawLineChartWithPointsCoordinates; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.largeDataStackingColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.topRoundedCornersStackingColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.upsideDownPyramidChart; -import android.content.Intent; -import android.graphics.Color; import android.os.Bundle; -import android.provider.Settings; +import android.text.TextUtils; import android.view.View; -import android.view.ViewGroup; -import android.view.WindowManager; -import android.widget.Toast; import androidx.appcompat.content.res.AppCompatResources; @@ -67,15 +15,15 @@ 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.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.HdlDeviceLogic; import com.hdl.photovoltaic.other.HdlLogLogic; +import com.hdl.photovoltaic.other.HdlThreadLogic; import com.hdl.photovoltaic.utils.TimeUtils; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; @@ -86,7 +34,6 @@ import java.util.Calendar; import java.util.Date; -import io.dcloud.common.util.DensityUtils; /** * 棣栭〉妯″潡 @@ -116,6 +63,7 @@ initView(); //鍒濆鍖栫晫闈㈢洃鍚櫒 initEvent(); + } @@ -151,8 +99,9 @@ viewBinding.v3.setVisibility(View.VISIBLE); viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); - - setUpAAChartView(1); + String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); + viewBinding.yearMonthDayTv.setText(dataStr); + setUpAAChartView(); } }); @@ -177,8 +126,9 @@ viewBinding.v2.setVisibility(View.GONE); viewBinding.v3.setVisibility(View.VISIBLE); viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); - - setUpAAChartView(2); + String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); + viewBinding.yearMonthDayTv.setText(dataStr); + setUpAAChartView(); } @@ -204,8 +154,9 @@ viewBinding.v2.setVisibility(View.GONE); viewBinding.v3.setVisibility(View.GONE); viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); - - setUpAAChartView(2); + String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); + viewBinding.yearMonthDayTv.setText(dataStr); + setUpAAChartView(); } }); //鐢熷懡鏈� @@ -230,32 +181,65 @@ viewBinding.v3.setVisibility(View.GONE); viewBinding.homePageStationSelectTimeLl.setVisibility(View.GONE); - setUpAAChartView(2); + setUpAAChartView(); } }); //涓婁竴姝� - viewBinding.lastStepIv.setOnClickListener(new View.OnClickListener() { + viewBinding.lastStepClickLl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + if (TextUtils.isEmpty(currDate)) { + return; + } + String timeDateFormat = getTimeDateFormat(); + Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); + String time = TimeUtils.subtractDayMonthYearFromDate(calendar, 1, timeDateFormat, timeType); + viewBinding.yearMonthDayTv.setText(time); + } }); //涓嬩竴姝� - viewBinding.nextStepIv.setOnClickListener(new View.OnClickListener() { + viewBinding.nextStepClickLl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + if (TextUtils.isEmpty(currDate)) { + return; + } + String timeDateFormat = getTimeDateFormat(); + Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); + String time = TimeUtils.addDayMonthYearToDate(calendar, 1, timeDateFormat, timeType); + if (TimeUtils.stringDateToTimestamp(time, timeDateFormat) > getCurrentTimestamp()) { + HdlThreadLogic.toast(_mActivity, getString(R.string.the_query_date_is_exceeded)); + return; + } + viewBinding.yearMonthDayTv.setText(time); } }); } private void initView() { - String dataStr = TimeUtils.getDateTimestamp(System.currentTimeMillis(), TimeUtils.zhDateFormat); - if (!UserConfigManage.getInstance().isZh()) { - dataStr = TimeUtils.getDateTimestamp(System.currentTimeMillis(), TimeUtils.enDateFormat); - } + + String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); viewBinding.yearMonthDayTv.setText(dataStr); + + String installed_capacity = getString(R.string.installed_capacity) + "(" + HdlDeviceLogic.kWp + ")"; + viewBinding.homePageStationInfoRl1Text2Tv.setText(installed_capacity); + String generated_power = getString(R.string.generated_power) + "(" + HdlDeviceLogic.kW + ")"; + viewBinding.homePageStationInfoRl1Text4Tv.setText(generated_power); + String generation = getString(R.string.generation) + "(" + HdlDeviceLogic.kWp + ")"; + viewBinding.homePageStationInfoRl1TitleTv.setText(generation); + + viewBinding.homePageStationInfoRl2DayIc.dataTypeTv.setText(R.string.day_power_generation); + viewBinding.homePageStationInfoRl2MonIc.dataTypeTv.setText(R.string.month_power_generation); + viewBinding.homePageStationInfoRl2YearIc.dataTypeTv.setText(R.string.year_power_generation); + viewBinding.homePageStationInfoRl2CumulativeIc.dataTypeTv.setText(R.string.cumulative_power_generation); + + 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)); @@ -268,6 +252,7 @@ viewBinding.v2.setVisibility(View.VISIBLE); viewBinding.v3.setVisibility(View.VISIBLE); viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); + setUpAAChartView();//鍥捐〃鍔犺浇 } @@ -275,24 +260,34 @@ * 鏃堕棿閫夋嫨鍣� */ private void selectedTimePickerBuilder() { + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + if (TextUtils.isEmpty(currDate)) { + return; + } //鏃堕棿閫夋嫨鍣� - Calendar selectedDate = Calendar.getInstance(); + Calendar selectedDate = TimeUtils.stringToCalendar(currDate, getTimeDateFormat()); Calendar startDate = Calendar.getInstance(); - //startDate.set(2013,1,1); - Calendar endDate = Calendar.getInstance(); - //endDate.set(2020,1,1); - - //姝g‘璁剧疆鏂瑰紡 - startDate.set(2024, 1, 1); - endDate.set(2025, 4, 25); - + Calendar endDate = TimeUtils.timestampToCalendar(getCurrentTimestamp()); + //璁剧疆鏃ユ湡銆愬紑濮嬨�戝拰銆愮粨鏉熴�� + startDate.set(2023, 1, 1); + endDate.set(endDate.get(Calendar.YEAR), endDate.get(Calendar.MONTH), endDate.get(Calendar.DAY_OF_MONTH)); + boolean day = true; + boolean month = true; + boolean year = true; + if (timeType == TimeType.month) { + day = false; + } else if (timeType == TimeType.year) { + day = false; + month = false; + } TimePickerView pvTime = new TimePickerBuilder(_mActivity, new OnTimeSelectListener() { @Override public void onTimeSelect(Date date, View v) {//閫変腑浜嬩欢鍥炶皟 -// tvTime.setText(getTime(date)); + String timeDateFormat = getTimeDateFormat(); + String time = TimeUtils.dateToString(date, timeDateFormat); + viewBinding.yearMonthDayTv.setText(time); } - }) - .setType(new boolean[]{true, true, true, false, false, false})// 榛樿鍏ㄩ儴鏄剧ず + }).setType(new boolean[]{year, month, day, false, false, false})// 榛樿鍏ㄩ儴鏄剧ず .setCancelText(_mActivity.getString(R.string.loading_cancel))//鍙栨秷鎸夐挳鏂囧瓧 .setSubmitText(_mActivity.getString(R.string.loading_affirm))//纭鎸夐挳鏂囧瓧 .setContentTextSize(18)//婊氳疆鏂囧瓧澶у皬 @@ -305,159 +300,33 @@ .setCancelColor(_mActivity.getColor(R.color.text_40000000))//鍙栨秷鎸夐挳鏂囧瓧棰滆壊 .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_90000000)).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.succeed))//榛樿璁剧疆涓哄勾鏈堟棩鏃跺垎绉� + .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鏂囧瓧锛宖alse鍒欐瘡椤筰tem鍏ㄩ儴閮藉甫鏈塴abel銆� .isDialog(false)//鏄惁鏄剧ず涓哄璇濇鏍峰紡 .setItemVisibleCount(7)//瀵硅瘽妗嗛珮搴� - .setDividerColor(_mActivity.getColor(R.color.text_E1E1E1)) - .setLineSpacingMultiplier(3f)// + .setDividerColor(_mActivity.getColor(R.color.text_E1E1E1)).setLineSpacingMultiplier(3f)// .build(); pvTime.show(); } - private void setUpAAChartView(int value) { - if (value == 1) { - aaChartView = viewBinding.AAChartView; - aaChartView.callBack = this; - aaChartModel = configureAAChartModel(); - aaChartView.aa_drawChartWithChartModel(aaChartModel); - } else if (value == 2) { - aaChartView = viewBinding.AAChartView; - aaChartView.callBack = this; - aaChartModel = configureColorfulColumnChart();// configureTheAAChartModel("colorfulColumnChart"); - aaChartView.aa_drawChartWithChartModel(aaChartModel); + /** + * 鍥捐〃鍔犺浇 + */ + private void setUpAAChartView() { + aaChartView = viewBinding.AAChartView; + aaChartView.callBack = this; + if (TimeType.day == timeType) { + aaChartModel = BasicChartComposer.configureAreaChart(); + } else if (TimeType.month == timeType + || TimeType.year == timeType + || TimeType.lifecycle == timeType) { + aaChartModel = configureColorfulColumnChart(); } + aaChartView.aa_drawChartWithChartModel(aaChartModel); } - private AAChartModel configureAAChartModel() { - String chartType = AAChartType.Area; - int position = 0; - aaChartModel = BasicChartComposer.configureAreaChart(); - configureTheStyleForDifferentTypeChart(chartType, position); - 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; - } - - private AAChartModel configureTheAAChartModel(String chartType) { - switch (chartType) { - case "colorfulChart": - return configureColorfulChart(); - case "gradientColorfulChart": - return configureColorfulGradientColorChart(); - case "discontinuousDataChart": - return configureDiscontinuousDataChart(); - case "colorfulColumnChart": - return configureColorfulColumnChart(); - case "nightingaleRoseChart": - return configureNightingaleRoseChart(); - case "chartWithShadowStyle": - return configureChartWithShadowStyle(); - case "colorfulGradientAreaChart": - return configureColorfulGradientAreaChart(); - case "colorfulGradientSplineChart": - return configureColorfulGradientSplineChart(); - case "gradientColorAreasplineChart": - return configureGradientColorAreasplineChart(); - case "SpecialStyleMarkerOfSingleDataElementChart": - return configureSpecialStyleMarkerOfSingleDataElementChart(); - case "SpecialStyleColumnOfSingleDataElementChart": - return configureSpecialStyleColumnOfSingleDataElementChart(); - case "AreaChartThreshold": - return configureAreaChartThreshold(); - case "customScatterChartMarkerSymbolContent": - return customScatterChartMarkerSymbolContent(); - case "customLineChartMarkerSymbolContent": - return customLineChartMarkerSymbolContent(); - case "TriangleRadarChart": - return configureTriangleRadarChart(); - case "QuadrangleRadarChart": - return configureQuadrangleRadarChart(); - case "PentagonRadarChart": - return configurePentagonRadarChart(); - case "HexagonRadarChart": - return configureHexagonRadarChart(); - case "adjustYAxisMaxAndMinValues": - return adjustYAxisMaxAndMinValues(); - case "customSpecialStyleDataLabelOfSingleDataElementChart": - return customSpecialStyleDataLabelOfSingleDataElementChart(); - case "customBarChartHoverColorAndSelectColor": - return customBarChartHoverColorAndSelectColor(); - case "customChartHoverAndSelectHaloStyle": - return customChartHoverAndSelectHaloStyle(); - case "customSplineChartMarkerStatesHoverStyle": - return customSplineChartMarkerStatesHoverStyle(); - case "splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle": - return splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(); - case "customNormalStackingChartDataLabelsContentAndStyle": - return customNormalStackingChartDataLabelsContentAndStyle(); - case "upsideDownPyramidChart": - return upsideDownPyramidChart(); - case "doubleLayerPieChart": - return doubleLayerPieChart(); - case "disableSomeOfLinesMouseTrackingEffect": - return disableSomeOfLinesMouseTrackingEffect(); - case "configureColorfulShadowSplineChart": - return configureColorfulShadowSplineChart(); - case "configureColorfulDataLabelsStepLineChart": - return configureColorfulDataLabelsStepLineChart(); - case "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart": - return configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(); - case "disableSplineChartMarkerHoverEffect": - return disableSplineChartMarkerHoverEffect(); - case "configureMaxAndMinDataLabelsForChart": - return configureMaxAndMinDataLabelsForChart(); - case "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag": - return customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(); - case "noMoreGroupingAndOverlapEachOtherColumnChart": - return noMoreGroupingAndOverlapEachOtherColumnChart(); - case "noMoreGroupingAndNestedColumnChart": - return noMoreGroupingAndNestedColumnChart(); - case "topRoundedCornersStackingColumnChart": - return topRoundedCornersStackingColumnChart(); - case "freeStyleRoundedCornersStackingColumnChart": - return freeStyleRoundedCornersStackingColumnChart(); - case "customColumnChartBorderStyleAndStatesHoverColor": - return customColumnChartBorderStyleAndStatesHoverColor(); - case "customLineChartWithColorfulMarkersAndLines": - return customLineChartWithColorfulMarkersAndLines(); - case "customLineChartWithColorfulMarkersAndLines2": - return customLineChartWithColorfulMarkersAndLines2(); - case "drawLineChartWithPointsCoordinates": - return drawLineChartWithPointsCoordinates(); - case "configureSpecialStyleColumnForNegativeDataMixedPositiveData": - return configureSpecialStyleColumnForNegativeDataMixedPositiveData(); - case "configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart": - return configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(); - case "connectNullsForSingleAASeriesElement": - return connectNullsForSingleAASeriesElement(); - case "lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement": - return lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(); - case "customAreasplineChartWithColorfulGradientColorZones": - return customAreasplineChartWithColorfulGradientColorZones(); - case "largeDataStackingColumnChart": - return largeDataStackingColumnChart(); - - - } - return configureColorfulChart(); - } @Override public void chartViewDidFinishLoad(AAChartView aaChartView) { @@ -488,10 +357,53 @@ } - public enum TimeType { - day, - month, - year, - lifecycle + /** + * 鑾峰彇褰撳墠绯荤粺鏃ユ湡鏃堕棿鎴� + * + * @return 鏃堕棿鎴� + */ + private long getCurrentTimestamp() { + return new Date().getTime(); } + + /** + * 鑾峰彇鏃ユ湡鏍煎紡 (2024/2/09,yyyy/DD/dd) + * + * @return 鏃ユ湡鏍煎紡 (2024/2/09,yyyy/DD/dd) + */ + private String getTimeDateFormat() { + String timeDateFormat = TimeUtils.zhDateYearMonthDayFormat; + switch (timeType) { + case day: { + timeDateFormat = TimeUtils.zhDateYearMonthDayFormat; + if (!UserConfigManage.getInstance().isZh()) { + timeDateFormat = TimeUtils.enDateYearMonthDayFormat; + } + } + break; + case month: { + timeDateFormat = TimeUtils.zhDateYearMonthFormat; + if (!UserConfigManage.getInstance().isZh()) { + timeDateFormat = TimeUtils.enDateYearMonthFormat; + } + } + break; + case year: + case lifecycle: { + timeDateFormat = TimeUtils.zhDateYearFormat; + if (!UserConfigManage.getInstance().isZh()) { + timeDateFormat = TimeUtils.enDateYearFormat; + } + } + break; + + } + return timeDateFormat; + } + + public enum TimeType { + day, month, year, lifecycle + } + + } \ No newline at end of file diff --git a/app/src/main/java/com/hdl/photovoltaic/utils/TimeUtils.java b/app/src/main/java/com/hdl/photovoltaic/utils/TimeUtils.java index 2e9aed4..899010f 100644 --- a/app/src/main/java/com/hdl/photovoltaic/utils/TimeUtils.java +++ b/app/src/main/java/com/hdl/photovoltaic/utils/TimeUtils.java @@ -1,9 +1,11 @@ package com.hdl.photovoltaic.utils; import android.annotation.SuppressLint; +import android.text.TextUtils; import com.hdl.photovoltaic.config.UserConfigManage; import com.hdl.photovoltaic.other.HdlThreadLogic; +import com.hdl.photovoltaic.ui.home.HomePageFragment; import com.hdl.sdk.link.core.utils.LanguageUtils; import java.text.SimpleDateFormat; @@ -16,8 +18,13 @@ */ public class TimeUtils { - public static final String zhDateFormat = "yyyy/MM/dd"; - public static final String enDateFormat = "dd/MM/yyyy"; + public static final String zhDateYearMonthDayFormat = "yyyy/MM/dd"; + public static final String zhDateYearMonthFormat = "yyyy/MM"; + public static final String zhDateYearFormat = "yyyy"; + + public static final String enDateYearMonthDayFormat = "dd/MM/yyyy"; + public static final String enDateYearMonthFormat = "/MM/yyyy"; + public static final String enDateYearFormat = "yyyy"; /** * 鑾峰彇鍒嗛挓 @@ -40,7 +47,7 @@ * 鏃堕棿鎴宠浆鏃堕棿(鏍煎紡:yyyy-MM-dd) * * @param timestamp 鏃堕棿鎴� - * @param date_format 鏃堕棿鏍煎紡(渚嬪"yyyy-MM-dd") + * @param date_format 鏃堕棿鏍煎紡(渚嬪"yyyy/MM/dd") * @return - */ public static String getDateTimestamp(long timestamp, String date_format) { @@ -100,30 +107,118 @@ } /** - * 鍔犲ぉ鏁� + * 鍔狅紙鏃ワ紝鏈堬紝骞达級璁$畻 * - * @param date 鏃ュ巻 - * @param daysToAdd 澶╂暟 + * @param date 鏃ュ巻 + * @param dayMonthYearToAdd 澶╂暟锛堟棩锛屾湀锛屽勾锛� * @return 鏃ュ巻 */ - public static Calendar addDaysToDate(Calendar date, int daysToAdd) { + public static String addDayMonthYearToDate(Calendar date, int dayMonthYearToAdd, String dateFormat, HomePageFragment.TimeType timeType) { Calendar newDate = (Calendar) date.clone(); - newDate.add(Calendar.DAY_OF_MONTH, daysToAdd); - return newDate; + if (timeType == HomePageFragment.TimeType.day) { + newDate.add(Calendar.DAY_OF_MONTH, dayMonthYearToAdd); + } else if (timeType == HomePageFragment.TimeType.month) { + newDate.add(Calendar.MONTH, dayMonthYearToAdd); + } else if (timeType == HomePageFragment.TimeType.year || timeType == HomePageFragment.TimeType.lifecycle) { + newDate.add(Calendar.YEAR, dayMonthYearToAdd); + } + return calendarToString(newDate, dateFormat); } /** - * 鍑忓ぉ鏁� + * 鍑忥紙鏃ワ紝鏈堬紝骞达級璁$畻 * - * @param date 鏃ュ巻 - * @param daysToSubtract 澶╂暟 + * @param date 鏃ュ巻 + * @param dayMonthYearToSubtract 澶╂暟 * @return 鏃ュ巻 */ - public static Calendar subtractDaysFromDate(Calendar date, int daysToSubtract) { + public static String subtractDayMonthYearFromDate(Calendar date, int dayMonthYearToSubtract, String dateFormat, HomePageFragment.TimeType timeType) { Calendar newDate = (Calendar) date.clone(); - newDate.add(Calendar.DAY_OF_MONTH, -daysToSubtract); - return newDate; + if (timeType == HomePageFragment.TimeType.day) { + newDate.add(Calendar.DAY_OF_MONTH, -dayMonthYearToSubtract); + } else if (timeType == HomePageFragment.TimeType.month) { + newDate.add(Calendar.MONTH, -dayMonthYearToSubtract); + } else if (timeType == HomePageFragment.TimeType.year) { + newDate.add(Calendar.YEAR, -dayMonthYearToSubtract); + } + return calendarToString(newDate, dateFormat); } + /** + * 鏃堕棿鎴宠浆Calendar + * + * @param timestamp 鏃堕棿鎴� + * @return Calendar瀵硅薄 + */ + public static Calendar timestampToCalendar(long timestamp) { + // 灏嗘椂闂存埑杞崲涓烘棩鏈� + Date date = new Date(timestamp); + // 浣跨敤Calendar绫昏缃棩鏈� + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + return calendar; + } + + /** + * 瀛楃涓叉棩鏈熸牸寮忚浆Calendar + * + * @param dateString (2023/04/01) + * @param dateFormat (yyyy/MM/dd) + * @return Calendar瀵硅薄 + */ + public static Calendar stringToCalendar(String dateString, String dateFormat) { + SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, Locale.ENGLISH); + Calendar calendar = Calendar.getInstance(); + try { + Date date = sdf.parse(dateString); + if (date != null) { + calendar.setTime(date); + } + } catch (Exception ignored) { + } + return calendar; + } + + /** + * Calendar杞瓧绗︿覆鏃ユ湡鏍煎紡 + * + * @param dateFormat (yyyy/MM/dd) + * @return Calendar瀵硅薄 + */ + public static String calendarToString(Calendar calendar, String dateFormat) { + SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, Locale.ENGLISH); + return sdf.format(calendar.getTime()); + } + + /** + * Date杞瓧绗︿覆鏃ユ湡鏍煎紡 + * + * @param dateFormat (yyyy/MM/dd) + * @return Calendar瀵硅薄 + */ + public static String dateToString(Date date, String dateFormat) { + SimpleDateFormat sdf = new SimpleDateFormat(dateFormat, Locale.ENGLISH); + return sdf.format(date.getTime()); + } + + /** + * 瀛楃涓叉棩鏈熸牸寮忚浆鏃堕棿鎴� + * + * @param dateString (2024/06/01) + * @param dateFormat (yyyy/MM/dd) + * @return 鏃堕棿鎴� + */ + public static long stringDateToTimestamp(String dateString, String dateFormat) { + try { + SimpleDateFormat slf = new SimpleDateFormat(dateFormat, Locale.getDefault()); + Date date = slf.parse(dateString); + if (date == null) { + return 0; + } + return date.getTime(); // 鑾峰彇鏃堕棿鎴� + } catch (Exception ignored) { + } + return 0; + } } diff --git a/app/src/main/res/layout/fragment_home_page.xml b/app/src/main/res/layout/fragment_home_page.xml index dc4f322..d500e94 100644 --- a/app/src/main/res/layout/fragment_home_page.xml +++ b/app/src/main/res/layout/fragment_home_page.xml @@ -148,7 +148,7 @@ android:layout_below="@+id/home_page_station_info_rl1_text1_tv" android:layout_alignStart="@+id/home_page_station_info_rl1_text1_tv" android:layout_marginTop="3dp" - android:text="kw.h" /> + android:text="@string/installed_capacity" /> <TextView android:id="@+id/home_page_station_info_rl1_text3_tv" @@ -168,7 +168,7 @@ android:layout_below="@+id/home_page_station_info_rl1_text3_tv" android:layout_alignStart="@+id/home_page_station_info_rl1_text1_tv" android:layout_marginTop="3dp" - android:text="kw.h" /> + android:text="@string/generated_power" /> </RelativeLayout> @@ -194,7 +194,7 @@ android:layout_height="14.5dp" android:layout_marginStart="@dimen/dp_47" android:layout_marginTop="17dp" - android:text="Electricity /kw.h" + android:text="@string/generation" android:textColor="@color/text_191919" android:textSize="@dimen/text_12" /> @@ -260,7 +260,7 @@ android:layout_width="wrap_content" android:layout_height="18dp" android:layout_marginTop="@dimen/dp_25" - android:text="鐐瑰嚮娴嬭瘯" + android:text="@string/energy_generation_statistics" android:textColor="@color/text_90000000" android:textSize="@dimen/text_14" android:textStyle="bold" @@ -340,16 +340,31 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/home_page_station_select_time_type_ll"> + <!--鍔犲ぇ鐐瑰嚮鐑尯--> + <LinearLayout + android:id="@+id/last_step_click_ll" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal"> - <ImageView - android:id="@+id/last_step_iv" - android:layout_width="9dp" - android:layout_height="15dp" - android:scaleType="fitCenter" - android:src="@drawable/last_step" /> + <View + android:layout_width="@dimen/dp_16" + android:layout_height="match_parent" /> + + <ImageView + android:id="@+id/last_step_iv" + android:layout_width="9dp" + android:layout_height="15dp" + android:scaleType="fitCenter" + android:src="@drawable/last_step" /> + + <View + android:layout_width="@dimen/dp_16" + android:layout_height="match_parent" /> + </LinearLayout> <View - android:layout_width="@dimen/dp_32" + android:layout_width="@dimen/dp_16" android:layout_height="match_parent" /> @@ -364,15 +379,31 @@ android:textStyle="bold" /> <View - android:layout_width="@dimen/dp_32" + android:layout_width="@dimen/dp_16" android:layout_height="match_parent" /> + <!--鍔犲ぇ鐐瑰嚮鐑尯--> + <LinearLayout + android:id="@+id/next_step_click_ll" + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:orientation="horizontal"> - <ImageView - android:id="@+id/next_step_iv" - android:layout_width="9dp" - android:layout_height="15dp" - android:scaleType="fitCenter" - android:src="@drawable/next_step" /> + <View + android:layout_width="@dimen/dp_16" + android:layout_height="match_parent" /> + + <ImageView + android:id="@+id/next_step_iv" + android:layout_width="9dp" + android:layout_height="15dp" + android:scaleType="fitCenter" + android:src="@drawable/next_step" /> + + <View + android:layout_width="@dimen/dp_16" + android:layout_height="match_parent" /> + + </LinearLayout> </LinearLayout> @@ -437,7 +468,7 @@ android:id="@+id/social_contribution_title_tv" android:layout_width="wrap_content" android:layout_height="17dp" - android:text="Social Contribution" + android:text="@string/social_contribution" android:textColor="@color/text_90000000" android:textSize="@dimen/text_14" android:textStyle="bold" diff --git a/app/src/main/res/layout/item_data.xml b/app/src/main/res/layout/item_data.xml index 9c4c3ba..7579de8 100644 --- a/app/src/main/res/layout/item_data.xml +++ b/app/src/main/res/layout/item_data.xml @@ -6,21 +6,23 @@ <TextView android:id="@+id/data_tv" - style="@style/Text20Style" android:layout_width="wrap_content" android:layout_height="@dimen/dp_24" - android:text="33333" + android:textColor="@color/text_90000000" + android:textSize="@dimen/text_20" + android:textStyle="bold" + android:text="33" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> <TextView android:id="@+id/data_type_tv" - style="@style/Text14Style" android:layout_width="wrap_content" android:layout_height="@dimen/dp_17" android:layout_marginTop="3dp" - android:text="kw.h" + android:textColor="@color/text_40000000" + android:textSize="@dimen/text_14" app:layout_constraintEnd_toEndOf="@+id/data_tv" app:layout_constraintStart_toStartOf="@+id/data_tv" app:layout_constraintTop_toBottomOf="@+id/data_tv" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 43d90dd..1c28425 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -255,5 +255,15 @@ <string name="hour">鏃�</string> <string name="minutc">鍒�</string> <string name="seconds">绉�</string> + <string name="the_query_date_is_exceeded">瓒呭嚭鏌ヨ鏃ユ湡.</string> + <string name="energy_generation_statistics">鍙戠數閲忕粺璁�</string> + <string name="social_contribution">绀句細璐$尞</string> + <string name="day_power_generation">褰撴棩鍙戠數閲�</string> + <string name="month_power_generation">褰撴湀鍙戠數閲�</string> + <string name="year_power_generation">褰撳勾鍙戠數閲�</string> + <string name="cumulative_power_generation">绱鍙戠數閲�</string> + <string name="generated_power">鍙戠數鍔熺巼</string> + <string name="installed_capacity">瑁呮満瀹归噺</string> + <string name="generation">鍙戠數閲�</string> </resources> \ No newline at end of file -- Gitblit v1.8.0