| | |
| | | |
| | | |
| | | import android.os.Bundle; |
| | | import android.support.annotation.NonNull; |
| | | import android.text.TextUtils; |
| | | import android.view.View; |
| | | import android.widget.AdapterView; |
| | |
| | | import android.widget.RelativeLayout; |
| | | import android.widget.Spinner; |
| | | import android.widget.TextView; |
| | | |
| | | import androidx.annotation.NonNull; |
| | | |
| | | import com.afollestad.materialdialogs.DialogAction; |
| | | import com.afollestad.materialdialogs.MaterialDialog; |
| | |
| | | private EditText subnetIDEditText; |
| | | private EditText deviceIDEditText; |
| | | private EditText channelNumEditText; |
| | | private EditText indexEditText; |
| | | private EditText remarksEditText; |
| | | private Button addButton; |
| | | // private String subnetIDStr, deviceIDStr, channelNumStr, remarksStr; |
| | | private int subnetID, deviceID, channelNum; |
| | | private String remarksStr; |
| | | // private String subnetIDStr, deviceIDStr, channelNumStr, remarksStr; |
| | | private int subnetID, deviceID, channelNum, index; |
| | | private String remarksStr; |
| | | |
| | | private int deviceTypeId = 0; |
| | | private static final String[] deviceTypeItems = {"安防模块", "音乐模块", "传感器模块"}; |
| | |
| | | subnetIDEditText = findViewById(R.id.et_subnetID); |
| | | deviceIDEditText = findViewById(R.id.et_deviceID); |
| | | channelNumEditText = findViewById(R.id.et_channelNum); |
| | | indexEditText = findViewById(R.id.et_index); |
| | | remarksEditText = findViewById(R.id.et_remarks); |
| | | |
| | | addButton = findViewById(R.id.btn_add); |
| | |
| | | boolean isSuccess = false; |
| | | if (deviceTypeId == 0) { |
| | | |
| | | isSuccess = HDLDeviceManager.addSecurityDevicesManually(subnetID, deviceID, channelNum, remarksStr); |
| | | } else if(deviceTypeId == 1) { |
| | | isSuccess = HDLDeviceManager.addAudioDevicesManually(subnetID, deviceID, channelNum, remarksStr); |
| | | }else { |
| | | isSuccess = HDLDeviceManager.addSecurityDevicesManually(subnetID, deviceID, channelNum, index, remarksStr); |
| | | } else if (deviceTypeId == 1) { |
| | | isSuccess = HDLDeviceManager.addAudioDevicesManually(subnetID, deviceID, channelNum, index, remarksStr); |
| | | } else { |
| | | //指定大类和小类参数 区分模块类型 |
| | | isSuccess = HDLDeviceManager.addDevicesManuallyWithoutSearching(Configuration.SENSOR_BIG_TYPE,11 ,subnetID, deviceID, channelNum, remarksStr); |
| | | isSuccess = HDLDeviceManager.addDevicesManuallyWithoutSearching(Configuration.SENSOR_BIG_TYPE, 11, subnetID, deviceID, channelNum, index, remarksStr); |
| | | } |
| | | |
| | | if(isSuccess){ |
| | | if (isSuccess) { |
| | | showToast("添加成功"); |
| | | finish(); |
| | | }else { |
| | | } else { |
| | | showToast("添加失败"); |
| | | } |
| | | } |
| | | |
| | | private void addButtonAction(){ |
| | | String subnetIDStr = subnetIDEditText.getText().toString(); |
| | | private void addButtonAction() { |
| | | String subnetIDStr = subnetIDEditText.getText().toString(); |
| | | if (TextUtils.isEmpty(subnetIDStr)) { |
| | | showToast("子网号不能为空"); |
| | | return; |
| | |
| | | return; |
| | | } |
| | | |
| | | String indexStr = indexEditText.getText().toString(); |
| | | if (TextUtils.isEmpty(indexStr)) { |
| | | showToast("序列号不能为空"); |
| | | return; |
| | | } |
| | | |
| | | String remarksString = remarksEditText.getText().toString(); |
| | | if (TextUtils.isEmpty(remarksString)) { |
| | | showToast("备注不能为空"); |
| | |
| | | } |
| | | |
| | | |
| | | subnetID = Integer.parseInt(subnetIDStr); |
| | | deviceID = Integer.parseInt(deviceIDStr); |
| | | channelNum = Integer.parseInt(channelNumStr); |
| | | remarksStr = remarksString; |
| | | String mes = ""; |
| | | subnetID = Integer.parseInt(subnetIDStr); |
| | | deviceID = Integer.parseInt(deviceIDStr); |
| | | channelNum = Integer.parseInt(channelNumStr); |
| | | index = Integer.parseInt(indexStr); |
| | | remarksStr = remarksString; |
| | | String mes = ""; |
| | | mes = "设备类型:" + deviceTypeItems[deviceTypeId]; |
| | | mes += "\n子网号:" + subnetIDStr +"\n设备号:" + deviceIDStr +"\n回路号:" + channelNumStr +"\n备注名:" + remarksStr; |
| | | mes += "\n子网号:" + subnetIDStr + "\n设备号:" + deviceIDStr + "\n回路号:" + channelNumStr + "\n序列号:" + indexStr + "\n备注名:" + remarksStr; |
| | | showTipDialog(mes); |
| | | |
| | | } |
| | | |
| | | private void showTipDialog(String message) { |
| | | |
| | | MaterialDialog mMaterialDialog = new MaterialDialog.Builder(this) |
| | | MaterialDialog mMaterialDialog = new MaterialDialog.Builder(this) |
| | | .title("是否确定添加该设备?") |
| | | .content(message) |
| | | .positiveText(R.string.ok) |
| | |
| | | }).build(); |
| | | mMaterialDialog.show(); |
| | | } |
| | | |
| | | |
| | | |
| | | } |