diff --git a/app/src/main/java/com/abbidot/tracker/adapter/TopSlideLayoutManager.java b/app/src/main/java/com/abbidot/tracker/adapter/TopSlideLayoutManager.java index acdcc25..62b971e 100644 --- a/app/src/main/java/com/abbidot/tracker/adapter/TopSlideLayoutManager.java +++ b/app/src/main/java/com/abbidot/tracker/adapter/TopSlideLayoutManager.java @@ -32,7 +32,8 @@ public class TopSlideLayoutManager extends LinearLayoutManager { View firstChild = getChildAt(0); if (firstChild != null) { int top = getDecoratedTop(firstChild) - mTopOffset; - layoutDecoratedWithMargins(firstChild, firstChild.getLeft(), top, firstChild.getRight(), top + firstChild.getHeight()); + layoutDecoratedWithMargins(firstChild, firstChild.getLeft(), top, + firstChild.getRight(), top + firstChild.getHeight()); } } } diff --git a/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt b/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt index 719f3f8..a42131e 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/activity/HomeV2Activity.kt @@ -310,7 +310,7 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding //蓝牙连接就去连接socket // mBleReportManage.dealBleReportData(macID, null) } else { - mLogBleReportViewModel.uploadLog(mContext, macID) + mLogBleReportViewModel.uploadLog(mContext, macID,deviceOutId) startCountDownConBle(15) } } @@ -454,7 +454,7 @@ class HomeV2Activity : BaseActivity(ActivityHomeV2Binding packageUnavailableState() //刚开始打开APP上传日志 getPet(false)?.apply { - mLogBleReportViewModel.uploadLog(mContext, macID) + mLogBleReportViewModel.uploadLog(mContext, macID,deviceOutId) } } else { onChangeClick(mSelectPetPosition) diff --git a/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV3Fragment.kt b/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV3Fragment.kt index 40858d8..be3219f 100644 --- a/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV3Fragment.kt +++ b/app/src/main/java/com/abbidot/tracker/ui/fragment/data/RouteV3Fragment.kt @@ -35,6 +35,7 @@ import com.abbidot.tracker.vm.GeoCoderViewModel import com.abbidot.tracker.widget.NoClickSlideSeekBar import com.abbidot.tracker.widget.TypefaceTextView import kotlinx.coroutines.launch +import kotlin.math.abs /** @@ -156,18 +157,20 @@ class RouteV3Fragment : BaseFragment(FragmentRouteV3Bind MotionEvent.ACTION_MOVE -> { val dy = mLastY - event.rawY - val layoutParams = svHomeRouteMapScroll.layoutParams - val diff = (svHomeRouteMapScroll.height + dy).toInt() - isSlideUp = dy >= 0.0f - if (diff > mLastScrollViewHeight) { - isHaveSlide = true - if (mHistoryFenceAdapter.getData().size != mAllHistoryFenceList.size) { - mHistoryFenceAdapter.setData(mAllHistoryFenceList, true) + if (abs(dy) >50){ + val layoutParams = svHomeRouteMapScroll.layoutParams + val diff = (svHomeRouteMapScroll.height + dy).toInt() + isSlideUp = dy >= 0.0f + if (diff > mLastScrollViewHeight) { + isHaveSlide = true + if (mHistoryFenceAdapter.getData().size != mAllHistoryFenceList.size) { + mHistoryFenceAdapter.setData(mAllHistoryFenceList, true) + } + mDiffHeight = diff + layoutParams.height = diff + svHomeRouteMapScroll.layoutParams = layoutParams + mLastY = event.rawY } - mDiffHeight = diff - layoutParams.height = diff - svHomeRouteMapScroll.layoutParams = layoutParams - mLastY = event.rawY } } diff --git a/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt b/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt index ca49128..3e1514b 100644 --- a/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt +++ b/app/src/main/java/com/abbidot/tracker/util/bluetooth/SRBleUtil.kt @@ -17,7 +17,6 @@ import com.abbidot.baselibrary.util.AppUtils import com.abbidot.baselibrary.util.LogUtil import com.abbidot.tracker.bean.BleTrackDeviceBean import com.abbidot.tracker.bean.ReceiveDeviceData -import com.abbidot.tracker.util.SocketUtilManage import com.abbidot.tracker.util.SocketUtilManageV2 import com.abbidot.tracker.util.Util import com.clj.fastble.BleManager @@ -68,8 +67,12 @@ class SRBleUtil private constructor() { UUID.fromString("6e400004-b5a3-f393-e0a9-e50e24dcca9e").toString() //日志上报notify - private val logNotifyCharacteristicUUID = + private val logG30NotifyCharacteristicUUID = UUID.fromString("6e400005-b5a3-f393-e0a9-e50e24dcca9e").toString() + private val logG40ServiceUUID = + UUID.fromString("0000d0d0-0000-1000-8000-00805f9b34fb").toString() + private val logG40NotifyCharacteristicUUID = + UUID.fromString("0000d0d2-0000-1000-8000-00805f9b34fb").toString() //保存已连接成功设备的全局变量 private val mTrackDeviceList = mutableListOf() @@ -192,11 +195,11 @@ class SRBleUtil private constructor() { * 打开通道通知 */ fun openNotify( - bleDevice: BleDevice, gatt: BluetoothGatt, uuid_service: String, uuid_notify: String + bleDevice: BleDevice, gatt: BluetoothGatt, uuidService: String, uuidNotify: String ) { - val notifyId = uuid_notify.split("-")[0] + val notifyId = uuidNotify.split("-")[0] BleManager.getInstance() - .notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() { + .notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() { override fun onNotifySuccess() { LogUtil.e("onNotifySuccess:${bleDevice.name}--${bleDevice.mac}") //绑定 @@ -250,18 +253,22 @@ class SRBleUtil private constructor() { * 打开蓝牙日志上报通道 */ private fun openBleReportNotify( - bleDevice: BleDevice, uuid_service: String, uuid_notify: String + bleDevice: BleDevice, uuidService: String, uuidNotify: String ) { BleManager.getInstance() - .notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() { + .notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() { override fun onNotifySuccess() { LogUtil.e("打开蓝牙上报通道成功:${bleDevice.name}--${bleDevice.mac}") - openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID) + openG30LogReportNotify( + bleDevice, notifyServiceUUID, logG30NotifyCharacteristicUUID + ) } override fun onNotifyFailure(exception: BleException?) { LogUtil.e("打开蓝牙上报通道失败:${bleDevice.mac},$exception") - openLogReportNotify(bleDevice, notifyServiceUUID, logNotifyCharacteristicUUID) + openG30LogReportNotify( + bleDevice, notifyServiceUUID, logG30NotifyCharacteristicUUID + ) } override fun onCharacteristicChanged(data: ByteArray?) { @@ -276,13 +283,44 @@ class SRBleUtil private constructor() { } /** - * 打开日志上报通道 + * 打开g30日志上报通道 */ - private fun openLogReportNotify( - bleDevice: BleDevice, uuid_service: String, uuid_notify: String + private fun openG30LogReportNotify( + bleDevice: BleDevice, uuidService: String, uuidNotify: String ) { BleManager.getInstance() - .notify(bleDevice, uuid_service, uuid_notify, object : BleNotifyCallback() { + .notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() { + override fun onNotifySuccess() { + LogUtil.e("打开日志上报通道成功:${bleDevice.name}--${bleDevice.mac}") + notifyDeviceState(bleDevice, ConState.CONNECTED) + } + + override fun onNotifyFailure(exception: BleException?) { + LogUtil.e("打开日志上报通道失败:${bleDevice.mac},$exception") + openG40LogReportNotify( + bleDevice, + logG40ServiceUUID, + logG40NotifyCharacteristicUUID + ) + } + + override fun onCharacteristicChanged(data: ByteArray?) { + data?.apply { + val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac) + XEventBus.post(EventName.LogReport, deviceData) + } + } + }) + } + + /** + * 打开g40日志上报通道 + */ + private fun openG40LogReportNotify( + bleDevice: BleDevice, uuidService: String, uuidNotify: String + ) { + BleManager.getInstance() + .notify(bleDevice, uuidService, uuidNotify, object : BleNotifyCallback() { override fun onNotifySuccess() { LogUtil.e("打开日志上报通道成功:${bleDevice.name}--${bleDevice.mac}") notifyDeviceState(bleDevice, ConState.CONNECTED) @@ -295,9 +333,6 @@ class SRBleUtil private constructor() { override fun onCharacteristicChanged(data: ByteArray?) { data?.apply { -// val formatData = HexUtil.formatHexString(data, true) -// LogUtil.e("接收日志上报通道数据:${bleDevice.mac},$formatData") -// LogUtil.e(String(data, Charsets.UTF_8)) val deviceData = ReceiveDeviceData(bleDevice, data, bleDevice.mac) XEventBus.post(EventName.LogReport, deviceData) } @@ -308,8 +343,8 @@ class SRBleUtil private constructor() { /** * 关闭通道通知 */ - fun closeNotify(bleDevice: BleDevice, uuid_service: String, uuid_notify: String) { - BleManager.getInstance().stopNotify(bleDevice, uuid_service, uuid_notify) + fun closeNotify(bleDevice: BleDevice, uuidService: String, uuidNotify: String) { + BleManager.getInstance().stopNotify(bleDevice, uuidService, uuidNotify) } diff --git a/app/src/main/java/com/abbidot/tracker/vm/LogBleReportViewModel.kt b/app/src/main/java/com/abbidot/tracker/vm/LogBleReportViewModel.kt index 418f73a..552b5e8 100644 --- a/app/src/main/java/com/abbidot/tracker/vm/LogBleReportViewModel.kt +++ b/app/src/main/java/com/abbidot/tracker/vm/LogBleReportViewModel.kt @@ -60,7 +60,7 @@ class LogBleReportViewModel : ViewModel() { /** * 设备日志上传 */ - fun uploadLog(context: Context, mac: String) { + fun uploadLog(context: Context, mac: String, deviceOutId: String) { //是否有网络功能 if (QMUIDisplayHelper.hasInternet(context)) { viewModelScope.launch { @@ -72,7 +72,8 @@ class LogBleReportViewModel : ViewModel() { fileName ) if (file.exists()) { - val newFileName = "${mac}_${System.currentTimeMillis()}.txt" + val newFileName = + "${deviceOutId}_${mac}_${System.currentTimeMillis() / 1000}.txt" val newFile = File( FileUtil.getDiskCacheDirectory( context, FileUtil.LOG_DIRECTORY_NAME