[m2] m2 UI处理

This commit is contained in:
wangmingjun
2023-02-16 21:21:50 +08:00
parent 2ab50dc6c8
commit a1a597435c
16 changed files with 97 additions and 83 deletions

View File

@@ -14,6 +14,7 @@ import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListener
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
import com.mogo.eagle.core.function.call.telematic.CallerTelematicListenerManager
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
import com.mogo.eagle.core.utilcode.util.GsonUtils
@@ -101,6 +102,8 @@ class PM2DrivingModel private constructor() {
// 定位监听
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
CallerTelematicListenerManager.removeListener(TAG)
}
fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback?){
@@ -115,7 +118,8 @@ class PM2DrivingModel private constructor() {
object : IReceivedMsgListener{
override fun onReceivedMsg(type: Int, byteArray: ByteArray) {//接收司机端发来的信息
if (TelematicConstant.BUSINESS_STRING == type){
val msg = GsonUtils.fromJson(byteArray.toString(),AppConnectMsg::class.java) as AppConnectMsg
val msg = GsonUtils.fromJson(String(byteArray),AppConnectMsg::class.java) as AppConnectMsg
Logger.d(TAG,"onReceivedMsg = "+GsonUtils.toJson(msg))
if (msg.isPlay){ //播报
showNotice(msg.msg)
}

View File

@@ -23,7 +23,7 @@ public interface PM2ServiceApi {
* @return 接口返回数据
*/
@Headers( {"Content-Type:application/json;charset=UTF-8"} )
@POST( "/autopilot-car-hailing/line/v2/driver/bus/passenger/lineDataWithDriver/query" )
@POST( "/och-shuttle-cabin/api/business/v1/passenger/lineDataWithDriver/query" )
Observable<PM2RoutesResponse> queryDriverSiteByCoordinate(@Header("appId") String appId, @Header("ticket") String ticket, @Body PM2QueryLineRequest request);
/**
@@ -33,7 +33,7 @@ public interface PM2ServiceApi {
*/
@Headers({"Content-type:application/json;charset=UTF-8"})
// @GET("/autopilot-car-hailing/car/v2/driver/bus/passenger/takeOrderStatus/query")
@GET("/autopilot-car-hailing/operation/v1/driver/bus/passenger/loginStatus")
@GET("/och-shuttle-cabin/api/business/v1/passenger/loginStatus")
Observable<PM2OperationStatusResponse> queryDriverOperationStatus(@Header ("appId") String appId, @Header("ticket") String ticket, @Query("sn") String sn);

View File

@@ -6,6 +6,8 @@ import android.view.View
import androidx.core.content.ContextCompat
import com.amap.api.maps.model.LatLng
import com.mogo.commons.mvp.MvpFragment
import com.mogo.eagle.core.function.hmi.ui.setting.ToggleDebugView
import com.mogo.eagle.core.utilcode.kotlin.onClick
import com.mogo.eagle.core.utilcode.util.DateTimeUtils
import com.mogo.och.bus.passenger.R
import com.mogo.och.bus.passenger.bean.PM2Station
@@ -33,6 +35,9 @@ class PM2DrivingInfoFragment :
}
override fun initViews() {
speed_tv.onClick {
context?.let { it -> ToggleDebugView.toggleDebugView.toggle(it) }
}
updateCurrentTime()
}

View File

@@ -6,6 +6,7 @@ import android.view.ViewGroup
import androidx.viewpager.widget.PagerAdapter
import androidx.viewpager.widget.ViewPager
import com.mogo.eagle.core.utilcode.mogo.logger.Logger
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
/**
@@ -48,27 +49,7 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
if (viewList[mViewPager.currentItem] is AdvanceVideoView) {//有人反应第一个是视频不播放这边优化了一下
Logger.d("onPageScrollStateChanged", "第一个是视频")
val video = viewList[mViewPager.currentItem] as AdvanceVideoView
video.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
video.setVideo( object : GSYSampleCallBack() {
override fun onPrepared(url: String?, vararg objects: Any?) {
super.onPrepared(url, *objects)
Logger.d("onPageScrollStateChanged", "onPrepared")
video.setCacheImageViewGone()
}
override fun onAutoComplete(url: String?, vararg objects: Any?) {
Logger.d("onPageScrollStateChanged", "onAutoComplete()")
video.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
}
override fun onPlayError(url: String?, vararg objects: Any?) {
Logger.d("onPageScrollStateChanged", "onPlayError()")
video.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
}
})
video.setVideo(gsySampleCallBack)
} else if (viewList[mViewPager.currentItem] is AdvanceImageView) {
Logger.d("onPageScrollStateChanged", "startTimer()_1")
@@ -140,42 +121,20 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
// 由于viewpager的预加载机制onPageSelected这里面加载videoview 放的跟玩一样 等操作完成后再播放videoview就香了 很丝滑
if (state == 0) { //静止,什么都没做
val currentItem = mViewPager.currentItem
Logger.d(
"onPageScrollStateChanged",
"state = $state currentItem = $currentItem lastPosition = $lastPosition"
)
Logger.d("onPageScrollStateChanged",
"state = $state currentItem = $currentItem lastPosition = $lastPosition")
if (viewList.size > 1) { //多于1才会循环跳转
if (lastPosition != -1 && lastPosition != mViewPager.currentItem
&& viewList[lastPosition] is AdvanceVideoView
) {
val videoView: AdvanceVideoView = viewList[lastPosition] as AdvanceVideoView
videoView.setPause()
}
// if (lastPosition != -1 && lastPosition != mViewPager.currentItem
// && viewList[lastPosition] is AdvanceVideoView
// ) {
// val videoView: AdvanceVideoView = viewList[lastPosition] as AdvanceVideoView
// videoView.setPause()
// }
if (viewList[mViewPager.currentItem] is AdvanceVideoView) {
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
videoView.setVideo(object : GSYSampleCallBack() {
override fun onPrepared(url: String?, vararg objects: Any?) {
super.onPrepared(url, *objects)
Logger.d("onPageScrollStateChanged", "onPrepared")
videoView.setCacheImageViewGone()
}
override fun onAutoComplete(url: String?, vararg objects: Any?) {
super.onAutoComplete(url, *objects)
Logger.d("onPageScrollStateChanged", "onAutoComplete()")
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
}
override fun onPlayError(url: String?, vararg objects: Any?) {
super.onPlayError(url, *objects)
Logger.d("onPageScrollStateChanged", "onPlayError()")
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
mViewPager.setCurrentItem(mViewPager.currentItem + 1, true)
}
})
videoView.setVideo(gsySampleCallBack)
} else if (viewList[mViewPager.currentItem] is AdvanceImageView) {
Logger.d("onPageScrollStateChanged", "startTimer()")
@@ -187,6 +146,34 @@ class AdvancePagerAdapter(context: Context, viewPager: ViewPager) : PagerAdapter
}
}
private var gsySampleCallBack = object : GSYSampleCallBack() {
override fun onPrepared(url: String?, vararg objects: Any?) {
super.onPrepared(url, *objects)
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
Logger.d("onPageScrollStateChanged", "onPrepared")
UiThreadHandler.postDelayed({
videoView.setCacheImageViewGone()
},400)
}
override fun onAutoComplete(url: String?, vararg objects: Any?) {
super.onAutoComplete(url, *objects)
Logger.d("onPageScrollStateChanged", "onAutoComplete()")
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
goNextItemView()
}
override fun onPlayError(url: String?, vararg objects: Any?) {
super.onPlayError(url, *objects)
Logger.d("onPageScrollStateChanged", "onPlayError()")
val videoView = (viewList[mViewPager.currentItem] as AdvanceVideoView)
videoView.setCacheImageView(dataList[mViewPager.currentItem].cacheImgPath)
goNextItemView()
}
}
private fun startTimer() {
if (null != thread && !thread?.isInterrupted!!) {
Logger.d("onPageScrollStateChanged", "thread.interrupt()")

View File

@@ -8,6 +8,7 @@ import android.widget.ImageView
import android.widget.RelativeLayout
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import com.mogo.eagle.core.utilcode.util.BitmapHelper
import com.mogo.och.bus.passenger.R
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
@@ -68,27 +69,40 @@ class AdvanceVideoView @JvmOverloads constructor(
fun setVideoPath(path: String) {
this.path = path
// BitmapHelper.getVideoThumbnail(path) /*获取第一帧图*/
// cacheImage?.let {
// it.setImageBitmap(BitmapHelper.getVideoThumbnail(path))
// }
}
@SuppressLint("CheckResult")
fun setCacheImageView(imgPath: String) {
cacheImage?.visibility = VISIBLE
cacheImage?.let {
Glide.with(context)
.apply { RequestOptions().placeholder(R.drawable.m2_p_video_holder).centerCrop() }
.load(imgPath).into(it)
}
cacheImage?.visibility = VISIBLE
}
fun setVideo(onCompletionListener: GSYSampleCallBack) {
gsyVideoOptionBuilder?.setUrl(path)
?.setBottomProgressBarDrawable(null)
?.setCacheWithPlay(false)
// ?.setAutoFullWithSize(true)
// ?.setShowPauseCover(false)
// ?.setFullHideActionBar(true)
// ?.setFullHideStatusBar(true)
// ?.setIsTouchWiget(false)
// ?.setIsTouchWigetFull(false)
// ?.setNeedLockFull(true)
// ?.setLockLand(true)
// ?.setAutoFullWithSize(true)
// ?.setNeedShowWifiTip(false)
?.build(videoViewPlayer)
videoViewPlayer?.setVideoAllCallBack(onCompletionListener)
videoViewPlayer?.startPlayLogic()
videoViewPlayer?.startButton?.performClick()
}
fun setCacheImageViewGone() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<size android:width="@dimen/dp_66" android:height="@dimen/dp_38"/>
<solid android:color="@color/m2_button_un_auto_bg_color"/>
<corners android:radius="@dimen/dp_20"/>
</shape>

View File

@@ -18,7 +18,6 @@
android:id="@+id/m2_p_traffic_light_iv"
android:layout_width="@dimen/dp_40"
android:layout_height="@dimen/dp_40"
android:layout_marginTop="@dimen/dp_8"
android:scaleType="fitXY"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"/>

View File

@@ -3,7 +3,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_556">
android:layout_height="match_parent">
<!-- 全览地图带站点-->
<com.mogo.eagle.core.function.view.OverMapView
@@ -12,6 +12,7 @@
android:layout_height="match_parent"
app:mapStyleExtraPath="@string/m2_over_map_style_extra_path"
app:mapStylePath="@string/m2_over_map_style_path"
app:startPointDrawable="@drawable/m2_map_start_icon"
app:endPointDrawable="@drawable/m2_map_end_icon"/>
<androidx.appcompat.widget.AppCompatImageView
@@ -42,16 +43,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_8"
android:layout_marginBottom="8dp"
android:textSize="@dimen/dp_18"
android:text="@string/m2_p_speed_unit_txt"
android:layout_marginBottom="@dimen/dp_12"
app:layout_constraintBottom_toBottomOf="@+id/speed_tv"
app:layout_constraintLeft_toRightOf="@+id/speed_tv" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/auto_tv"
android:layout_width="@dimen/dp_66"
android:layout_height="@dimen/dp_38"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_p_m2_auto"
android:layout_marginTop="@dimen/dp_12"
android:text="@string/m2_p_auto_tv"
@@ -64,8 +65,8 @@
<!-- 转向灯 IMoGoChassisLamplightListener-->
<com.mogo.och.bus.passenger.ui.widget.M2TurnLightView
android:id="@+id/turn_light_view"
android:layout_width="@dimen/dp_68"
android:layout_height="@dimen/dp_38"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/dp_12"
app:layout_constraintLeft_toRightOf="@+id/auto_tv"
app:layout_constraintTop_toTopOf="@+id/auto_tv"
@@ -94,6 +95,7 @@
android:layout_width="@dimen/dp_74"
android:layout_height="@dimen/dp_79"
android:layout_marginRight="@dimen/dp_20"
android:scaleType="fitXY"
app:layout_constraintTop_toTopOf="@+id/img_line_bg"
app:layout_constraintBottom_toBottomOf="@+id/img_line_bg"
app:layout_constraintRight_toRightOf="@+id/img_line_bg"

View File

@@ -8,17 +8,19 @@
<FrameLayout
android:id="@+id/driving_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintLeft_toLeftOf="parent"/>
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHeight_percent="0.290"/>
<!-- 高精地图-->
<FrameLayout
android:id="@+id/hd_map_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/driving_fragment"
app:layout_constraintLeft_toLeftOf="parent"/>
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHeight_percent="0.418"/>
<!-- 图片或视频广告-->
@@ -26,8 +28,9 @@
<FrameLayout
android:id="@+id/video_fragment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_height="0dp"
app:layout_constraintTop_toBottomOf="@+id/hd_map_fragment"
app:layout_constraintLeft_toLeftOf="parent"/>
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintHeight_percent="0.294"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -2,7 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_800">
android:layout_height="match_parent">
<!-- 高精地图 -->

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_565">
android:layout_height="match_parent">
<!-- 图片或视频广告-->

View File

@@ -18,23 +18,23 @@
<ImageView
android:id="@+id/left_nor_image"
android:layout_width="@dimen/dp_19"
android:layout_height="@dimen/dp_21"
android:layout_width="@dimen/dp_22"
android:layout_height="@dimen/dp_20"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="@dimen/dp_10"
android:layout_marginLeft="@dimen/dp_5"
android:src="@drawable/m2_zuozhuan_un_open" />
<ImageView
android:id="@+id/right_nor_image"
android:layout_width="@dimen/dp_19"
android:layout_height="@dimen/dp_21"
android:layout_width="@dimen/dp_22"
android:layout_height="@dimen/dp_20"
android:layout_gravity="right|center_vertical"
android:layout_marginRight="@dimen/dp_10"
android:src="@drawable/m2_youzhuan_un_open" />
<ImageView
android:id="@+id/left_select_image"
android:layout_width="@dimen/dp_20"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_22"
android:layout_gravity="left|center_vertical"
android:layout_marginLeft="@dimen/dp_10"
@@ -44,7 +44,7 @@
<ImageView
android:id="@+id/right_select_image"
android:layout_width="@dimen/dp_20"
android:layout_width="@dimen/dp_24"
android:layout_height="@dimen/dp_22"
android:layout_gravity="right|center_vertical"
android:layout_marginTop="2dp"

View File

@@ -26,7 +26,7 @@ public class ScreenHelper {
}
AutoSizeConfig.getInstance()
.setBaseOnWidth(true)
.setBaseOnWidth(false)
.setCustomFragment(true)
.setDesignWidthInDp(baseWidth)
.setDesignHeightInDp(baseHeight)