1.网络接口请求超时10s修改为35秒
2.关机由原来的:0x04 -> turnoff接口 -> 0x18,改为:0x18-> turnoff接口
This commit is contained in:
@@ -25,6 +25,7 @@ class LiveDurationSetActivity :
|
|||||||
|
|
||||||
//选中的下标
|
//选中的下标
|
||||||
private var mSelectIndex = -1
|
private var mSelectIndex = -1
|
||||||
|
private var mSelectTempIndex = -1
|
||||||
|
|
||||||
private var mMapDeviceBean: MapDeviceBean? = null
|
private var mMapDeviceBean: MapDeviceBean? = null
|
||||||
|
|
||||||
@@ -55,6 +56,7 @@ class LiveDurationSetActivity :
|
|||||||
dealRequestResult(it, object : GetResultCallback {
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
override fun onResult(any: Any) {
|
override fun onResult(any: Any) {
|
||||||
showToast(R.string.txt_change_successful)
|
showToast(R.string.txt_change_successful)
|
||||||
|
mSelectIndex = mSelectTempIndex
|
||||||
ViewUtil.instance.updateDataBeanOnlySelectedItem(
|
ViewUtil.instance.updateDataBeanOnlySelectedItem(
|
||||||
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
|
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
|
||||||
)
|
)
|
||||||
@@ -69,7 +71,7 @@ class LiveDurationSetActivity :
|
|||||||
for (time in timeList) {
|
for (time in timeList) {
|
||||||
DataBean().apply {
|
DataBean().apply {
|
||||||
imageId = time
|
imageId = time
|
||||||
name = String.format(getString(R.string.txt_duration_min_unit), time)
|
name = String.format(getString(R.string.txt_duration_min_unit), "$time")
|
||||||
durationList.add(this)
|
durationList.add(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -96,7 +98,7 @@ class LiveDurationSetActivity :
|
|||||||
fun setLiveDuration(pos: Int) {
|
fun setLiveDuration(pos: Int) {
|
||||||
if (mSelectIndex == pos) return
|
if (mSelectIndex == pos) return
|
||||||
mMapDeviceBean?.apply {
|
mMapDeviceBean?.apply {
|
||||||
mSelectIndex = pos
|
mSelectTempIndex = pos
|
||||||
val dataBean = mDurationSetAdapter.getData()[pos]
|
val dataBean = mDurationSetAdapter.getData()[pos]
|
||||||
mTrackerSetViewModel.setLiveTime(
|
mTrackerSetViewModel.setLiveTime(
|
||||||
this@LiveDurationSetActivity, deviceId, dataBean.imageId
|
this@LiveDurationSetActivity, deviceId, dataBean.imageId
|
||||||
|
|||||||
@@ -93,8 +93,12 @@ class PowerOffActivity : BaseActivity<ActivityPowerOffBinding>(ActivityPowerOffB
|
|||||||
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
|
val data0 = SRBleCmdUtil.instance.byteToInt(data[0])
|
||||||
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
|
val data1 = SRBleCmdUtil.instance.byteToInt(data[1])
|
||||||
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
|
val data2 = SRBleCmdUtil.instance.byteToInt(data[2])
|
||||||
if (data0 == 4 && data1 == 1 && data2 == 0) {
|
if (data0 == 0x18 && data1 == 1) {
|
||||||
showToast(R.string.txt_done, true)
|
if (data2 == 0) showToast(R.string.txt_done, true)
|
||||||
|
else if (data2 == 3) {
|
||||||
|
setButtonEnabled(mViewBinding.btnPowerOffYes)
|
||||||
|
showToast(R.string.txt_on_charging)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +126,7 @@ class PowerOffActivity : BaseActivity<ActivityPowerOffBinding>(ActivityPowerOffB
|
|||||||
mPetBean?.apply {
|
mPetBean?.apply {
|
||||||
SRBleUtil.instance.getConnectMacDevice(macID)?.let {
|
SRBleUtil.instance.getConnectMacDevice(macID)?.let {
|
||||||
setButtonEnabled(mViewBinding.btnPowerOffYes)
|
setButtonEnabled(mViewBinding.btnPowerOffYes)
|
||||||
val cmd = SRBleCmdUtil.instance.shutdownDevice()
|
val cmd = SRBleCmdUtil.instance.forcedShutdown()
|
||||||
SRBleUtil.instance.writeData(it.bleDevice, cmd)
|
SRBleUtil.instance.writeData(it.bleDevice, cmd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ class TrackingDurationSetActivity :
|
|||||||
|
|
||||||
//选中的下标
|
//选中的下标
|
||||||
private var mSelectIndex = -1
|
private var mSelectIndex = -1
|
||||||
|
private var mSelectTempIndex = -1
|
||||||
|
|
||||||
private var mMapDeviceBean: MapDeviceBean? = null
|
private var mMapDeviceBean: MapDeviceBean? = null
|
||||||
|
|
||||||
@@ -62,6 +63,7 @@ class TrackingDurationSetActivity :
|
|||||||
dealRequestResult(it, object : GetResultCallback {
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
override fun onResult(any: Any) {
|
override fun onResult(any: Any) {
|
||||||
showToast(R.string.txt_change_successful)
|
showToast(R.string.txt_change_successful)
|
||||||
|
mSelectIndex = mSelectTempIndex
|
||||||
ViewUtil.instance.updateDataBeanOnlySelectedItem(
|
ViewUtil.instance.updateDataBeanOnlySelectedItem(
|
||||||
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
|
mDurationSetAdapter, mDurationSetAdapter.getData(), mSelectIndex
|
||||||
)
|
)
|
||||||
@@ -143,7 +145,7 @@ class TrackingDurationSetActivity :
|
|||||||
fun setTrackingDuration(pos: Int) {
|
fun setTrackingDuration(pos: Int) {
|
||||||
if (mSelectIndex == pos) return
|
if (mSelectIndex == pos) return
|
||||||
mMapDeviceBean?.apply {
|
mMapDeviceBean?.apply {
|
||||||
mSelectIndex = pos
|
mSelectTempIndex = pos
|
||||||
val dataBean = mDurationSetAdapter.getData()[pos]
|
val dataBean = mDurationSetAdapter.getData()[pos]
|
||||||
if (BleManager.getInstance().isConnected(deviceMacId)) {
|
if (BleManager.getInstance().isConnected(deviceMacId)) {
|
||||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||||
|
|||||||
@@ -361,14 +361,11 @@ class HomeTrackFragment :
|
|||||||
mTurnoffLiveData.observe(viewLifecycleOwner) {
|
mTurnoffLiveData.observe(viewLifecycleOwner) {
|
||||||
dealRequestResult(it, object : GetResultCallback {
|
dealRequestResult(it, object : GetResultCallback {
|
||||||
override fun onResult(any: Any) {
|
override fun onResult(any: Any) {
|
||||||
// mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
// mBleTrackDeviceBean?.apply {
|
||||||
// mTrackMenuAdapter.notifyItemChanged(4)
|
// SRBleUtil.instance.writeData(
|
||||||
// bleTurnOff()
|
// bleDevice, SRBleCmdUtil.instance.forcedShutdown()
|
||||||
mBleTrackDeviceBean?.apply {
|
// )
|
||||||
SRBleUtil.instance.writeData(
|
// }
|
||||||
bleDevice, SRBleCmdUtil.instance.forcedShutdown()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -819,8 +816,22 @@ class HomeTrackFragment :
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
} else if (data0 == 4 && data1 == 1 && data2 == 0) {
|
} else if (data0 == 4 && data1 == 1 && data2 == 0) {
|
||||||
mMapDeviceBean?.let {
|
// mMapDeviceBean?.let {
|
||||||
mTrackerSetViewModel.turnOff(it.deviceServerId)
|
// mTrackerSetViewModel.turnOff(it.deviceServerId)
|
||||||
|
// }
|
||||||
|
// mTrackMenuList[1].menuValue = ""
|
||||||
|
// mTrackMenuList[2].menuValue = ""
|
||||||
|
// mTrackMenuList[3].menuValue = ""
|
||||||
|
// //取消红点显示
|
||||||
|
// mTrackMenuList[3].isSwitch = false
|
||||||
|
// mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
||||||
|
// mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
|
||||||
|
} else if (data0 == 0x18 && data1 == 1 && data2 == 0) {
|
||||||
|
mBleTrackDeviceBean?.apply {
|
||||||
|
SRBleUtil.instance.disconnectToMac(mac)
|
||||||
|
}
|
||||||
|
mMapDeviceBean?.let {ble->
|
||||||
|
mTrackerSetViewModel.turnOff(ble.deviceServerId)
|
||||||
}
|
}
|
||||||
mTrackMenuList[1].menuValue = ""
|
mTrackMenuList[1].menuValue = ""
|
||||||
mTrackMenuList[2].menuValue = ""
|
mTrackMenuList[2].menuValue = ""
|
||||||
@@ -829,10 +840,6 @@ class HomeTrackFragment :
|
|||||||
mTrackMenuList[3].isSwitch = false
|
mTrackMenuList[3].isSwitch = false
|
||||||
mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
mTrackMenuList[4].menuValue = ConstantInt.Close.toString()
|
||||||
mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
|
mTrackMenuAdapter.notifyItemRangeChanged(1, 4)
|
||||||
} else if (data0 == 0x18 && data1 == 1 && data2 == 0) {
|
|
||||||
mBleTrackDeviceBean?.apply {
|
|
||||||
SRBleUtil.instance.disconnectToMac(mac)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -114,10 +114,12 @@ abstract class BaseNetworkApi<I>(private val baseUrl: String) : IService<I> {
|
|||||||
|
|
||||||
//失败重试请求次数
|
//失败重试请求次数
|
||||||
private const val RETRY_COUNT = 1
|
private const val RETRY_COUNT = 1
|
||||||
|
//请求超时时间
|
||||||
|
private const val REQUEST_TIMEOUT=35L
|
||||||
private val defaultOkHttpClient by lazy {
|
private val defaultOkHttpClient by lazy {
|
||||||
val builder = OkHttpClient.Builder().callTimeout(10L, TimeUnit.SECONDS)
|
val builder = OkHttpClient.Builder().callTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
||||||
.connectTimeout(10L, TimeUnit.SECONDS).readTimeout(10L, TimeUnit.SECONDS)
|
.connectTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS).readTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS)
|
||||||
.writeTimeout(10L, TimeUnit.SECONDS).retryOnConnectionFailure(true)
|
.writeTimeout(REQUEST_TIMEOUT, TimeUnit.SECONDS).retryOnConnectionFailure(true)
|
||||||
//添加拦截器
|
//添加拦截器
|
||||||
builder.addInterceptor(CommonRequestInterceptor())
|
builder.addInterceptor(CommonRequestInterceptor())
|
||||||
builder.addInterceptor(CommonResponseInterceptor())
|
builder.addInterceptor(CommonResponseInterceptor())
|
||||||
|
|||||||
Reference in New Issue
Block a user