| | |
| | | |
| | | import android.app.Activity; |
| | | import android.content.Context; |
| | | import android.graphics.Color; |
| | | import android.os.Bundle; |
| | | import android.text.TextUtils; |
| | | import android.view.Gravity; |
| | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.BaseDialog; |
| | | 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); |
| | |
| | | @Override |
| | | protected void onCreate(Bundle savedInstanceState) { |
| | | super.onCreate(savedInstanceState); |
| | | // requestWindowFeature(Window.FEATURE_NO_TITLE); |
| | | viewBinding = DialogDefaultFilteringBinding.inflate(getLayoutInflater()); |
| | | setContentView(viewBinding.getRoot()); |
| | | Window window = getWindow(); |
| | | if (window != null) { |
| | | window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); |
| | | window.setGravity(Gravity.BOTTOM); |
| | | } |
| | | viewBinding = DialogDefaultFilteringBinding.inflate(getLayoutInflater()); |
| | | setContentView(viewBinding.getRoot()); |
| | | |
| | | // 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(); |
| | |
| | | public void onClick(View v) { |
| | | setBackgroundColor(null, TitleType.string_capacity); |
| | | setSelectedText(""); |
| | | setBackgroundColor(viewBinding.allTv, TitleType.GridConnectedState); |
| | | mStateValue = GridType.All; |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | setBackgroundColor(viewBinding.powerStationTypeAllTv, TitleType.powerStationType); |
| | | mGridType = DebugStatus.All; |
| | | mPowerStationType = PowerStationType.All; |
| | | } |
| | | }); |
| | | viewBinding.text1Tv.setOnClickListener(new View.OnClickListener() { |
| | |
| | | setSelectedText(viewBinding.text8Tv.getTag().toString()); |
| | | } |
| | | }); |
| | | |
| | | //全部 |
| | | viewBinding.allTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.allTv, TitleType.GridConnectedState); |
| | | mStateValue = GridType.All; |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | mGridType = DebugStatus.All; |
| | | } |
| | | }); |
| | | viewBinding.gridConnectedTv.setOnClickListener(new View.OnClickListener() { |
| | | //调试中 |
| | | viewBinding.beDebuggingTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.gridConnectedTv, TitleType.GridConnectedState); |
| | | mStateValue = GridType.FULL_GRID; |
| | | setBackgroundColor(viewBinding.beDebuggingTv, TitleType.debuggingState); |
| | | mGridType = DebugStatus.Debugging; |
| | | } |
| | | }); |
| | | viewBinding.offNetworkTv.setOnClickListener(new View.OnClickListener() { |
| | | //调试完成 |
| | | viewBinding.debuggingcOmpletedTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.offNetworkTv, TitleType.GridConnectedState); |
| | | mStateValue = GridType.OFFLINE; |
| | | setBackgroundColor(viewBinding.debuggingcOmpletedTv, TitleType.debuggingState); |
| | | mGridType = DebugStatus.WAIT_DELIVERED; |
| | | } |
| | | }); |
| | | //已交付 |
| | | viewBinding.deliveredTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.deliveredTv, TitleType.debuggingState); |
| | | mGridType = DebugStatus.Delivered; |
| | | } |
| | | }); |
| | | //授权调试 |
| | | viewBinding.authorizationDebuggingTv.setOnClickListener(new View.OnClickListener() { |
| | | |
| | | @Override |
| | | public void onClick(View v) { |
| | | setBackgroundColor(viewBinding.authorizationDebuggingTv, TitleType.debuggingState); |
| | | 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.gridConnectedTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.offNetworkTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.beDebuggingTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.debuggingcOmpletedTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.deliveredTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | viewBinding.authorizationDebuggingTv.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_129)); |
| | | } |
| | | if (textView != null) { |
| | | textView.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.config_yes_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; |
| | | } |
| | | } |
| | | 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); |
| | | switch (stateValue) { |
| | | case DebugStatus.All: |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | break; |
| | | case DebugStatus.Debugging: |
| | | setBackgroundColor(viewBinding.beDebuggingTv, TitleType.debuggingState); |
| | | break; |
| | | case DebugStatus.WAIT_DELIVERED: |
| | | setBackgroundColor(viewBinding.debuggingcOmpletedTv, TitleType.debuggingState); |
| | | break; |
| | | case DebugStatus.Delivered: |
| | | setBackgroundColor(viewBinding.deliveredTv, TitleType.debuggingState); |
| | | break; |
| | | case DebugStatus.SECONDARY_DEBUGGIN: |
| | | setBackgroundColor(viewBinding.authorizationDebuggingTv, TitleType.debuggingState); |
| | | break; |
| | | default: { |
| | | setBackgroundColor(viewBinding.allTv, TitleType.debuggingState); |
| | | 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.text7Tv.setTag(text7); |
| | | viewBinding.text8Tv.setTag(text8); |
| | | |
| | | viewBinding.allTv.setTag(GridType.All); |
| | | viewBinding.gridConnectedTv.setTag(GridType.FULL_GRID); |
| | | viewBinding.offNetworkTv.setTag(GridType.OFFLINE); |
| | | viewBinding.allTv.setTag(DebugStatus.All); |
| | | viewBinding.beDebuggingTv.setTag(DebugStatus.Debugging); |
| | | viewBinding.debuggingcOmpletedTv.setTag(DebugStatus.WAIT_DELIVERED); |
| | | viewBinding.deliveredTv.setTag(DebugStatus.Delivered); |
| | | viewBinding.authorizationDebuggingTv.setTag(DebugStatus.SECONDARY_DEBUGGIN); |
| | | setBackgroundColor(null, TitleType.string_capacity); |
| | | setBackgroundColor(viewBinding.allTv, TitleType.GridConnectedState); |
| | | 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,//组串容量 |
| | | GridConnectedState//并网状态 |
| | | debuggingState,//调试状态 |
| | | powerStationType//电站类型 |
| | | |
| | | } |
| | | |