From ce062b3c62d283fa364f92853d1b53221b94a3bc Mon Sep 17 00:00:00 2001 From: JLChen <551775569@qq.com> Date: 星期三, 24 六月 2020 09:30:32 +0800 Subject: [PATCH] 2020-06-24 1.增加手动添加生成设备接口方法。 2.增加通用开关和安防模块支持。 --- app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java | 209 ++++++++++++++++++++++++++++++++++------------------ 1 files changed, 136 insertions(+), 73 deletions(-) diff --git a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java index 7a752f0..957b70e 100644 --- a/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java +++ b/app/src/main/java/com/hdl/sdk/hdl_sdk/activity/GeothermalActivity.java @@ -1,6 +1,7 @@ package com.hdl.sdk.hdl_sdk.activity; +import android.app.ProgressDialog; import android.os.Bundle; import android.text.TextUtils; import android.view.View; @@ -9,12 +10,12 @@ import android.widget.TextView; import com.hdl.sdk.hdl_core.HDLAppliances.Config.HDLApConfig; -import com.hdl.sdk.hdl_core.HDLAppliances.HDLFreshAir.Parser.FreshAirParser; import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.GeothermalBackInfo; import com.hdl.sdk.hdl_core.HDLAppliances.HDLGeothermal.Parser.GeothermalParser; import com.hdl.sdk.hdl_core.HDLDeviceManger.Bean.AppliancesInfo; import com.hdl.sdk.hdl_core.HDLDeviceManger.Core.HDLCommand; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.DeviceStateEvent; +import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.EventCode; import com.hdl.sdk.hdl_core.HDLDeviceManger.EventBusEvent.GeothermalFeedBackEvent; import com.hdl.sdk.hdl_sdk.R; import com.hdl.sdk.hdl_sdk.base.BaseActivity; @@ -37,7 +38,7 @@ private int gModeState; private int gTempState; private int ctrlId; - + private ProgressDialog proDialog; /** * 瑕佹敞鍐屼娇鐢‥ventBus锛岃繖閲岃璁剧疆杩斿洖true * @@ -63,6 +64,13 @@ HDLCommand.getDeviceState(appliancesInfo); } + @Override + protected void onDestroy() { + super.onDestroy(); + proDialog.dismiss(); + HDLLog.I("onDestroy: GeothermalActivity"); + } + private void initcurState() { appliancesInfo = (AppliancesInfo) getIntent().getSerializableExtra("hdl"); } @@ -74,12 +82,17 @@ btn_temp = findViewById(R.id.btn_temp); tempEditText = findViewById(R.id.et_temp); + proDialog = new ProgressDialog(this); + proDialog.setTitle("姝e湪鍙戦�佹帶鍒跺懡浠�..."); + proDialog.setMessage("璇疯�愬績绛夊緟"); + proDialog.onStart(); } private void initClickOnEvent() { btn_switch.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = GeothermalParser.gSwich; //婕旂ず褰撳墠鐘舵�佷负鍏筹紝璁剧疆涓哄紑銆傚紑锛岃缃负鍏炽�� if (gSwitchState == 0) { @@ -97,6 +110,7 @@ btn_mode.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { + proDialog.show(); ctrlId = GeothermalParser.gMode; switch (gModeState) { case 1: @@ -127,6 +141,7 @@ } + } }); @@ -136,7 +151,7 @@ public void onClick(View view) { String tempStr = tempEditText.getText().toString(); - if (TextUtils.isEmpty(tempStr) || TextUtils.isEmpty(tempStr)) { + if (TextUtils.isEmpty(tempStr)) { showToast("璁剧疆鐨勬俯搴︿笉鑳戒负绌�"); return; } @@ -146,38 +161,63 @@ showToast("娓╁害璁剧疆鑼冨洿涓猴細16~35鎽勬皬搴�(鈩�)"); return; } + proDialog.show(); +// HDLCommand.geothermalCtrlTemp(appliancesInfo, tempInt);//鑷姩鏍规嵁褰撳墠妯″紡璁剧疆褰撳墠妯″紡鐨勬俯搴︺�� switch (gModeState) { - case 1: - - //褰撳墠鍦扮儹妯″紡涓烘櫘閫� - HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNormalTemp, tempInt);//鏅�氭俯搴� - ctrlId = GeothermalParser.gNormalTemp; - break; case 2: - //褰撳墠鍦扮儹妯″紡涓虹櫧澶� - HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gDayTemp, tempInt);//鐧藉ぉ娓╁害 - ctrlId = GeothermalParser.gDayTemp; - break; case 3: - //褰撳墠鍦扮儹妯″紡涓哄闂� - HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNightTemp, tempInt);//澶滈棿娓╁害 - ctrlId = GeothermalParser.gNightTemp; - break; case 4: - //褰撳墠鍦扮儹妯″紡涓虹寮� - HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gLeaveTemp, tempInt);//绂诲紑娓╁害 - ctrlId = GeothermalParser.gLeaveTemp; + HDLCommand.geothermalCtrlTemp(appliancesInfo, tempInt);//鑷姩鏍规嵁褰撳墠妯″紡璁剧疆褰撳墠妯″紡鐨勬俯搴︺�� break; case 5: + proDialog.dismiss(); //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� - showToast("鑷姩妯″紡涓嶈兘鎺у埗娓╁害"); + showToast("鑷姩妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); break; default: + proDialog.dismiss(); + //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� + showToast("鏈煡妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); break; } + +// switch (gModeState) { +// +// case 1: +// //褰撳墠鍦扮儹妯″紡涓烘櫘閫� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNormalTemp, tempInt);//鏅�氭俯搴� +// ctrlId = GeothermalParser.gNormalTemp; +// break; +// case 2: +// //褰撳墠鍦扮儹妯″紡涓虹櫧澶� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gDayTemp, tempInt);//鐧藉ぉ娓╁害 +// ctrlId = GeothermalParser.gDayTemp; +// break; +// case 3: +// //褰撳墠鍦扮儹妯″紡涓哄闂� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gNightTemp, tempInt);//澶滈棿娓╁害 +// ctrlId = GeothermalParser.gNightTemp; +// break; +// case 4: +// //褰撳墠鍦扮儹妯″紡涓虹寮� +// HDLCommand.geothermalCtrl(appliancesInfo, GeothermalParser.gLeaveTemp, tempInt);//绂诲紑娓╁害 +// ctrlId = GeothermalParser.gLeaveTemp; +// break; +// case 5: +// proDialog.dismiss(); +// //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� +// showToast("鑷姩妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); +// break; +// default: +// proDialog.dismiss(); +// //褰撳墠鍦扮儹妯″紡涓鸿嚜鍔� +// showToast("鏈煡妯″紡锛屼笉鑳芥帶鍒舵俯搴�"); +// break; +// +// } } @@ -191,9 +231,9 @@ GeothermalBackInfo mGeothermalBackInfo = new GeothermalBackInfo(appliancesInfo, false); String stringState = ""; - if (mGeothermalBackInfo.getIsOn() == 0) { + if (mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOff) { stringState = "鍦扮儹妯″潡锛氬叧闂�"; - } else if (mGeothermalBackInfo.getIsOn() == 1) { + } else if (mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) { stringState = "鍦扮儹妯″潡锛氭墦寮�"; stringState += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); @@ -227,10 +267,10 @@ String mStrState = "鏈煡"; gSwitchState = mState; //鏇存柊寮�鍏崇姸鎬� switch (mState) { - case FreshAirParser.freshAirOn: + case GeothermalParser.gSwichOn: mStrState = "鍦扮儹妯″潡锛氭墦寮�"; break; - case FreshAirParser.freshAirOff: + case GeothermalParser.gSwichOff: mStrState = "鍦扮儹妯″潡锛氬叧闂�"; break; @@ -253,19 +293,19 @@ gModeState = mState; //鏇存柊妯″紡鐘舵�� switch (mState) { case GeothermalParser.gModeNormal: - mStrState = " 妯″紡锛氭櫘閫�"; + mStrState = "妯″紡锛氭櫘閫�"; break; case GeothermalParser.gModeDay: - mStrState = " 妯″紡锛氱櫧澶�"; + mStrState = "妯″紡锛氱櫧澶�"; break; case GeothermalParser.gModeNight: - mStrState = " 妯″紡锛氬闂�"; + mStrState = "妯″紡锛氬闂�"; break; case GeothermalParser.gModeLeave: - mStrState = " 妯″紡锛氱寮�"; + mStrState = "妯″紡锛氱寮�"; break; case GeothermalParser.gModeAuto: - mStrState = " 妯″紡锛氳嚜鍔�"; + mStrState = "妯″紡锛氳嚜鍔�"; break; default: @@ -277,55 +317,64 @@ @Subscribe(threadMode = ThreadMode.MAIN) public void onGeothermalFeedBackEventMain(GeothermalFeedBackEvent event) { + proDialog.dismiss(); if (event.getGeothermalBackInfo().getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() && event.getGeothermalBackInfo().getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() && event.getGeothermalBackInfo().getAppliancesInfo().getChannelNum() == appliancesInfo.getChannelNum() ) { //鍏堝垽鏂槸鍚﹁秴鏃� - if (!event.isSuccess()) { + if (event.getStatusID() == EventCode.FAILURE) { showToast("鍦扮儹妯″潡鎺у埗瓒呮椂锛岃閲嶆柊鍐嶈瘯"); return; } - String message = ""; - GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo(); - - switch (ctrlId) { //ctrlId 褰撳墠鎺у埗绫诲瀷,鍙弽棣堟帶鍒剁殑鐘舵�� - case GeothermalParser.gSwich: - message = getSwichStateString(mGeothermalBackInfo.getIsOn()); - break; - case GeothermalParser.gMode: - message = getModeStateString(mGeothermalBackInfo.getgMode()); - break; - case GeothermalParser.gNormalTemp: -// gTempState = mGeothermalBackInfo.getgNormalTemp(); - message = "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); - break; - - - case GeothermalParser.gDayTemp: - message = "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); - break; - case GeothermalParser.gNightTemp: - message = "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); - break; - case GeothermalParser.gLeaveTemp: - message = "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); - break; - default: - break; - + if (event.getStatusID() == EventCode.DATAEMPTY) { + showToast("鍦扮儹妯″潡,杩斿洖鏁版嵁涓虹┖"); + return; } + GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo(); + showGeothermalBackInfo(mGeothermalBackInfo); +// String message = ""; +// GeothermalBackInfo mGeothermalBackInfo = event.getGeothermalBackInfo(); - mTextView.setText(message); - showToast(message); - HDLLog.I(message); +// switch (ctrlId) { //ctrlId 褰撳墠鎺у埗绫诲瀷,鍙弽棣堟帶鍒剁殑鐘舵�� +// case GeothermalParser.gSwich: +// message = getSwichStateString(mGeothermalBackInfo.getIsOn()); +// break; +// case GeothermalParser.gMode: +// message = getModeStateString(mGeothermalBackInfo.getgMode()); +// break; +// case GeothermalParser.gNormalTemp: +//// gTempState = mGeothermalBackInfo.getgNormalTemp(); +// message = "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); +// break; +// +// +// case GeothermalParser.gDayTemp: +// message = "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); +// break; +// case GeothermalParser.gNightTemp: +// message = "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); +// break; +// case GeothermalParser.gLeaveTemp: +// message = "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); +// break; +// default: +// break; +// +// } +// +// +// mTextView.setText(message); +// showToast(message); +// HDLLog.I(message); } } @Subscribe(threadMode = ThreadMode.MAIN) public void onDeviceStateEventMain(DeviceStateEvent event) { + proDialog.dismiss(); if (event.getAppliancesInfo().getDeviceSubnetID() == appliancesInfo.getDeviceSubnetID() && event.getAppliancesInfo().getDeviceDeviceID() == appliancesInfo.getDeviceDeviceID() ) { @@ -345,21 +394,35 @@ return; } - message += "\n" + getSwichStateString(mGeothermalBackInfo.getIsOn()); - message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); - message += "\n" + "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); - message += "\n" + "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); - message += "\n" + "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); - message += "\n" + "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); - - - mTextView.setText(message); - showToast(message); - HDLLog.I(message); + showGeothermalBackInfo(mGeothermalBackInfo); } break; } } } + + /** + * showGeothermalBackInfo + * @param mGeothermalBackInfo + */ + private void showGeothermalBackInfo(GeothermalBackInfo mGeothermalBackInfo){ + String message = ""; + if(mGeothermalBackInfo.getIsOn() == GeothermalParser.gSwichOn) { + message = getSwichStateString(mGeothermalBackInfo.getIsOn()); + + message += "\n" + getModeStateString(mGeothermalBackInfo.getgMode()); + message += "\n" + "鏅�氭ā寮忔俯搴︼細" + mGeothermalBackInfo.getgNormalTemp(); + message += "\n" + "鐧藉ぉ妯″紡娓╁害锛�" + mGeothermalBackInfo.getgDayTemp(); + message += "\n" + "澶滈棿妯″紡娓╁害锛�" + mGeothermalBackInfo.getgNightTemp(); + message += "\n" + "绂诲紑妯″紡娓╁害锛�" + mGeothermalBackInfo.getgLeaveTemp(); + }else { + message = getSwichStateString(mGeothermalBackInfo.getIsOn()); + } + + + mTextView.setText(message); + showToast(message); + HDLLog.I(message); + } } -- Gitblit v1.8.0