[M2] M2 广告模块opt
This commit is contained in:
@@ -14,29 +14,15 @@ class URLConst {
|
||||
private const val Shettle_BASE_URL_OCH_QA = "https://och-driver-qa.zhidaozhixing.com"
|
||||
private const val Shettle_BASE_URL_OCH_RELEASE = "https://och-driver.zhidaozhixing.com"
|
||||
|
||||
private const val BASE_URL_OCH_DEV = "http://tech-dev.zhidaohulian.com"
|
||||
private const val BASE_URL_OCH_QA = "https://tech-qa.zhidaohulian.com"
|
||||
private const val BASE_URL_OCH_RELEASE = "https://tech.zhidaohulian.com"
|
||||
|
||||
|
||||
@JvmStatic
|
||||
fun getBaseUrl(): String {
|
||||
return if(AppIdentityModeUtils.isShuttle(FunctionBuildConfig.appIdentityMode)){
|
||||
when (DebugConfig.getNetMode()) {
|
||||
return when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_DEMO -> Shettle_BASE_URL_OCH_DEV
|
||||
DebugConfig.NET_MODE_QA -> Shettle_BASE_URL_OCH_QA
|
||||
DebugConfig.NET_MODE_RELEASE -> Shettle_BASE_URL_OCH_RELEASE
|
||||
else -> Shettle_BASE_URL_OCH_RELEASE
|
||||
}
|
||||
}else{
|
||||
when (DebugConfig.getNetMode()) {
|
||||
DebugConfig.NET_MODE_DEV, DebugConfig.NET_MODE_DEMO -> BASE_URL_OCH_DEV
|
||||
DebugConfig.NET_MODE_QA -> BASE_URL_OCH_QA
|
||||
DebugConfig.NET_MODE_RELEASE -> BASE_URL_OCH_RELEASE
|
||||
else -> BASE_URL_OCH_RELEASE
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,7 +8,7 @@ import com.mogo.eagle.core.data.map.MogoLocation
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoChassisLocationGCJ02Listener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotStatusListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ20ListenerManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerChassisLocationGCJ02ListenerManager
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger.d
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.scene.SceneConstant
|
||||
import com.mogo.eagle.core.utilcode.mogo.storage.SharedPrefsMgr
|
||||
@@ -74,7 +74,8 @@ class PM2DrivingModel private constructor() {
|
||||
CallerAutoPilotStatusListenerManager.addListener(TAG, mAutoPilotStatusListener)
|
||||
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.addListener(TAG, mMapLocationListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.addListener(TAG, mMapLocationListener)
|
||||
CallerChassisLocationGCJ02ListenerManager.setListenerHz(TAG,5)//设置5hz, 1s返回一次
|
||||
}
|
||||
|
||||
public fun releaseListener(){
|
||||
@@ -82,7 +83,7 @@ class PM2DrivingModel private constructor() {
|
||||
CallerAutoPilotStatusListenerManager.removeListener(TAG)
|
||||
|
||||
// 定位监听
|
||||
CallerChassisLocationGCJ20ListenerManager.removeListener(TAG)
|
||||
CallerChassisLocationGCJ02ListenerManager.removeListener(TAG)
|
||||
}
|
||||
|
||||
fun setDrivingInfoCallback(drivingInfoCallback : DrivingInfoCallback?){
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.mogo.och.bus.passenger.ui.video
|
||||
import com.mogo.commons.mvp.MvpFragment
|
||||
import com.mogo.och.bus.passenger.R
|
||||
import com.mogo.och.bus.passenger.presenter.PM2VideoPresenter
|
||||
import com.mogo.och.bus.passenger.ui.widget.video.RotationItem
|
||||
import kotlinx.android.synthetic.m2.p_m2_video_fragment.*
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
@@ -10,21 +12,13 @@ import com.mogo.och.bus.passenger.presenter.PM2VideoPresenter
|
||||
*/
|
||||
class PM2VideoFragment :
|
||||
MvpFragment<PM2VideoFragment?, PM2VideoPresenter?>() {
|
||||
/**
|
||||
* 改变自动驾驶状态
|
||||
*
|
||||
* @param status 2 - running 1 - enable 2 - disable
|
||||
*/
|
||||
|
||||
private var arrayListOf = mutableListOf<RotationItem>()
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.p_m2_video_fragment
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
return TAG
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
}
|
||||
|
||||
override fun createPresenter(): PM2VideoPresenter {
|
||||
return PM2VideoPresenter(this)
|
||||
@@ -33,4 +27,56 @@ class PM2VideoFragment :
|
||||
companion object {
|
||||
private val TAG = PM2VideoFragment::class.java.simpleName
|
||||
}
|
||||
|
||||
override fun getTagName(): String {
|
||||
return TAG
|
||||
}
|
||||
|
||||
override fun initViews() {
|
||||
initResourceData()
|
||||
image_video_rotation_view.setData(arrayListOf)
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
image_video_rotation_view.setPause()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
image_video_rotation_view.setResume()
|
||||
}
|
||||
|
||||
private fun initResourceData() {
|
||||
TODO("要替换成接驳私有化的链接")
|
||||
arrayListOf.clear()
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1656558672856/小宝宝.mp4",
|
||||
0,
|
||||
"小宝宝"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1656559367261/2.png",
|
||||
0,
|
||||
"小猫"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1656558730074/星空.mp4",
|
||||
1,
|
||||
"星空"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
RotationItem(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1656559384635/3.png",
|
||||
0,
|
||||
"星空"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,81 @@
|
||||
package com.mogo.och.bus.passenger.ui.widget.video
|
||||
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/6
|
||||
*/
|
||||
class AdvancePagerAdapter: PagerAdapter() {
|
||||
class AdvancePagerAdapter(context: Context, viewPager: ViewPager): PagerAdapter(),
|
||||
ViewPager.OnPageChangeListener {
|
||||
|
||||
private val mContext: Context = context
|
||||
private val mViewPager: ViewPager = viewPager
|
||||
|
||||
private var dataList = mutableListOf<RotationItem>()
|
||||
private var viewList = mutableListOf<View>()
|
||||
|
||||
private var thread: Thread? = null
|
||||
|
||||
private var lastPosition = -1
|
||||
|
||||
private var current = 0
|
||||
private val time = 5000
|
||||
private val pause = false
|
||||
|
||||
fun setData(list: MutableList<RotationItem>){
|
||||
if (list.isEmpty()) return
|
||||
dataList.addAll(list)
|
||||
|
||||
viewList.clear()
|
||||
|
||||
list.forEach {
|
||||
addView(it)
|
||||
}
|
||||
|
||||
mViewPager.addOnPageChangeListener(this)
|
||||
|
||||
notifyDataSetChanged()
|
||||
|
||||
}
|
||||
|
||||
override fun getCount(): Int {
|
||||
TODO("Not yet implemented")
|
||||
return dataList.size
|
||||
}
|
||||
|
||||
override fun isViewFromObject(view: View, `object`: Any): Boolean {
|
||||
TODO("Not yet implemented")
|
||||
return view === `object`
|
||||
}
|
||||
|
||||
public fun setData(list: MutableList<RotationItem>){
|
||||
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
|
||||
container.removeView(viewList[position])
|
||||
}
|
||||
|
||||
override fun instantiateItem(container: ViewGroup, position: Int): Any {
|
||||
val view: View = viewList[position]
|
||||
container.addView(view)
|
||||
return view
|
||||
|
||||
}
|
||||
|
||||
override fun getItemPosition(`object`: Any): Int {
|
||||
return POSITION_NONE
|
||||
}
|
||||
|
||||
private fun addView(item: RotationItem) {
|
||||
if (item.type.equals("1")) { // 表示视频
|
||||
var videoView = AdvanceVideoView(mContext)
|
||||
videoView.setVideoImagePath(item.path)
|
||||
viewList.add(videoView)
|
||||
} else { // 表示图片
|
||||
var imageView = AdvanceImageView(mContext)
|
||||
imageView.setImagePath(item.path)
|
||||
viewList.add(imageView)
|
||||
}
|
||||
}
|
||||
|
||||
public fun setPause(){
|
||||
@@ -27,4 +85,38 @@ class AdvancePagerAdapter: PagerAdapter() {
|
||||
public fun setResume(){
|
||||
|
||||
}
|
||||
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun onPageSelected(position: Int) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
// 由于viewpager的预加载机制onPageSelected这里面加载videoview 放的跟玩一样 等操作完成后再播放videoview就香了 很丝滑
|
||||
// if (state == 0) {
|
||||
// if (viewList.size > 1) { //多于1,才会循环跳转
|
||||
// if (lastPosition != -1 && lastPosition != mViewPager.currentItem
|
||||
// && viewList[lastPosition] is AdvanceVideoView) {
|
||||
// var videoView: AdvanceVideoView = (AdvanceVideoView)viewList[lastPosition]
|
||||
// videoView.setPause()
|
||||
// }
|
||||
// if (mViewPager.getCurrentItem() < 1) { //首位之前,跳转到末尾(N)
|
||||
// var position = dataList.size //注意这里是mList,而不是mViews
|
||||
// mViewPager.setCurrentItem(position, false)
|
||||
// } else if (mViewPager.currentItem > dataList.size) { //末位之后,跳转到首位(1)
|
||||
// mViewPager.setCurrentItem(1, false) //false:不显示跳转过程的动画
|
||||
// }
|
||||
// current = 0;//换页重新计算时间
|
||||
// if (viewList.get(mViewPager.currentItem) instanceof AdvanceVideoView) {
|
||||
// ((AdvanceVideoView) list.get(mViewPager.getCurrentItem())).setVideo(mediaPlayer -> {
|
||||
// mViewPager.setCurrentItem(mViewPager.getCurrentItem() + 1, true);
|
||||
// })
|
||||
// }
|
||||
// lastPosition = mViewPager.currentItem
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.mogo.och.bus.passenger.ui.widget.video
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.media.MediaPlayer
|
||||
import android.util.AttributeSet
|
||||
import android.widget.ImageView
|
||||
import android.widget.RelativeLayout
|
||||
import android.widget.VideoView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/8
|
||||
*/
|
||||
class AdvanceVideoView @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : RelativeLayout(context, attrs) {
|
||||
|
||||
private var videoRelativeLayout: RelativeLayout? = null
|
||||
private var videoPlayer: VideoView? = null
|
||||
|
||||
private var startImage: ImageView? = null
|
||||
private var path: String? = null
|
||||
|
||||
init {
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
videoRelativeLayout = RelativeLayout(context)
|
||||
addView(videoRelativeLayout, LayoutParams(-1,-1))
|
||||
startImage = ImageView(context)
|
||||
startImage?.scaleType = ImageView.ScaleType.FIT_XY
|
||||
addView(startImage, LayoutParams(-1,-1))
|
||||
}
|
||||
|
||||
fun setVideoImagePath(path: String){
|
||||
this.path = path
|
||||
startImage?.let { Glide.with(context).load(path).into(it) }
|
||||
}
|
||||
|
||||
fun setVideo(onCompletionListener : MediaPlayer.OnCompletionListener) {
|
||||
if (videoPlayer != null) {
|
||||
videoRelativeLayout?.removeView(videoPlayer)
|
||||
videoPlayer = null
|
||||
}
|
||||
videoPlayer = VideoView(context)
|
||||
videoPlayer?.setVideoPath(path)
|
||||
videoPlayer?.setBackgroundColor(Color.TRANSPARENT)
|
||||
|
||||
var layoutParams= LayoutParams(-1,-1)
|
||||
//设置videoview占满父view播放
|
||||
layoutParams.addRule(ALIGN_PARENT_LEFT)
|
||||
layoutParams.addRule(ALIGN_PARENT_RIGHT)
|
||||
layoutParams.addRule(ALIGN_PARENT_TOP)
|
||||
layoutParams.addRule(ALIGN_PARENT_BOTTOM)
|
||||
videoRelativeLayout?.addView(videoPlayer, layoutParams);
|
||||
videoPlayer?.setOnCompletionListener(onCompletionListener);
|
||||
videoPlayer?.start()
|
||||
|
||||
videoPlayer?.setOnPreparedListener {
|
||||
UiThreadHandler.postDelayed({
|
||||
startImage?.visibility = GONE
|
||||
}, 400) //防止黑屏闪烁
|
||||
}
|
||||
}
|
||||
|
||||
fun setPause() {
|
||||
if (videoPlayer != null) {
|
||||
videoPlayer?.pause()
|
||||
startImage?.visibility = VISIBLE
|
||||
}
|
||||
}
|
||||
|
||||
fun setRestart() {
|
||||
if (videoPlayer != null) {
|
||||
videoPlayer?.start()
|
||||
startImage?.visibility = GONE
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,20 +23,20 @@ class ImageAndVideoRotation @JvmOverloads constructor(
|
||||
|
||||
private fun initView() {
|
||||
viewPager = ViewPager(context)
|
||||
pagerAdapter = AdvancePagerAdapter()
|
||||
pagerAdapter = AdvancePagerAdapter(context, viewPager!!)
|
||||
viewPager?.adapter = pagerAdapter
|
||||
addView(viewPager, LayoutParams(-1,-1))
|
||||
}
|
||||
|
||||
public fun setData(list: MutableList<RotationItem>){
|
||||
fun setData(list: MutableList<RotationItem>){
|
||||
pagerAdapter?.setData(list)
|
||||
}
|
||||
|
||||
public fun setPause(){
|
||||
fun setPause(){
|
||||
pagerAdapter?.setPause()
|
||||
}
|
||||
|
||||
public fun setResume(){
|
||||
fun setResume(){
|
||||
pagerAdapter?.setResume()
|
||||
}
|
||||
}
|
||||
@@ -3,5 +3,7 @@ package com.mogo.och.bus.passenger.ui.widget.video
|
||||
/**
|
||||
* @author: wangmingjun
|
||||
* @date: 2023/2/6
|
||||
* type:0 图片
|
||||
* type:1 视频
|
||||
*/
|
||||
data class RotationItem(var path: String, var type: String)
|
||||
data class RotationItem(var path: String, var type: Int, var title: String)
|
||||
@@ -134,7 +134,7 @@
|
||||
|
||||
|
||||
<!-- 全览地图带站点-->
|
||||
<com.mogo.eagle.core.function.overview.view.OverMapView
|
||||
<com.mogo.eagle.core.function.view.OverMapView
|
||||
android:id="@+id/overMapView"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="@dimen/dp_600"
|
||||
|
||||
@@ -4,22 +4,28 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<!-- 高精地图 消息盒子-->
|
||||
<TextView
|
||||
<!-- 高精地图 -->
|
||||
|
||||
<com.mogo.eagle.core.function.view.MapBizView
|
||||
android:id="@+id/mapBizView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<!-- 消息盒子气泡-->
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView
|
||||
android:id="@+id/box_bubble_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:text="这是hdMap"
|
||||
android:textSize="@dimen/dp_60"/>
|
||||
|
||||
<!-- 消息盒子气泡 -->
|
||||
<!--<com.mogo.eagle.core.function.hmi.ui.msgbox.PassengerMsgBoxBubbleView-->
|
||||
<!-- android:layout_width=""-->
|
||||
<!-- android:layout_height=""/>-->
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent" />
|
||||
|
||||
<!--pnc行为决策-->
|
||||
<!-- <com.mogo.eagle.core.function.hmi.ui.vehicle.PncActionsView-->
|
||||
<!-- android:layout_width=""-->
|
||||
<!-- android:layout_height=""/>-->
|
||||
<com.mogo.eagle.core.function.hmi.ui.vehicle.PncActionsView
|
||||
android:id="@+id/pnc_actions_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -6,12 +6,9 @@
|
||||
|
||||
<!-- 图片或视频广告-->
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:text="这是video"
|
||||
android:textSize="@dimen/dp_60"/>
|
||||
<com.mogo.och.bus.passenger.ui.widget.video.ImageAndVideoRotation
|
||||
android:id="@+id/image_video_rotation_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
Reference in New Issue
Block a user