[6.10.0][Feat]状态栏新增高精地图数据缓存进度
This commit is contained in:
@@ -0,0 +1,78 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.os.Looper
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.mogo.eagle.core.function.api.map.deva.IMoGoMapDevaProvider
|
||||
import com.mogo.eagle.core.function.call.map.CallerMapDevaListenerManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import kotlinx.android.synthetic.main.view_map_download_progress.view.download_pb
|
||||
import kotlinx.android.synthetic.main.view_map_download_progress.view.ivBackground
|
||||
|
||||
class MapDownloadView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoMapDevaProvider {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "MapDownloadView"
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_map_download_progress, this)
|
||||
}
|
||||
|
||||
fun setProgress(pg: Int) {
|
||||
download_pb.progress = pg
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
CallerMapDevaListenerManager.addListener("${TAG}${this.hashCode()}", this)
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
CallerMapDevaListenerManager.removeListener("${TAG}${this.hashCode()}")
|
||||
}
|
||||
|
||||
private fun updateMapStatus(type: Int, progress: Int) {
|
||||
when (type) {
|
||||
-1 -> {// 下载失败
|
||||
visibility = View.VISIBLE
|
||||
download_pb.visibility = View.GONE
|
||||
ivBackground.setBackgroundResource(R.drawable.map_download_failed)
|
||||
}
|
||||
0 -> {// 下载成功
|
||||
visibility = View.VISIBLE
|
||||
download_pb.visibility = View.GONE
|
||||
ivBackground.setBackgroundResource(R.drawable.map_download_success)
|
||||
ThreadUtils.runOnUiThreadDelayed({
|
||||
visibility = View.GONE
|
||||
}, 3000)
|
||||
}
|
||||
else -> {// 下载中
|
||||
visibility = View.VISIBLE
|
||||
download_pb.visibility = View.VISIBLE
|
||||
ivBackground.setBackgroundResource(R.drawable.map_download_bg)
|
||||
download_pb.progress = progress
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun downloadStatus(type: Int, progress: Int) {
|
||||
if (Thread.currentThread() != Looper.getMainLooper().thread) {
|
||||
UiThreadHandler.post {
|
||||
updateMapStatus(type, progress)
|
||||
}
|
||||
} else {
|
||||
updateMapStatus(type, progress)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.mogo.eagle.core.function.hmi.ui.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ProgressBar
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
|
||||
class RoundProgressBar @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : ProgressBar(context, attrs) {
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
outlineProvider = TextureVideoViewOutlineProvider(AutoSizeUtils.dp2px(context, 1f).toFloat())
|
||||
clipToOutline = true
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 781 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 1.4 KiB |
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:id="@android:id/background">
|
||||
<shape>
|
||||
<solid android:color="#FFFFFF" />
|
||||
<!--下面是设置4个角的圆角-->
|
||||
<corners android:radius="0dp" />
|
||||
</shape>
|
||||
</item>
|
||||
<item android:id="@android:id/progress">
|
||||
<scale
|
||||
android:scaleWidth="0%"
|
||||
android:scaleHeight="100%"
|
||||
android:scaleGravity="bottom">
|
||||
<shape>
|
||||
<!--这里是设置填充颜色和方向-->
|
||||
<solid android:color="#5EBE5D" />
|
||||
<!--下面是设置4个角的圆角-->
|
||||
<corners android:radius="0dp" />
|
||||
</shape>
|
||||
</scale>
|
||||
</item>
|
||||
</layer-list>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="54dp"
|
||||
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/ivBackground"
|
||||
android:layout_width="54dp"
|
||||
android:layout_height="54dp"
|
||||
android:background="@drawable/map_download_bg"
|
||||
/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.RoundProgressBar
|
||||
android:id="@+id/download_pb"
|
||||
style="@style/Widget.AppCompat.ProgressBar.Horizontal"
|
||||
android:layout_width="6dp"
|
||||
android:layout_height="25dp"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginEnd="7dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:progressDrawable="@drawable/pb_vertical_drawable"
|
||||
android:progress="75"
|
||||
android:max="100"
|
||||
/>
|
||||
</merge>
|
||||
@@ -83,6 +83,14 @@
|
||||
android:background="@drawable/icon_status_route_download_complete"
|
||||
android:layout_gravity="center_vertical"/>
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.widget.MapDownloadView
|
||||
android:id="@+id/mapDownloadView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/dp_30"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
|
||||
<Space
|
||||
android:layout_width="0dip"
|
||||
android:layout_height="@dimen/dp_1"
|
||||
|
||||
Reference in New Issue
Block a user