| | |
| | | import com.hdl.photovoltaic.databinding.DialogDefaultFilteringBinding; |
| | | import com.hdl.photovoltaic.enums.DebugStatus; |
| | | import com.hdl.photovoltaic.enums.GridType; |
| | | import com.hdl.photovoltaic.enums.PowerStationType; |
| | | import com.hdl.photovoltaic.enums.UnitType; |
| | | import com.hdl.photovoltaic.other.HdlThreadLogic; |
| | | |
| | |
| | | final String text8 = "500+"; |
| | | |
| | | |
| | | private String mStateValue = GridType.All; |
| | | private String mGridType = GridType.All; |
| | | /** |
| | | * 电站类型(INV = 逆变器电站;BMS = BMS电站) |
| | | */ |
| | | private String mPowerStationType = PowerStationType.All; |
| | | |
| | | public DefaultFilteringDialog(@NonNull Context context) { |
| | | super(context, R.style.Custom_Dialog); |
| | |
| | | window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | window.setGravity(Gravity.BOTTOM); |
| | | } |
| | | setCanceledOnTouchOutside(false); |
| | | // setCanceledOnTouchOutside(false); |
| | | //初始化界面控件 |
| | | initView(); |
| | | //初始化界面数据 |
| | |
| | | if (Integer.parseInt(minValue) > Integer.parseInt(maxValue)) { |
| | | //最小值在前面 |
| | | if (mOnClickListener != null) { |
| | | mOnClickListener.confirm(maxValue, minValue, mStateValue); |
| | | mOnClickListener.confirm(maxValue, minValue, mGridType, mPowerStationType); |
| | | } |
| | | } else { |
| | | if (mOnClickListener != null) { |
| | | mOnClickListener.confirm(minValue, maxValue, mStateValue); |
| | | mOnClickListener.confirm(minValue, maxValue, mGridType, mPowerStationType); |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | //强制转换因输入值超出int值域范围报出异常 |
| | | // //强制转换因输入值超出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); |
| | | mOnClickListener.confirm(minValue, maxValue, mGridType, mPowerStationType); |
| | | } |
| | | } |
| | | dismiss(); |
| | |
| | | setBackgroundColor(null, TitleType.string_capacity); |
| | | setSelectedText(""); |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | mStateValue = DebugStatus.All; |
| | | setBackgroundColor(viewBinding.powerStationTypeAllTv, TitleType.powerStationType); |
| | | mGridType = DebugStatus.All; |
| | | mPowerStationType = PowerStationType.All; |
| | | } |
| | | }); |
| | | viewBinding.text1Tv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | mStateValue = DebugStatus.All; |
| | | mGridType = DebugStatus.All; |
| | | } |
| | | }); |
| | | //调试中 |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.beDebuggingTv, TitleType.debuggingState); |
| | | mStateValue = DebugStatus.Debugging; |
| | | mGridType = DebugStatus.Debugging; |
| | | } |
| | | }); |
| | | //调试完成 |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.debuggingcOmpletedTv, TitleType.debuggingState); |
| | | mStateValue = DebugStatus.WAIT_DELIVERED; |
| | | mGridType = DebugStatus.WAIT_DELIVERED; |
| | | } |
| | | }); |
| | | //已交付 |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.deliveredTv, TitleType.debuggingState); |
| | | mStateValue = DebugStatus.Delivered; |
| | | mGridType = DebugStatus.Delivered; |
| | | } |
| | | }); |
| | | //授权调试 |
| | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.authorizationDebuggingTv, TitleType.debuggingState); |
| | | mStateValue = DebugStatus.SECONDARY_DEBUGGIN; |
| | | mGridType = DebugStatus.SECONDARY_DEBUGGIN; |
| | | } |
| | | }); |
| | | //电站类型--全部 |
| | | viewBinding.powerStationTypeAllTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.powerStationTypeAllTv, TitleType.powerStationType); |
| | | mPowerStationType = PowerStationType.All; |
| | | } |
| | | }); |
| | | |
| | | //电站类型--逆变器 |
| | | viewBinding.powerStationTypeInvTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.powerStationTypeInvTv, TitleType.powerStationType); |
| | | mPowerStationType = PowerStationType.INV; |
| | | } |
| | | }); |
| | | |
| | | //电站类型--BMS |
| | | viewBinding.powerStationTypeBmsTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.powerStationTypeBmsTv, TitleType.powerStationType); |
| | | mPowerStationType = PowerStationType.BMS; |
| | | } |
| | | }); |
| | | |
| | |
| | | viewBinding.text6Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.text7Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.text8Tv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | } else if (titleType == TitleType.powerStationType) { |
| | | viewBinding.powerStationTypeAllTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.powerStationTypeInvTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.powerStationTypeBmsTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | } else { |
| | | viewBinding.allTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.beDebuggingTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | |
| | | |
| | | } |
| | | |
| | | public void initState(String min, String max, String stateValue) { |
| | | public void initState(String min, String max, String stateValue, String powerStationTypeValue) { |
| | | try { |
| | | mStateValue = stateValue; |
| | | mPowerStationType = powerStationTypeValue; |
| | | mGridType = stateValue; |
| | | viewBinding.minEt.setText(min); |
| | | viewBinding.maxEt.setText(max); |
| | | |
| | |
| | | break; |
| | | } |
| | | } |
| | | switch (powerStationTypeValue) { |
| | | case PowerStationType.All: |
| | | setBackgroundColor(viewBinding.powerStationTypeAllTv, TitleType.powerStationType); |
| | | break; |
| | | case PowerStationType.INV: |
| | | setBackgroundColor(viewBinding.powerStationTypeInvTv, TitleType.powerStationType); |
| | | break; |
| | | case PowerStationType.BMS: |
| | | setBackgroundColor(viewBinding.powerStationTypeBmsTv, TitleType.powerStationType); |
| | | break; |
| | | default: { |
| | | setBackgroundColor(viewBinding.powerStationTypeAllTv, TitleType.powerStationType); |
| | | break; |
| | | } |
| | | } |
| | | } catch (Exception ignored) { |
| | | } |
| | | |
| | |
| | | viewBinding.authorizationDebuggingTv.setTag(DebugStatus.SECONDARY_DEBUGGIN); |
| | | setBackgroundColor(null, TitleType.string_capacity); |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | setBackgroundColor(viewBinding.powerStationTypeAllTv, TitleType.powerStationType); |
| | | } |
| | | |
| | | public void setOnClickListener(OnClickListener onClickListener) { |
| | |
| | | |
| | | |
| | | public interface OnClickListener { |
| | | void confirm(String min, String max, String state); |
| | | void confirm(String min, String max, String state, String powerStationType); |
| | | } |
| | | |
| | | public enum TitleType { |
| | | string_capacity,//组串容量 |
| | | debuggingState//调试状态 |
| | | debuggingState,//调试状态 |
| | | powerStationType//电站类型 |
| | | |
| | | } |
| | | |