1.修改没连接蓝牙,删除wifi,提示蓝牙没连接
2.删除led灯的色盘 3.优化蓝牙找设备声音播放问题 4.map页切换宠物,先清除上一个宠物的地图上信息
This commit is contained in:
@@ -178,7 +178,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
|||||||
mPetBean?.apply {
|
mPetBean?.apply {
|
||||||
//查找是否连接了蓝牙
|
//查找是否连接了蓝牙
|
||||||
SRBleUtil.instance.getConnectMacDevice(macID)?.let {
|
SRBleUtil.instance.getConnectMacDevice(macID)?.let {
|
||||||
updateConState(it)
|
updateConState(it, false)
|
||||||
}
|
}
|
||||||
mTrackerManageSetViewModel.getPetTrackerInfo(this@LedLightActivity, deviceId)
|
mTrackerManageSetViewModel.getPetTrackerInfo(this@LedLightActivity, deviceId)
|
||||||
}
|
}
|
||||||
@@ -235,7 +235,7 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
|||||||
/**
|
/**
|
||||||
* 更新设备连接状态
|
* 更新设备连接状态
|
||||||
*/
|
*/
|
||||||
private fun updateConState(trackBleDevice: BleTrackDeviceBean) {
|
private fun updateConState(trackBleDevice: BleTrackDeviceBean, isShowToast: Boolean = true) {
|
||||||
mBleTrackDeviceBean = trackBleDevice
|
mBleTrackDeviceBean = trackBleDevice
|
||||||
mViewBinding.ledLightBluetoothTips.trbBleConnectState.let { view ->
|
mViewBinding.ledLightBluetoothTips.trbBleConnectState.let { view ->
|
||||||
val bgColor = if (trackBleDevice.conState == ConState.CONNECTED) {
|
val bgColor = if (trackBleDevice.conState == ConState.CONNECTED) {
|
||||||
@@ -248,8 +248,10 @@ class LedLightActivity : BaseActivity<ActivityLedLightBinding>(ActivityLedLightB
|
|||||||
}
|
}
|
||||||
view.setBackgroundColor(bgColor)
|
view.setBackgroundColor(bgColor)
|
||||||
}
|
}
|
||||||
|
if (isShowToast) {
|
||||||
ViewUtil.instance.bleConStateToast(this, trackBleDevice.conState, Gravity.CENTER)
|
ViewUtil.instance.bleConStateToast(this, trackBleDevice.conState, Gravity.CENTER)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setBleLedMode(mode: Int) {
|
private fun setBleLedMode(mode: Int) {
|
||||||
mBleTrackDeviceBean?.apply {
|
mBleTrackDeviceBean?.apply {
|
||||||
|
|||||||
@@ -321,6 +321,10 @@ class EditWifiPowerZoneActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun deleteWifiZone() {
|
private fun deleteWifiZone() {
|
||||||
|
if (null == mBleTrackDeviceBean) {
|
||||||
|
showToast(R.string.tracker_manage_set_ble_unconnect, gravity = Gravity.CENTER)
|
||||||
|
return
|
||||||
|
}
|
||||||
ViewUtil.instance.showDialog(
|
ViewUtil.instance.showDialog(
|
||||||
mContext, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
|
mContext, R.string.txt_delete_tips, object : BaseDialog.OnDialogOkListener {
|
||||||
override fun onOkClick(dialog: BaseDialog<*>) {
|
override fun onOkClick(dialog: BaseDialog<*>) {
|
||||||
@@ -382,6 +386,10 @@ class EditWifiPowerZoneActivity :
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun senCmd(cmd: ByteArray) {
|
private fun senCmd(cmd: ByteArray) {
|
||||||
|
if (null == mBleTrackDeviceBean) {
|
||||||
|
showToast(R.string.tracker_manage_set_ble_unconnect, gravity = Gravity.CENTER)
|
||||||
|
return
|
||||||
|
}
|
||||||
mBleTrackDeviceBean?.apply {
|
mBleTrackDeviceBean?.apply {
|
||||||
//判断是否有蓝牙连接
|
//判断是否有蓝牙连接
|
||||||
if (BleManager.getInstance().isConnected(bleDevice)) {
|
if (BleManager.getInstance().isConnected(bleDevice)) {
|
||||||
|
|||||||
@@ -342,12 +342,10 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
|||||||
}
|
}
|
||||||
|
|
||||||
//接收蓝牙连接状态
|
//接收蓝牙连接状态
|
||||||
XEventBus.observe(
|
XEventBus.observe(this, EventName.ConnectDeviceState) { trackBle: BleTrackDeviceBean ->
|
||||||
this, EventName.ConnectDeviceState
|
|
||||||
) { trackBleDevice: BleTrackDeviceBean ->
|
|
||||||
mMapDeviceBean?.apply {
|
mMapDeviceBean?.apply {
|
||||||
if (trackBleDevice.mac == deviceMacId) {
|
if (trackBle.mac == deviceMacId) {
|
||||||
updateConState(trackBleDevice)
|
updateConState(trackBle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -586,7 +584,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
|||||||
if (isLiveJump) {
|
if (isLiveJump) {
|
||||||
openNetLive(ConstantInt.Type2)
|
openNetLive(ConstantInt.Type2)
|
||||||
}
|
}
|
||||||
} else if (trackBleDevice.conState == ConState.DISCONNECTED) {
|
} else {
|
||||||
if (isLiveJump && isStartLive) {
|
if (isLiveJump && isStartLive) {
|
||||||
mPetBean?.apply {
|
mPetBean?.apply {
|
||||||
//直播开启后,就去获取直播轨迹
|
//直播开启后,就去获取直播轨迹
|
||||||
@@ -594,9 +592,6 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
|||||||
mMapLiveViewModel.getPetLivePoint(deviceId)
|
mMapLiveViewModel.getPetLivePoint(deviceId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
// showToast(R.string.tracker_manage_set_ble_unconnect)
|
|
||||||
// mViewBinding.ilLiveV2BluetoothFindDevice.ivMapLiveV2BleConState.setValue(0)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -940,6 +935,7 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
|||||||
*/
|
*/
|
||||||
private fun stopLive() {
|
private fun stopLive() {
|
||||||
mPetBean?.apply {
|
mPetBean?.apply {
|
||||||
|
setButtonEnabled(mViewBinding.ilLiveV2OperateLayout.llLiveV2StopLive, ConstantInt.Type0)
|
||||||
if (BleManager.getInstance().isConnected(macID)) {
|
if (BleManager.getInstance().isConnected(macID)) {
|
||||||
SRBleUtil.instance.isConnectBleSendCmdData(
|
SRBleUtil.instance.isConnectBleSendCmdData(
|
||||||
macID, SRBleCmdUtil.instance.setLiveSwitch(0, 0)
|
macID, SRBleCmdUtil.instance.setLiveSwitch(0, 0)
|
||||||
@@ -992,8 +988,8 @@ class LiveActivityV2 : BaseActivity<ActivityLiveV2Binding>(ActivityLiveV2Binding
|
|||||||
isOpenSound = true
|
isOpenSound = true
|
||||||
setSound()
|
setSound()
|
||||||
showAndHideFindLayout()
|
showAndHideFindLayout()
|
||||||
mFindBleDeviceViewModel.stopFindDevice()
|
|
||||||
} else {
|
} else {
|
||||||
|
mFindBleDeviceViewModel.stopFindDevice()
|
||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,6 +72,14 @@ class HomeMapCommon @Inject constructor() : BaseMapCommon() {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun clearMarker() {
|
||||||
|
if (null != mHomeMapBaiduMapFragment) {
|
||||||
|
mHomeMapBaiduMapFragment!!.mBaiduMap?.clear()
|
||||||
|
} else if (null != mHomeMapGoogleMapFragment) {
|
||||||
|
mHomeMapGoogleMapFragment!!.mGoogleMap?.clear()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fun refreshPetCurrentLocation(latitude: Double, longitude: Double, isAnimMoveCamera: Boolean) {
|
fun refreshPetCurrentLocation(latitude: Double, longitude: Double, isAnimMoveCamera: Boolean) {
|
||||||
if (null != mHomeMapBaiduMapFragment) {
|
if (null != mHomeMapBaiduMapFragment) {
|
||||||
mHomeMapBaiduMapFragment?.apply {
|
mHomeMapBaiduMapFragment?.apply {
|
||||||
|
|||||||
@@ -512,6 +512,9 @@ class MapV2Fragment : BaseFragment<FragmentMapV2Binding>(FragmentMapV2Binding::i
|
|||||||
)
|
)
|
||||||
|
|
||||||
if (mHomeMapCommon.isMapLoadOk()) {
|
if (mHomeMapCommon.isMapLoadOk()) {
|
||||||
|
mHomeMapCommon.clearMarker()
|
||||||
|
mViewBinding.miHomeMapAddressView.visibility = View.GONE
|
||||||
|
mViewBinding.rvHomeMapDeviceMsg.visibility = View.GONE
|
||||||
showLoading(true)
|
showLoading(true)
|
||||||
val pet = mHomeV2Activity.mPetList[position]
|
val pet = mHomeV2Activity.mPetList[position]
|
||||||
//重新设置地图宠物头像
|
//重新设置地图宠物头像
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ import com.abbidot.tracker.databinding.FragmentGoogleMapBinding
|
|||||||
import com.abbidot.tracker.util.ImageUtil
|
import com.abbidot.tracker.util.ImageUtil
|
||||||
import com.abbidot.tracker.util.LonAndLatUtil
|
import com.abbidot.tracker.util.LonAndLatUtil
|
||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.widget.MapDeviceNetView
|
import com.abbidot.tracker.widget.MapDeviceNetView
|
||||||
import com.abbidot.tracker.widget.MapMarkerInfoView
|
import com.abbidot.tracker.widget.MapMarkerInfoView
|
||||||
import com.google.android.gms.location.FusedLocationProviderClient
|
import com.google.android.gms.location.FusedLocationProviderClient
|
||||||
@@ -1059,6 +1060,7 @@ abstract class BaseGoogleMapFragment :
|
|||||||
*/
|
*/
|
||||||
fun setMarkerInfoViewOffset(markerInfoView: MapMarkerInfoView, latLng: LatLng) {
|
fun setMarkerInfoViewOffset(markerInfoView: MapMarkerInfoView, latLng: LatLng) {
|
||||||
mGoogleMap?.projection?.toScreenLocation(latLng)?.let {
|
mGoogleMap?.projection?.toScreenLocation(latLng)?.let {
|
||||||
|
ViewUtil.instance.viewShow(markerInfoView)
|
||||||
markerInfoView.setOffsetXY(it.x, it.y - AppUtils.dpToPx(56))
|
markerInfoView.setOffsetXY(it.x, it.y - AppUtils.dpToPx(56))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,9 @@ package com.abbidot.tracker.ui.fragment.map.googlemap
|
|||||||
|
|
||||||
import android.animation.ValueAnimator
|
import android.animation.ValueAnimator
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.view.View
|
|
||||||
import android.view.animation.LinearInterpolator
|
import android.view.animation.LinearInterpolator
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isVisible
|
||||||
import androidx.fragment.app.viewModels
|
import androidx.fragment.app.viewModels
|
||||||
import com.abbidot.baselibrary.util.AppUtils
|
import com.abbidot.baselibrary.util.AppUtils
|
||||||
import com.abbidot.baselibrary.util.Utils
|
import com.abbidot.baselibrary.util.Utils
|
||||||
@@ -94,7 +94,7 @@ class HomeMapGoogleMapFragment : BaseGoogleMapFragment() {
|
|||||||
// mMarker?.tag = history
|
// mMarker?.tag = history
|
||||||
|
|
||||||
// showMarkerInfoWindow(history)
|
// showMarkerInfoWindow(history)
|
||||||
mMarkerInfoView.visibility = View.VISIBLE
|
ViewUtil.instance.viewShow(mMarkerInfoView)
|
||||||
mMarkerInfoView.setShowText(timeString, it)
|
mMarkerInfoView.setShowText(timeString, it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@ class HomeMapGoogleMapFragment : BaseGoogleMapFragment() {
|
|||||||
//设置自定义头部地点布局
|
//设置自定义头部地点布局
|
||||||
mGoogleMap?.apply {
|
mGoogleMap?.apply {
|
||||||
setOnCameraMoveListener {
|
setOnCameraMoveListener {
|
||||||
setMarkerInfoViewOffset()
|
if (mMarkerInfoView.isVisible) setMarkerInfoViewOffset()
|
||||||
}
|
}
|
||||||
getLastLocation()
|
getLastLocation()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import android.widget.RelativeLayout
|
|||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.annotation.DrawableRes
|
import androidx.annotation.DrawableRes
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.isGone
|
||||||
import androidx.core.view.setPadding
|
import androidx.core.view.setPadding
|
||||||
import androidx.core.widget.addTextChangedListener
|
import androidx.core.widget.addTextChangedListener
|
||||||
import androidx.fragment.app.FragmentActivity
|
import androidx.fragment.app.FragmentActivity
|
||||||
@@ -1110,4 +1111,8 @@ class ViewUtil private constructor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun viewShow(view: View) {
|
||||||
|
if (view.isGone) view.visibility = View.VISIBLE
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ class FindBleDeviceViewModel : ViewModel() {
|
|||||||
//播放的速度
|
//播放的速度
|
||||||
private var mSetPlaySpeed = 0.5f
|
private var mSetPlaySpeed = 0.5f
|
||||||
|
|
||||||
private var isStartFindBleDevice = false
|
private var isStopReadRssi = false
|
||||||
|
|
||||||
private var mCountDownTimer: CountDownTimer? = null
|
private var mCountDownTimer: CountDownTimer? = null
|
||||||
|
|
||||||
@@ -79,7 +79,6 @@ class FindBleDeviceViewModel : ViewModel() {
|
|||||||
|
|
||||||
viewModelScope.launch(Dispatchers.IO) {
|
viewModelScope.launch(Dispatchers.IO) {
|
||||||
|
|
||||||
isStartFindBleDevice = true
|
|
||||||
mAudioManager = activity.getSystemService(Service.AUDIO_SERVICE) as AudioManager
|
mAudioManager = activity.getSystemService(Service.AUDIO_SERVICE) as AudioManager
|
||||||
mPhoneOriginalVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
mPhoneOriginalVolume = mAudioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
||||||
mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
mMaxVolume = mAudioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
||||||
@@ -89,6 +88,7 @@ class FindBleDeviceViewModel : ViewModel() {
|
|||||||
|
|
||||||
if (BleManager.getInstance().isConnected(mac)) {
|
if (BleManager.getInstance().isConnected(mac)) {
|
||||||
LogUtil.e("是已连接的设备,直接获取信号")
|
LogUtil.e("是已连接的设备,直接获取信号")
|
||||||
|
mCountDownTimer?.cancel()
|
||||||
activity.runOnUiThread {
|
activity.runOnUiThread {
|
||||||
countDownReadConnectRssi {
|
countDownReadConnectRssi {
|
||||||
SRBleUtil.instance.readConnectRssi(mac, object : BleRssiCallback() {
|
SRBleUtil.instance.readConnectRssi(mac, object : BleRssiCallback() {
|
||||||
@@ -97,7 +97,11 @@ class FindBleDeviceViewModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onRssiSuccess(rssi: Int) {
|
override fun onRssiSuccess(rssi: Int) {
|
||||||
LogUtil.e("FindBleDeviceViewModel--->获取连接设备信号onRssiSuccess$rssi...")
|
LogUtil.e("FindBleDeviceViewModel--->获取连接设备信号onRssiSuccess$rssi...$isStopReadRssi")
|
||||||
|
if (isStopReadRssi) {
|
||||||
|
mCountDownTimer?.cancel()
|
||||||
|
return
|
||||||
|
}
|
||||||
speed = getPlaySpeed(rssi)
|
speed = getPlaySpeed(rssi)
|
||||||
val value = getSignalValue(rssi)
|
val value = getSignalValue(rssi)
|
||||||
signalView.setValue(value)
|
signalView.setValue(value)
|
||||||
@@ -272,20 +276,20 @@ class FindBleDeviceViewModel : ViewModel() {
|
|||||||
* 停止查找设备
|
* 停止查找设备
|
||||||
*/
|
*/
|
||||||
fun stopFindDevice() {
|
fun stopFindDevice() {
|
||||||
if (!isStartFindBleDevice) return
|
|
||||||
SRBleUtil.instance.cancelBleScan("停止查找设备取消扫描蓝牙")
|
SRBleUtil.instance.cancelBleScan("停止查找设备取消扫描蓝牙")
|
||||||
|
isStopReadRssi = true
|
||||||
|
mCountDownTimer?.cancel()
|
||||||
//还原手机原来的音量
|
//还原手机原来的音量
|
||||||
setVolume(mPhoneOriginalVolume)
|
setVolume(mPhoneOriginalVolume)
|
||||||
isStartFindBleDevice = false
|
|
||||||
mCountDownTimer?.cancel()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCleared() {
|
override fun onCleared() {
|
||||||
super.onCleared()
|
super.onCleared()
|
||||||
|
LogUtil.e("FindBleDeviceViewModel onCleared")
|
||||||
|
stopFindDevice()
|
||||||
mSoundPool?.apply {
|
mSoundPool?.apply {
|
||||||
if (mStreamID > 0) stop(mStreamID)
|
if (mStreamID > 0) stop(mStreamID)
|
||||||
release()
|
release()
|
||||||
}
|
}
|
||||||
stopFindDevice()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,6 +15,7 @@ import com.abbidot.tracker.bean.PetBean
|
|||||||
import com.abbidot.tracker.constant.ConstantInt
|
import com.abbidot.tracker.constant.ConstantInt
|
||||||
import com.abbidot.tracker.retrofit2.NetworkApi
|
import com.abbidot.tracker.retrofit2.NetworkApi
|
||||||
import com.abbidot.tracker.util.Util
|
import com.abbidot.tracker.util.Util
|
||||||
|
import com.abbidot.tracker.util.ViewUtil
|
||||||
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
import com.abbidot.tracker.util.bluetooth.SRBleUtil
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
|
||||||
@@ -116,6 +117,7 @@ class MapViewModel : ViewModel() {
|
|||||||
rvMsg: RecyclerView,
|
rvMsg: RecyclerView,
|
||||||
isLive: Boolean = false
|
isLive: Boolean = false
|
||||||
) {
|
) {
|
||||||
|
ViewUtil.instance.viewShow(rvMsg)
|
||||||
mapDeviceBean.apply {
|
mapDeviceBean.apply {
|
||||||
deviceMsgList.clear()
|
deviceMsgList.clear()
|
||||||
//设备关机
|
//设备关机
|
||||||
|
|||||||
@@ -93,7 +93,8 @@
|
|||||||
android:layout_marginTop="@dimen/dp_10"
|
android:layout_marginTop="@dimen/dp_10"
|
||||||
android:layout_marginBottom="@dimen/dp_50"
|
android:layout_marginBottom="@dimen/dp_50"
|
||||||
android:background="@drawable/shape8_white_bg"
|
android:background="@drawable/shape8_white_bg"
|
||||||
android:padding="@dimen/dp_16">
|
android:padding="@dimen/dp_16"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
<com.abbidot.tracker.widget.TypefaceTextView
|
<com.abbidot.tracker.widget.TypefaceTextView
|
||||||
android:id="@+id/tv_led_light_current_rgb"
|
android:id="@+id/tv_led_light_current_rgb"
|
||||||
|
|||||||
Reference in New Issue
Block a user