JLChen
2020-10-20 1884d3f3eba4c5193e0a5f71853c42ef9cd131b8
app/src/main/java/com/hdl/sdk/hdl_sdk/activity/CtrlRGBLightActivity.java
@@ -1,6 +1,7 @@
package com.hdl.sdk.hdl_sdk.activity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
@@ -61,7 +62,7 @@
        mRGBBackInfo = new RGBBackInfo(appliancesInfo);
        //读取状态
        HDLCommand.getRGBCCTStateFromNetwork(appliancesInfo);
        HDLCommand.getRgbOrCctStateFromNetwork(appliancesInfo);
    }
@@ -101,16 +102,19 @@
        btnRGB.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                int rStatus = Integer.parseInt(etR.getText().toString());
                int gStatus = Integer.parseInt(etG.getText().toString());
                int bStatus = Integer.parseInt(etB.getText().toString());
                if (rStatus < 0 || rStatus > 255 || gStatus < 0 || gStatus > 255 || bStatus < 0 || bStatus > 255) {
                    showToast("RGB值范围 0~255");
                    return;
                if (TextUtils.isEmpty(etR.getText().toString()) || TextUtils.isEmpty(etG.getText().toString()) || TextUtils.isEmpty(etB.getText().toString())) {
                    showToast("RGB值 不能为空");
                } else {
                    int rStatus = Integer.parseInt(etR.getText().toString());
                    int gStatus = Integer.parseInt(etG.getText().toString());
                    int bStatus = Integer.parseInt(etB.getText().toString());
                    if (rStatus < 0 || rStatus > 255 || gStatus < 0 || gStatus > 255 || bStatus < 0 || bStatus > 255) {
                        showToast("RGB值范围 0~255");
                        return;
                    }
                    int brightness = settingBrightness == 0 ? 100 : settingBrightness;
                    HDLCommand.lightRGBCtrl(appliancesInfo, brightness, rStatus, gStatus, bStatus);
                }
                int brightness = settingBrightness == 0 ? 100 : settingBrightness;
                HDLCommand.lightRGBCtrl(appliancesInfo, brightness, rStatus, gStatus, bStatus);
            }
        });