优化route页交互体验,修复有无数据切换布局错位bug

This commit is contained in:
yezhiqiu
2026-04-17 15:43:29 +08:00
parent 3b55eaabf4
commit 4e46370ec1
6 changed files with 50 additions and 26 deletions

View File

@@ -30,7 +30,7 @@ android {
targetSdkVersion 35 targetSdkVersion 35
versionCode 2202 versionCode 2202
// versionName "2.2.2" // versionName "2.2.2"
versionName "2.2.2-Beta3" versionName "2.2.2-Beta4"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View File

@@ -75,28 +75,36 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
// private var isFirst = true // private var isFirst = true
private var mProgress = 0 private var mProgress = 0
//原来有列表一个元素的高度
private var mLastScrollViewHeight = 0
private var mTotalHeight = 0
private lateinit var mHistoryFenceAdapter: HistoryFenceAdapter private lateinit var mHistoryFenceAdapter: HistoryFenceAdapter
private val mAllHistoryFenceList = mutableListOf<MessageBean>() private val mAllHistoryFenceList = mutableListOf<MessageBean>()
//充值续费或升级返回类型 //充值续费或升级返回类型
private var mRechargeBackType = ConstantInt.SpecialType private var mRechargeBackType = ConstantInt.SpecialType
//列表是否展开 //列表是否滑到顶部展开
private var isListExpand = false private var isListExpand = false
//判断是否滑过 //判断是否滑过
private var isHaveSlide = false private var isHaveSlide = false
//手指滑动的y坐标点
private var mLastY = 0f private var mLastY = 0f
//手指滑动时布局移动高度
private var mDiffHeight = 0 private var mDiffHeight = 0
//是否上滑 //是否上滑
private var isSlideUp = false private var isSlideUp = false
//布局可以滑的总高度
private var mTotalHeight = 0
//底部列表有一个元素的高度+日历的高度
private var mLastScrollViewHeight = 0
//选择日期布局的高度包括有SeekBar的高度
private var mCalendarLayoutHaveSeekBarHeight = 0
// private lateinit var mTopSlideLayoutManager: TopSlideLayoutManager // private lateinit var mTopSlideLayoutManager: TopSlideLayoutManager
companion object { companion object {
@@ -148,6 +156,7 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
if (rlMapRouteLineV3TimeLayout.isVisible) { if (rlMapRouteLineV3TimeLayout.isVisible) {
if (mTotalHeight == 0) { if (mTotalHeight == 0) {
mTotalHeight = cvHomeRouteV3Card.height + svHomeRouteMapScroll.height mTotalHeight = cvHomeRouteV3Card.height + svHomeRouteMapScroll.height
mCalendarLayoutHaveSeekBarHeight = rlHomeRouteCalendarV3Layout.height
mLastScrollViewHeight = svHomeRouteMapScroll.height mLastScrollViewHeight = svHomeRouteMapScroll.height
} }
@@ -178,13 +187,20 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
MotionEvent.ACTION_UP -> { MotionEvent.ACTION_UP -> {
LogUtil.e("ACTION_UP") LogUtil.e("ACTION_UP")
// val layoutParams = svHomeRouteMapScroll.layoutParams
if (mDiffHeight > mTotalHeight / 2) { if (mDiffHeight > mTotalHeight / 2) {
setSeekBarShowHide(false) setSeekBarShowHide(false)
// layoutParams.height = mTotalHeight
// svHomeRouteMapScroll.layoutParams = layoutParams
animateViewHeight(svHomeRouteMapScroll, mTotalHeight)
isListExpand = true isListExpand = true
if (isSlideUp) {
animateViewHeight(svHomeRouteMapScroll, mTotalHeight)
} else {
animateViewHeight(svHomeRouteMapScroll, mTotalHeight / 2)
svHomeRouteMapScroll.postDelayed(
{
//重新设置地图缩放级别
mHistoryDataMapCommon.setLatLngData(mHistoryDataList)
}, 500
)
}
} else { } else {
if (mDiffHeight > mLastScrollViewHeight) { if (mDiffHeight > mLastScrollViewHeight) {
val height = if (isSlideUp) { val height = if (isSlideUp) {
@@ -203,11 +219,13 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
} }
mLastScrollViewHeight mLastScrollViewHeight
} }
animateViewHeight(svHomeRouteMapScroll, height, 300) animateViewHeight(svHomeRouteMapScroll, height)
} }
// svHomeRouteMapScroll.layoutParams = layoutParams
svHomeRouteMapScroll.postDelayed( svHomeRouteMapScroll.postDelayed(
{ mHistoryDataMapCommon.setLatLngData(mHistoryDataList) }, 500 {
//重新设置地图缩放级别
mHistoryDataMapCommon.setLatLngData(mHistoryDataList)
}, 500
) )
} }
} }
@@ -235,7 +253,7 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
initState() initState()
} }
private fun animateViewHeight(view: View, targetHeight: Int, duration: Long = 500) { private fun animateViewHeight(view: View, targetHeight: Int, duration: Long = 300) {
val animator = ValueAnimator.ofInt(view.height, targetHeight) val animator = ValueAnimator.ofInt(view.height, targetHeight)
animator.duration = duration // 设置动画持续时间 animator.duration = duration // 设置动画持续时间
animator.interpolator = LinearInterpolator() // 设置插值器 animator.interpolator = LinearInterpolator() // 设置插值器
@@ -387,18 +405,23 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
} }
} else { } else {
mViewBinding.rlMapRouteLineV3TimeLayout.visibility = View.GONE mViewBinding.rlMapRouteLineV3TimeLayout.visibility = View.GONE
if (isHaveSlide) {
val lastScrollViewNoListHeight = val lastScrollViewNoListHeight =
mViewBinding.rlHomeRouteCalendarV3Layout.height mViewBinding.rlHomeRouteCalendarV3Layout.height
if (isHaveSlide) {
val layoutParams = val layoutParams =
mViewBinding.svHomeRouteMapScroll.layoutParams mViewBinding.svHomeRouteMapScroll.layoutParams
layoutParams.height = lastScrollViewNoListHeight layoutParams.height =
if (mViewBinding.vsbMapRouteLineV3.isVisible) mCalendarLayoutHaveSeekBarHeight
else lastScrollViewNoListHeight
mViewBinding.svHomeRouteMapScroll.layoutParams = layoutParams mViewBinding.svHomeRouteMapScroll.layoutParams = layoutParams
} }
isListExpand = false isListExpand = false
} }
if (mViewBinding.cvHomeRouteV3Card.height > 0) mViewBinding.svHomeRouteMapScroll.postDelayed( if (mViewBinding.cvHomeRouteV3Card.height > 0) mViewBinding.svHomeRouteMapScroll.postDelayed(
{ mHistoryDataMapCommon.setLatLngData(mHistoryDataList) }, 200 {
//重新设置地图缩放级别
mHistoryDataMapCommon.setLatLngData(mHistoryDataList)
}, 200
) )
} }
} }
@@ -508,7 +531,9 @@ class RouteV3Fragment : BaseFragment<FragmentRouteV3Binding>(FragmentRouteV3Bind
vsbMapRouteLineV3.visibility = View.VISIBLE vsbMapRouteLineV3.visibility = View.VISIBLE
ivMapRouteLineV3LastBtn.visibility = View.VISIBLE ivMapRouteLineV3LastBtn.visibility = View.VISIBLE
ivMapRouteLineV3NextBtn.visibility = View.VISIBLE ivMapRouteLineV3NextBtn.visibility = View.VISIBLE
LogUtil.e("显示")
} else { } else {
LogUtil.e("隐藏")
vsbMapRouteLineV3.visibility = View.GONE vsbMapRouteLineV3.visibility = View.GONE
ivMapRouteLineV3LastBtn.visibility = View.GONE ivMapRouteLineV3LastBtn.visibility = View.GONE
ivMapRouteLineV3NextBtn.visibility = View.GONE ivMapRouteLineV3NextBtn.visibility = View.GONE

View File

@@ -859,7 +859,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
if (SRBleUtil.instance.isMacConnect(pet.macID)) { if (SRBleUtil.instance.isMacConnect(pet.macID)) {
showToast(R.string.txt_pet_close, gravity = Gravity.CENTER) showToast(R.string.txt_pet_close, gravity = Gravity.CENTER)
} else if (null != mMapDeviceBean && mMapDeviceBean!!.powerSwitch == ConstantInt.Type2) { } else if (null != mMapDeviceBean && mMapDeviceBean!!.powerSwitch == ConstantInt.Type2) {
val string = String.format(getString(R.string.txt_move_wake), pet.petName) val string = String.format(getString(R.string.txt_move_wake_up), pet.petName)
showToast(string, gravity = Gravity.CENTER) showToast(string, gravity = Gravity.CENTER)
} else if (!isCanLive) { } else if (!isCanLive) {
showToast(R.string.txt_locate_works, gravity = Gravity.CENTER) showToast(R.string.txt_locate_works, gravity = Gravity.CENTER)
@@ -956,7 +956,7 @@ class MapV3Fragment : BaseFragment<FragmentMapV3Binding>(FragmentMapV3Binding::i
) )
ViewUtil.instance.addMenuBean( ViewUtil.instance.addMenuBean(
mapList, mapList,
getString(R.string.map_navigate_map_baidu), getString(R.string.map_baidu_map),
mMapBaiduPackageName, mMapBaiduPackageName,
R.drawable.ico_map_gaode R.drawable.ico_map_gaode
) )

View File

@@ -454,7 +454,7 @@ class MapViewModel : ViewModel() {
R.drawable.icon_device_sleep_image, 0, 0, 0 R.drawable.icon_device_sleep_image, 0, 0, 0
) )
it.text = String.format( it.text = String.format(
context.getString(R.string.txt_fully_asleep), context.getString(R.string.txt_fell_asleep),
getTimeDifference(updateTime * 1000, System.currentTimeMillis()) getTimeDifference(updateTime * 1000, System.currentTimeMillis())
) )
ViewUtil.instance.viewShow(closeBtn) ViewUtil.instance.viewShow(closeBtn)

View File

@@ -53,7 +53,6 @@
android:id="@+id/rl_home_route_calendar_v3_layout" android:id="@+id/rl_home_route_calendar_v3_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginHorizontal="@dimen/dp_8" android:layout_marginHorizontal="@dimen/dp_8"
android:background="@drawable/shape_home_route_calendar_bg" android:background="@drawable/shape_home_route_calendar_bg"
android:padding="@dimen/dp_12"> android:padding="@dimen/dp_12">

View File

@@ -1073,9 +1073,9 @@
<string name="txt_load_more_pull_text">Pull to load more</string> <string name="txt_load_more_pull_text">Pull to load more</string>
<string name="txt_load_more_release_text">Release to load</string> <string name="txt_load_more_release_text">Release to load</string>
<string name="txt_fully_charged">Fully charged</string> <string name="txt_fully_charged">Fully charged</string>
<string name="txt_fully_asleep">Fell asleep %s ago</string> <string name="txt_fell_asleep">Fell asleep %s ago</string>
<string name="txt_move_wake">Move %s to wake up</string> <string name="txt_move_wake_up">Move %s to wake up</string>
<string name="map_navigate_map_baidu">Baidu Map</string> <string name="map_baidu_map">Baidu Map</string>
<string name="txt_time_line">Timeline</string> <string name="txt_time_line">Timeline</string>
<string name="txt_phone_close_device">Keep phone close to device</string> <string name="txt_phone_close_device">Keep phone close to device</string>