mac
2024-07-02 d7ff801372431e64aee8f68ece4b8532cffb2207
app/src/main/java/com/hdl/photovoltaic/ui/adapter/HouseInfoAdapter.java
@@ -15,6 +15,7 @@
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.hdl.photovoltaic.R;
import com.hdl.photovoltaic.enums.PowerStationStatus;
import com.hdl.photovoltaic.enums.UnitType;
import com.hdl.photovoltaic.other.HdlCommonLogic;
import com.hdl.photovoltaic.other.HdlDeviceLogic;
@@ -32,6 +33,8 @@
    private List<HouseIdBean> mList;
    private final Context mContext;
    private OnclickListener noOnclickListener;//点击了的监听器
    String mPowerStationStatus;
    /**
     * 收集SwipeLayout数组,要一键全部打开;
@@ -57,7 +60,7 @@
        HouseIdBean houseIdBean = this.mList.get(position);
        holder.homeNameTv.setText(houseIdBean.getHomeName().trim());
        //装机容量
        String capacity = mContext.getString(R.string.my_power_station_installed_capacity) + ":" + HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getInstalledCapacity(), UnitType.kWp);
        String capacity = mContext.getString(R.string.string_capacity) + ":" + HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getInstalledCapacity(), UnitType.kWp);
        holder.capacityTv.setText(capacity);
        //发电功率
        holder.power_value_tv.setText(HdlCommonLogic.getConvertDoubleUnit(houseIdBean.getPower(), UnitType.kW));
@@ -114,7 +117,8 @@
    }
    public void setList(List<HouseIdBean> newData) {
    public void setList(List<HouseIdBean> newData, String powerStationStatus) {
        mPowerStationStatus = powerStationStatus;
        if (this.mList == null) {
            this.mList = new ArrayList<>();
        } else {
@@ -148,37 +152,48 @@
     * @param state_value 电站状态(1:正常(运行),2:离线,3:连接中,4:故障,5:离线有故障)
     */
    private void setTextViewStyle(TextView textView, int state_value) {
        String text = mContext.getString(R.string.my_power_station_operation);
        Drawable drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_06b92a);
        switch (state_value) {
            case 1: {
                text = mContext.getString(R.string.my_power_station_operation);
        if (mPowerStationStatus.equals(PowerStationStatus.All)) {
            switch (state_value) {
                case 1: {
                    text = mContext.getString(R.string.my_power_station_operation);
                }
                break;
            }
            break;
            case 2: {
                text = mContext.getString(R.string.my_power_station_off_line);
                drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9);
            }
            break;
            case 3: {
                text = mContext.getString(R.string.my_power_station_connecting);
                drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300);
            }
            break;
            case 4:
            case 5:
            {
                text = mContext.getString(R.string.my_power_station_malfunction);
                drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343);
            }
            //5:离线有故障Offline_fault
            break;
                case 2: {
                    text = mContext.getString(R.string.my_power_station_off_line);
                    drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9);
                }
                break;
                case 3: {
                    text = mContext.getString(R.string.my_power_station_connecting);
                    drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300);
                }
                break;
                case 4:
                case 5: {
                    text = mContext.getString(R.string.my_power_station_malfunction);
                    drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343);
                }
                //5:离线有故障Offline_fault
                break;
//            case 5: {
//                text = mContext.getString(R.string.Offline_fault);
//                drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343);
//            }
//            break;
            }
        } else if (mPowerStationStatus.equals(PowerStationStatus.malfunction)) {
            text = mContext.getString(R.string.my_power_station_malfunction);
            drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_e34343);
        } else if (mPowerStationStatus.equals(PowerStationStatus.off)) {
            text = mContext.getString(R.string.my_power_station_off_line);
            drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_b9b9b9);
        } else if (mPowerStationStatus.equals(PowerStationStatus.connecting)) {
            text = mContext.getString(R.string.my_power_station_connecting);
            drawable = AppCompatResources.getDrawable(mContext, R.drawable.state_ffb300);
        }
        textView.setText(text);
        textView.setBackground(drawable);