wifi管理,解绑设备
This commit is contained in:
@@ -74,7 +74,7 @@ class SettingsActivity : BaseActivity() {
|
||||
.setPositiveText(getString(R.string.confirm))
|
||||
.setShowInput(false)
|
||||
dialog.setOnConfirmListener {
|
||||
finish()
|
||||
unbindDevice()
|
||||
}
|
||||
dialog.show(supportFragmentManager, "CustomDialogFragment")
|
||||
}
|
||||
@@ -134,6 +134,7 @@ class SettingsActivity : BaseActivity() {
|
||||
}
|
||||
binding.itemWifiManage.setOnClickListener {
|
||||
val intent = Intent(this, WiFiManagementActivity::class.java)
|
||||
intent.putExtra("wifi_name", binding.tvWifiName.text.toString())
|
||||
startActivity(intent)
|
||||
}
|
||||
}
|
||||
@@ -277,4 +278,36 @@ class SettingsActivity : BaseActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun unbindDevice() {
|
||||
val deviceId = DeviceIdEvent.getDeviceId()
|
||||
if (deviceId.isNullOrEmpty()) {
|
||||
Toast.makeText(this, "设备ID为空", Toast.LENGTH_SHORT).show()
|
||||
return
|
||||
}
|
||||
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
try {
|
||||
val deleteBean = com.example.defenseapplication.bean.DeleteBean()
|
||||
deleteBean.deviceId = deviceId
|
||||
val response = RetrofitNetwork.getNetworkService().deleteDevice(deleteBean)
|
||||
withContext(Dispatchers.Main) {
|
||||
if (response.code == 200) {
|
||||
Toast.makeText(this@SettingsActivity, "解绑成功", Toast.LENGTH_SHORT).show()
|
||||
val intent = Intent(this@SettingsActivity, com.example.defenseapplication.home.HomeActivity::class.java)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK
|
||||
startActivity(intent)
|
||||
finish()
|
||||
} else {
|
||||
Toast.makeText(this@SettingsActivity, response.msg, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
withContext(Dispatchers.Main) {
|
||||
Toast.makeText(this@SettingsActivity, "网络请求失败", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user