app/src/main/java/com/hdl/photovoltaic/base/BaseDialog.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/java/com/hdl/photovoltaic/widget/DefaultFilteringDialog.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/layout/dialog_default_filtering.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/values/strings.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
app/src/main/res/values/styles.xml | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
app/src/main/java/com/hdl/photovoltaic/base/BaseDialog.java
@@ -1,5 +1,6 @@ package com.hdl.photovoltaic.base; import android.app.Activity; import android.app.Dialog; import android.content.Context; import android.graphics.Color; @@ -8,6 +9,7 @@ import androidx.annotation.NonNull; import com.hdl.photovoltaic.R; import com.jaeger.library.StatusBarUtil; public class BaseDialog extends Dialog { @@ -20,6 +22,7 @@ setNotificationBarBackgroundColor(CustomColor.white); } /** * 修改状态栏字体颜色(黑色) */ app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -344,21 +344,59 @@ /** * 获取住宅(电站)ID列表 * * @param key 发电功率排序(powerSort); * 今日发电量排序(todayElectricitySort); * 创建时间排序(createTimeSort); * @param keyValue (descending:降序 * ascending:升序), * @param pageNo 页码 * @param pageSize 页数(一页多少数据) * @param key 发电功率排序(powerSort); * 今日发电量排序(todayElectricitySort); * 创建时间排序(createTimeSort); * @param keyValue (descending:降序 * ascending:升序), * @param installedCapacityMin 最小组串容量(装机容量) * @param installedCapacityMax 最大组串容量(装机容量) * @param gridType 并网状态 (全部 :"";FULL_GRID : 并网;OFFLINE :离网) * @param powerStationStatus 电站状态 (全部 :"";1 : 正常;2 : 离线; 3 : 待接入;4 : 故障) * @param pageNo 页码 * @param pageSize 页数(一页多少数据) */ public void getResidenceIdList(String key, String keyValue, long pageNo, long pageSize, CloudCallBeak<HouseBeanClass> cloudCallBeak) { public void getResidenceIdList( String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String gridType, String powerStationStatus, long pageNo, long pageSize, CloudCallBeak<HouseBeanClass> cloudCallBeak) { String requestUrl = HttpApi.POST_PowerStation_List; JsonObject json = new JsonObject(); if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(keyValue)) { json.addProperty(key, keyValue);//发电功率排序(descending:降序ascending:升序) } if (!TextUtils.isEmpty(installedCapacityMin)) { try { int value = Integer.parseInt(installedCapacityMin);//可能有异常,用户输入值超时int最大致导致的 json.addProperty("installedCapacityMin", value); } catch (Exception ignored) { } } if (!TextUtils.isEmpty(installedCapacityMax)) { try { int value = Integer.parseInt(installedCapacityMax);//可能有异常,用户输入值超时int最大致导致的 json.addProperty("installedCapacityMax", value); } catch (Exception ignored) { } } if (!TextUtils.isEmpty(gridType)) { try { json.addProperty("gridType", gridType); } catch (Exception ignored) { } } if (!TextUtils.isEmpty(powerStationStatus)) { try { int value = Integer.parseInt(powerStationStatus); json.addProperty("powerStationStatus", value); } catch (Exception ignored) { } } // json.addProperty("zoneType", "password");//区域 json.addProperty("pageNo", pageNo);//页码 json.addProperty("pageSize", pageSize);//页数 app/src/main/java/com/hdl/photovoltaic/ui/message/MessageInfoActivity.java
@@ -125,18 +125,20 @@ } //未处理 if (mMessageBean.getStatus().equals(MessageStateType.untreated)) { BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(ConstantManage.message_function_push_post); //改变缓存状态 if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) { HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated); BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(ConstantManage.message_function_push_post); baseEventBus.setType(MessageStateType.untreated); EventBus.getDefault().post(baseEventBus); } else { //除“故障”外,其他等级信息“已读”后,自动移出“发生中”列表并加入“历史记录”列表 HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed); baseEventBus.setType(MessageStateType.processed); sendEventBus(); } EventBus.getDefault().post(baseEventBus); } finish(); } @@ -151,18 +153,18 @@ } //未处理 if (mMessageBean.getStatus().equals(MessageStateType.untreated)) { BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(ConstantManage.message_function_push_post); //改变缓存状态 if (mMessageBean.getType().equals(MessageAlarmStateType.fault)) { HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.untreated); BaseEventBus baseEventBus = new BaseEventBus(); baseEventBus.setTopic(ConstantManage.message_function_push_post); baseEventBus.setType(MessageStateType.untreated); EventBus.getDefault().post(baseEventBus); } else { //除“故障”外,其他等级信息“已读”后,自动移出“发生中”列表并加入“历史记录”列表 HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed); baseEventBus.setType(MessageStateType.processed); sendEventBus(); } EventBus.getDefault().post(baseEventBus); } finish(); } @@ -181,17 +183,7 @@ //未处理 if (mMessageBean.getStatus().equals(MessageStateType.untreated)) { HdlMessageLogic.getInstance().setMessageState(mMessageBean.getMsgId(), true, MessageStateType.processed); //通知已处理要更新数据 BaseEventBus processedBus = new BaseEventBus(); processedBus.setTopic(ConstantManage.message_function_push_post); processedBus.setType(MessageStateType.processed); EventBus.getDefault().post(processedBus); //通知未处理要更新数据 BaseEventBus untreatedBus = new BaseEventBus(); untreatedBus.setTopic(ConstantManage.message_function_push_post); untreatedBus.setType(MessageStateType.untreated); EventBus.getDefault().post(untreatedBus); sendEventBus(); } finish(); @@ -210,6 +202,22 @@ } /** * 通知出去外面更新数据 */ private void sendEventBus() { //通知已处理要更新数据 BaseEventBus processedBus = new BaseEventBus(); processedBus.setTopic(ConstantManage.message_function_push_post); processedBus.setType(MessageStateType.processed); EventBus.getDefault().post(processedBus); //通知未处理要更新数据 BaseEventBus untreatedBus = new BaseEventBus(); untreatedBus.setTopic(ConstantManage.message_function_push_post); untreatedBus.setType(MessageStateType.untreated); EventBus.getDefault().post(untreatedBus); } private void initView() { app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseListFragment.java
@@ -36,6 +36,7 @@ import com.hdl.photovoltaic.ui.bean.HouseIdBean; import com.hdl.photovoltaic.uni.HDLUniMP; import com.hdl.photovoltaic.utils.PermissionUtils; import com.hdl.photovoltaic.widget.DefaultFilteringDialog; import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog; import com.hdl.sdk.link.common.exception.HDLLinkException; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; @@ -70,16 +71,10 @@ private String key = SortValue.all; private String value = SortValue.all;//descending:降序,ascending:升序 private String installedCapacityMinKey = SortType.installedCapacityMin; private int installedCapacityMinValue;//最小组串容量(装机容量) private String installedCapacityMaxKey = SortType.installedCapacityMax; private int installedCapacityMaxValue;//最大组串容量(装机容量) private String gridTypeKey = SortType.gridType; private String gridTypeValue;//并网状态(全部 不传该过滤参数,FULL_GRID:并网,OFFLINE:离网) private String powerStationStatusKey = SortType.powerStationStatus; private int powerStationStatusValue;//电站状态(全部 不传该过滤参数,1:正常(运行),2:离线,3:待接入,4:故障) private String installedCapacityMinValue = "";//最小组串容量(装机容量) private String installedCapacityMaxValue = "";//最大组串容量(装机容量) private String gridTypeValue = "";//并网状态(全部 不传该过滤参数,FULL_GRID:并网,OFFLINE:离网) private String powerStationStatusValue = "";//电站状态(全部 不传该过滤参数,1:正常(运行),2:离线,3:待接入,4:故障) private final long pageSize = 20;//页数 @@ -113,7 +108,7 @@ viewBinding.deviceLabel.setTextAppearance(R.style.Text16Style); viewBinding.powerStationLabelParent.setVisibility(View.VISIBLE); viewBinding.deviceLabelParent.setVisibility(View.GONE);//设备标签隐藏 loadNextPageHouseList(true, 1, true); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); } }); //设备标签 @@ -142,7 +137,7 @@ } }); //电站添搜索 //电站搜索 viewBinding.powerStationSearchClickCl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { @@ -151,6 +146,25 @@ startActivity(intent); } }); //默认选择参数图标 viewBinding.powerStationDefaultConditionIv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { DefaultFilteringDialog defaultFilteringDialog = new DefaultFilteringDialog(_mActivity); defaultFilteringDialog.show(); defaultFilteringDialog.initState(installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue); defaultFilteringDialog.setOnClickListener(new DefaultFilteringDialog.OnClickListener() { @Override public void confirm(String min, String max, String state) { installedCapacityMinValue = min;//最小组串容量(装机容量) installedCapacityMaxValue = max;//最大组串容量(装机容量) gridTypeValue = state;//并网状态(全部 不传该过滤参数,FULL_GRID:并网,OFFLINE:离网) loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); } }); } }); //电站设置下拉箭头颜色 viewBinding.fragmentHouseSrl.setColorSchemeResources(R.color.text_FF245EC3); //电站下拉读取 @@ -158,7 +172,7 @@ @Override public void onRefresh() { viewBinding.fragmentHouseSrl.setRefreshing(false); loadNextPageHouseList(true, 1, true); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); } }); //电站上拉读取 @@ -178,7 +192,7 @@ if (!isHouseLoadingMore) { // 滑动到了底部,执行相应的操作 HdlLogLogic.print("--->滑动到了底部"); loadNextPageHouseList(false, ++currentHouseListPage, false); loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, ++currentHouseListPage, false); } } } @@ -421,7 +435,7 @@ if (HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL.equals(eventBus.getTopic())) { if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) { //uin创建电站成功后通知 loadNextPageHouseList(false, 1, true); loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); if (eventBus.getData() != null) { Gson gson = new Gson(); String json = eventBus.getData().toString(); @@ -460,7 +474,7 @@ if (MqttRecvClient.getInstance() != null) { MqttRecvClient.getInstance().removeAllTopic(); } loadNextPageHouseList(false, 1, true); loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) { //进去住宅详情uni读取逆变器列表成功后通知 @@ -475,7 +489,7 @@ //接收外部点击事件 if (eventBus.getType().equals(HomepageTitleTabSwitch.powerstation.toString())) { HdlLogLogic.print("正在点击【电站】"); loadNextPageHouseList(true, 1, true); loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true); } } } @@ -484,9 +498,28 @@ /** * 刷新UI(电站) * * @param isRefreshing 表示是下拉刷新的 * @param isRefreshing 表示是下拉刷新的 * @param key 发电功率排序(powerSort); * 今日发电量排序(todayElectricitySort); * 创建时间排序(createTimeSort); * @param keyValue (descending:降序 * ascending:升序), * @param installedCapacityMin 最小组串容量(装机容量) * @param installedCapacityMax 最大组串容量(装机容量) * @param gridType 并网状态 (全部 :"";FULL_GRID : 并网;OFFLINE :离网) * @param powerStationStatus 电站状态 (全部 :"";1 : 正常;2 : 离线; 3 : 待接入;4 : 故障) * @param pageNo 页码 * @param isClear 是否清除数据 */ private void loadNextPageHouseList(boolean isRefreshing, long pageNo, boolean isClear) { private void loadNextPageHouseList(boolean isRefreshing, String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String gridType, String powerStationStatus, long pageNo, boolean isClear) { if (isClear) { clearData(); } @@ -502,50 +535,57 @@ } //获取住宅(电站)ID列表 HdlResidenceLogic.getInstance().getResidenceIdList(key, value, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() { @Override public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) { HdlThreadLogic.runMainThread(new Runnable() { HdlResidenceLogic.getInstance().getResidenceIdList( key, keyValue, installedCapacityMin, installedCapacityMax, gridType, powerStationStatus, pageNo, pageSize, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() { @Override public void run() { if (isRefreshing) { hideLoading(); } isHouseLoadingMore = false; if (houseBeanClass != null) { currentHouseListTotal = (int) houseBeanClass.getTotalPage(); currentHouseListPage = (int) houseBeanClass.getPageNo(); //更新缓存 HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList()); if (houseInfoAdapter != null) { initData(); //更新UI houseInfoAdapter.setList(houseListBeanIDList); public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { if (isRefreshing) { hideLoading(); } isHouseLoadingMore = false; if (houseBeanClass != null) { currentHouseListTotal = (int) houseBeanClass.getTotalPage(); currentHouseListPage = (int) houseBeanClass.getPageNo(); //更新缓存 HdlResidenceLogic.getInstance().setHouseIdList(houseBeanClass.getList()); if (houseInfoAdapter != null) { initData(); //更新UI houseInfoAdapter.setList(houseListBeanIDList); } } nullDataUpdateUi(); } } nullDataUpdateUi(); }, _mActivity, ShowErrorMode.YES); } }, _mActivity, ShowErrorMode.YES); } @Override public void onFailure(HDLException e) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { if (currentHouseListPage > 1) { --currentHouseListPage; } isHouseLoadingMore = false; if (isRefreshing) { hideLoading(); } public void onFailure(HDLException e) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { if (currentHouseListPage > 1) { --currentHouseListPage; } isHouseLoadingMore = false; if (isRefreshing) { hideLoading(); } } }, _mActivity, ShowErrorMode.YES); } }, _mActivity, ShowErrorMode.YES); } }); }); } /** app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseSearchActivity.java
@@ -270,49 +270,51 @@ } //获取住宅(电站)ID列表 HdlResidenceLogic.getInstance().getResidenceIdList(SortType.homeName, currSearchText, pageNo, 20, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() { @Override public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) { HdlThreadLogic.runMainThread(new Runnable() { HdlResidenceLogic.getInstance().getResidenceIdList(SortType.homeName, currSearchText, "", "", "", "", pageNo, 20, new CloudCallBeak<HdlResidenceLogic.HouseBeanClass>() { @Override public void run() { if (isRefreshing) { hideLoading(); } isHouseLoadingMore = false; if (houseBeanClass != null) { currentHouseListTotal = (int) houseBeanClass.getTotalPage(); currentHouseListPage = (int) houseBeanClass.getPageNo(); //更新缓存 setHouseIdList(houseBeanClass.getList()); if (searchHouseAdapter != null) { initData(); //更新UI searchHouseAdapter.setList(houseListBeanIDList); public void onSuccess(HdlResidenceLogic.HouseBeanClass houseBeanClass) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { if (isRefreshing) { hideLoading(); } isHouseLoadingMore = false; if (houseBeanClass != null) { currentHouseListTotal = (int) houseBeanClass.getTotalPage(); currentHouseListPage = (int) houseBeanClass.getPageNo(); //更新缓存 setHouseIdList(houseBeanClass.getList()); if (searchHouseAdapter != null) { initData(); //更新UI searchHouseAdapter.setList(houseListBeanIDList); } } } } }, _mActivity, ShowErrorMode.YES); } }, _mActivity, ShowErrorMode.YES); } @Override public void onFailure(HDLException e) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { if (currentHouseListPage > 1) { --currentHouseListPage; } isHouseLoadingMore = false; if (isRefreshing) { hideLoading(); } public void onFailure(HDLException e) { HdlThreadLogic.runMainThread(new Runnable() { @Override public void run() { if (currentHouseListPage > 1) { --currentHouseListPage; } isHouseLoadingMore = false; if (isRefreshing) { hideLoading(); } } }, _mActivity, ShowErrorMode.YES); } }, _mActivity, ShowErrorMode.YES); } }); }); } private void clearData() { app/src/main/java/com/hdl/photovoltaic/widget/DefaultFilteringDialog.java
@@ -2,13 +2,18 @@ import android.content.Context; import android.os.Bundle; import android.text.TextUtils; import android.view.View; import android.widget.TextView; import androidx.annotation.NonNull; import androidx.appcompat.content.res.AppCompatResources; import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.base.BaseDialog; import com.hdl.photovoltaic.databinding.DialogDefaultFilteringBinding; import com.hdl.photovoltaic.enums.GridType; import com.hdl.photovoltaic.other.HdlThreadLogic; public class DefaultFilteringDialog extends BaseDialog { private final Context mContext; @@ -16,6 +21,18 @@ DialogDefaultFilteringBinding viewBinding; OnClickListener mOnClickListener; final String text1 = "0-5"; final String text2 = "5-10"; final String text3 = "10-15"; final String text4 = "15-30"; final String text5 = "30-100"; final String text6 = "100-300"; final String text7 = "300-500"; final String text8 = "500+"; private String mStateValue = GridType.All; public DefaultFilteringDialog(@NonNull Context context) { super(context, R.style.Custom_Dialog); @@ -32,7 +49,7 @@ //初始化界面控件 initView(); //初始化界面数据 initData(); // initData(mMinValue, mMaxValue, mStateValue); //初始化界面控件的事件 initEvent(); } @@ -42,12 +59,36 @@ viewBinding.affirmLl.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (mOnClickListener != null) { mOnClickListener.confirm(); String minValue = viewBinding.minEt.getText().toString(); String maxValue = viewBinding.maxEt.getText().toString(); if (!TextUtils.isEmpty(minValue) && !TextUtils.isEmpty(maxValue)) { try { if (Integer.parseInt(minValue) > Integer.parseInt(maxValue)) { //最小值在前面 if (mOnClickListener != null) { mOnClickListener.confirm(maxValue, minValue, mStateValue); } } else { if (mOnClickListener != null) { mOnClickListener.confirm(minValue, maxValue, mStateValue); } } } catch (Exception e) { //强制转换因输入值超出int值域范围报出异常 int maxValueInt = Integer.MAX_VALUE; HdlThreadLogic.toast(mContext, mContext.getString(R.string.the_input_value_has_been_exceeded) + "(" + maxValueInt + ")."); return; } } else { if (mOnClickListener != null) { mOnClickListener.confirm(minValue, maxValue, mStateValue); } } dismiss(); } }); viewBinding.cancelLl.setOnClickListener(new View.OnClickListener() { @Override @@ -55,12 +96,228 @@ dismiss(); } }); viewBinding.resetTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(null, TitleType.string_capacity); setSelectedText(""); } }); viewBinding.text1Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text1Tv, TitleType.string_capacity); setSelectedText(viewBinding.text1Tv.getTag().toString()); } }); viewBinding.text2Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text2Tv, TitleType.string_capacity); setSelectedText(viewBinding.text2Tv.getTag().toString()); } }); viewBinding.text3Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text3Tv, TitleType.string_capacity); setSelectedText(viewBinding.text3Tv.getTag().toString()); } }); viewBinding.text4Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text4Tv, TitleType.string_capacity); setSelectedText(viewBinding.text4Tv.getTag().toString()); } }); viewBinding.text5Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text5Tv, TitleType.string_capacity); setSelectedText(viewBinding.text5Tv.getTag().toString()); } }); viewBinding.text6Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text6Tv, TitleType.string_capacity); setSelectedText(viewBinding.text6Tv.getTag().toString()); } }); viewBinding.text7Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text7Tv, TitleType.string_capacity); setSelectedText(viewBinding.text7Tv.getTag().toString()); } }); viewBinding.text8Tv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.text8Tv, TitleType.string_capacity); setSelectedText(viewBinding.text8Tv.getTag().toString()); } }); viewBinding.allTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.allTv, TitleType.GridConnectedState); setSelectedText(viewBinding.allTv.getTag().toString()); } }); viewBinding.gridConnectedTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.gridConnectedTv, TitleType.GridConnectedState); setSelectedText(viewBinding.gridConnectedTv.getTag().toString()); } }); viewBinding.offNetworkTv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { setBackgroundColor(viewBinding.offNetworkTv, TitleType.GridConnectedState); setSelectedText(viewBinding.offNetworkTv.getTag().toString()); } }); } private void initData() { /** * @param value 选中的值 */ private void setSelectedText(String value) { String minValue = "", maxValue = ""; if (TextUtils.isEmpty(value)) { minValue = ""; maxValue = ""; } else if (value.contains("+")) { minValue = "500"; maxValue = ""; } else if (value.contains("-")) { String[] min_max = value.split("-"); if (min_max.length == 2) { minValue = min_max[0]; maxValue = min_max[1]; } } else { mStateValue = value; } viewBinding.minEt.setText(minValue); viewBinding.maxEt.setText(maxValue); } /** * 改变组件背景,字体颜色格式 * * @param textView 组件可以(设置为null,没有选中状态) * @param titleType 修改类型 */ private void setBackgroundColor(TextView textView, TitleType titleType) { if (titleType == TitleType.string_capacity) { viewBinding.text1Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text1Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text2Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text2Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text3Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text3Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text4Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text4Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text5Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text5Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text6Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text6Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text7Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text7Tv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.text8Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.text8Tv.setTextColor(mContext.getColor(R.color.text_90000000)); } else { viewBinding.allTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.allTv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.gridConnectedTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.gridConnectedTv.setTextColor(mContext.getColor(R.color.text_90000000)); viewBinding.offNetworkTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.search_bj_ff05000000)); viewBinding.offNetworkTv.setTextColor(mContext.getColor(R.color.text_90000000)); } if (textView != null) { textView.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.selected_38c494)); textView.setTextColor(mContext.getColor(R.color.text_FFFFFFFF)); } } public void initState(String min, String max, String stateValue) { try { mStateValue = stateValue; viewBinding.minEt.setText(min); viewBinding.maxEt.setText(max); if (!TextUtils.isEmpty(min) || !TextUtils.isEmpty(max)) { String str = min + "-" + max; switch (str) { case text1: setBackgroundColor(viewBinding.text1Tv, TitleType.string_capacity); break; case text2: setBackgroundColor(viewBinding.text2Tv, TitleType.string_capacity); break; case text3: setBackgroundColor(viewBinding.text3Tv, TitleType.string_capacity); break; case text4: setBackgroundColor(viewBinding.text4Tv, TitleType.string_capacity); break; case text5: setBackgroundColor(viewBinding.text5Tv, TitleType.string_capacity); break; case text6: setBackgroundColor(viewBinding.text6Tv, TitleType.string_capacity); break; case text7: setBackgroundColor(viewBinding.text7Tv, TitleType.string_capacity); break; case text8: setBackgroundColor(viewBinding.text8Tv, TitleType.string_capacity); break; } } if (TextUtils.isEmpty(stateValue)) { setBackgroundColor(viewBinding.allTv, TitleType.GridConnectedState); } else if (stateValue.equals(GridType.FULL_GRID)) { setBackgroundColor(viewBinding.gridConnectedTv, TitleType.GridConnectedState); } else { setBackgroundColor(viewBinding.offNetworkTv, TitleType.GridConnectedState); } } catch (Exception ignored) { } } private void initView() { viewBinding.text1Tv.setTag(text1); viewBinding.text2Tv.setTag(text2); viewBinding.text3Tv.setTag(text3); viewBinding.text4Tv.setTag(text4); viewBinding.text5Tv.setTag(text5); viewBinding.text6Tv.setTag(text6); viewBinding.text7Tv.setTag(text7); viewBinding.text8Tv.setTag(text8); viewBinding.allTv.setTag(GridType.All); viewBinding.gridConnectedTv.setTag(GridType.FULL_GRID); viewBinding.offNetworkTv.setTag(GridType.OFFLINE); setBackgroundColor(null, TitleType.string_capacity); setBackgroundColor(viewBinding.allTv, TitleType.GridConnectedState); } public void setOnClickListener(OnClickListener onClickListener) { @@ -71,6 +328,14 @@ public interface OnClickListener { void confirm(); void confirm(String min, String max, String state); } public enum TitleType { string_capacity,//组串容量 GridConnectedState//并网状态 } } app/src/main/res/layout/dialog_default_filtering.xml
@@ -123,22 +123,18 @@ android:layout_marginStart="@dimen/dp_20" android:background="@drawable/search_bj_ff05000000" android:gravity="center" android:hint="min" android:inputType="number" android:textColor="@color/text_90000000" android:textColorHint="@color/text_40000000" android:textSize="@dimen/text_14" /> <View android:layout_width="match_parent" android:layout_width="@dimen/dp_16" android:layout_height="1dp" android:layout_marginStart="@dimen/dp_5" android:layout_marginTop="@dimen/dp_17" android:layout_marginEnd="@dimen/dp_5" android:layout_toStartOf="@+id/max_et" android:layout_toEndOf="@+id/min_et" android:background="@color/text_E1E1E1" /> android:layout_alignParentStart="true" android:layout_marginStart="@dimen/dp_180" android:layout_marginTop="@dimen/dp_19" android:background="@color/text_E1E1E1" /> <EditText android:id="@+id/max_et" @@ -149,7 +145,7 @@ android:layout_marginEnd="@dimen/dp_20" android:background="@drawable/search_bj_ff05000000" android:gravity="center" android:hint="max" android:inputType="number" android:textColor="@color/text_90000000" android:textColorHint="@color/text_40000000" android:textSize="@dimen/text_14" /> @@ -219,7 +215,7 @@ android:id="@+id/text5_tv" android:layout_width="102dp" android:layout_height="@dimen/dp_35" android:layout_marginStart="@dimen/dp_20" android:layout_marginStart="@dimen/dp_15" android:layout_marginTop="@dimen/dp_66" android:background="@drawable/search_bj_ff05000000" android:gravity="center" @@ -234,7 +230,7 @@ android:id="@+id/text6_tv" android:layout_width="102dp" android:layout_height="@dimen/dp_35" android:layout_marginStart="@dimen/dp_20" android:layout_marginStart="@dimen/dp_15" android:layout_marginTop="@dimen/dp_66" android:background="@drawable/search_bj_ff05000000" android:gravity="center" @@ -264,11 +260,11 @@ android:id="@+id/text8_tv" android:layout_width="102dp" android:layout_height="@dimen/dp_35" android:layout_marginStart="@dimen/dp_20" android:layout_marginStart="@dimen/dp_15" android:layout_marginTop="114dp" android:background="@drawable/search_bj_ff05000000" android:gravity="center" android:tag="500-1000000" android:tag="500+" android:text="500+" android:textColor="@color/text_90000000" android:textSize="@dimen/text_14" @@ -295,7 +291,6 @@ android:layout_marginTop="13dp" android:background="@drawable/search_bj_ff05000000" android:gravity="center" android:tag="all" android:text="@string/message_all" android:textColor="@color/text_90000000" android:textSize="@dimen/text_14" @@ -310,7 +305,6 @@ android:layout_marginTop="13dp" android:background="@drawable/search_bj_ff05000000" android:gravity="center" android:tag="grid_connected" android:text="@string/grid_connected" android:textColor="@color/text_90000000" android:textSize="@dimen/text_14" @@ -325,7 +319,6 @@ android:layout_marginTop="13dp" android:background="@drawable/search_bj_ff05000000" android:gravity="center" android:tag="off_network" android:text="@string/off_network" android:textColor="@color/text_90000000" android:textSize="@dimen/text_14" app/src/main/res/values/strings.xml
@@ -286,6 +286,7 @@ <string name="grid_connected_state">并网状态</string> <string name="grid_connected">并网</string> <string name="off_network">离网</string> <string name="the_input_value_has_been_exceeded">输入值已经超过</string> </resources> app/src/main/res/values/styles.xml
@@ -13,7 +13,7 @@ <item name="android:textSize">@dimen/text_20</item> <item name="android:textStyle">bold</item> <item name="android:textColor">@color/text_90000000</item> <!-- <item name="android:fontFamily"></item>--> <!-- <item name="android:fontFamily"></item>--> </style> <!-- 自定义字体样式 内容一级标题--> @@ -35,4 +35,6 @@ </style> </resources>