[宣传视频] refactor: M1 乘客屏宣传视频 增加数据后台可配置相关逻辑;
This commit is contained in:
@@ -2,16 +2,19 @@ package com.mogo.och.charter.passenger.bean;
|
||||
|
||||
public class TaxiPassengerVideoPlay {
|
||||
|
||||
public TaxiPassengerVideoPlay(String url, String imageUrl, String title) {
|
||||
public TaxiPassengerVideoPlay(String url, String imageUrl, String title, int type) {
|
||||
this.url = url;
|
||||
this.imageUrl = imageUrl;
|
||||
this.title = title;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
private String url;
|
||||
private String imageUrl;
|
||||
private String title;
|
||||
|
||||
private int type;
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
@@ -35,4 +38,12 @@ public class TaxiPassengerVideoPlay {
|
||||
public void setImageUrl(String imageUrl) {
|
||||
this.imageUrl = imageUrl;
|
||||
}
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -490,5 +490,9 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
fun getVideoAllCallBack(): VideoAllCallBack? {
|
||||
return mVideoAllCallBack
|
||||
}
|
||||
|
||||
fun showOrHideStartPlayButton(isShow: Boolean) {
|
||||
aivStartPlay?.visibility = if (isShow ) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,12 +5,25 @@ import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotStatusListener
|
||||
import com.mogo.eagle.core.function.main.MainMoGoApplication
|
||||
import com.mogo.eagle.core.utilcode.kotlin.onClick
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.util.GsonUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.charter.passenger.R
|
||||
import com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay
|
||||
import com.mogo.och.charter.passenger.callback.IClearViewCallback
|
||||
import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager
|
||||
import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener
|
||||
import com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CenterScrollListener
|
||||
import com.mogo.och.charter.passenger.ui.video.adapter.RecyclerVideoAdapter
|
||||
import com.mogo.och.common.module.wigets.media.IMediaDataSourceListener
|
||||
import com.mogo.och.common.module.wigets.media.MediaDataSourceManager
|
||||
import com.mogo.och.common.module.wigets.media.MediaFileCacheManager
|
||||
import com.mogo.och.common.module.wigets.media.MediaItem
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
|
||||
import kotlinx.android.synthetic.main.charter_p_video_fragment.view.rvVideoPlaylist
|
||||
import kotlin.math.floor
|
||||
@@ -22,27 +35,32 @@ class VideoView @JvmOverloads constructor(
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr), IMoGoAutopilotStatusListener {
|
||||
|
||||
companion object {
|
||||
const val TAG = "DebugView"
|
||||
const val TAG = "VideoView"
|
||||
}
|
||||
|
||||
private val arrayListOf = ArrayList<com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay>()
|
||||
|
||||
var goneViewListener: IClearViewCallback? = null
|
||||
|
||||
private val mediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
//新的数据,在view不展示的时候完成新数据更新
|
||||
private val mNewMediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.charter_p_video_fragment, this, true)
|
||||
onClick {
|
||||
goneViewListener?.goneAllView()
|
||||
}
|
||||
initConsultData()
|
||||
initView()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
val carouselLayoutManager =
|
||||
com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager(
|
||||
CarouselLayoutManager(
|
||||
CarouselLayoutManager.HORIZONTAL,
|
||||
true
|
||||
)
|
||||
carouselLayoutManager.setPostLayoutListener(com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselZoomPostLayoutListener())
|
||||
carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener())
|
||||
carouselLayoutManager.maxVisibleItems = 1
|
||||
rvVideoPlaylist.addOnScrollListener(object : com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CenterScrollListener() {
|
||||
rvVideoPlaylist.addOnScrollListener(object : CenterScrollListener() {
|
||||
var prePlayerPosition = 0
|
||||
override fun pageSelect(recyclerView: RecyclerView?, newState: Int) {
|
||||
//播放视频
|
||||
@@ -70,7 +88,6 @@ class VideoView @JvmOverloads constructor(
|
||||
player.onVideoPause()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition ->
|
||||
val fl = adapterPosition - floor(adapterPosition)
|
||||
@@ -84,16 +101,16 @@ class VideoView @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
val recyclerVideoAdapter =
|
||||
com.mogo.och.charter.passenger.ui.video.adapter.RecyclerVideoAdapter(
|
||||
RecyclerVideoAdapter(
|
||||
context,
|
||||
arrayListOf,
|
||||
mediaList,
|
||||
rvVideoPlaylist
|
||||
)
|
||||
recyclerVideoAdapter.setOnThumbImageClilckListener {
|
||||
val (_, player) = getPlayer(carouselLayoutManager)
|
||||
if (player is ConsultVideoPlayer) {
|
||||
player.onVideoReset()
|
||||
player.thumbImageViewLayout.visibility = View.VISIBLE
|
||||
player.thumbImageViewLayout.visibility = VISIBLE
|
||||
}
|
||||
rvVideoPlaylist?.smoothScrollToPosition(it)
|
||||
}
|
||||
@@ -104,7 +121,44 @@ class VideoView @JvmOverloads constructor(
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
MediaFileCacheManager.createFileCacheDir(MainMoGoApplication.getApp().applicationContext)
|
||||
MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener {
|
||||
override fun onMediaDataSourceChanged(list: List<MediaItem>) {
|
||||
val isNewData = mediaList.isNotEmpty()
|
||||
CallerLogger.d(
|
||||
TAG,
|
||||
"onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}"
|
||||
)
|
||||
val localMediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
list.forEach {
|
||||
val taxiPassengerVideoPlay = TaxiPassengerVideoPlay(
|
||||
it.fileUrl,
|
||||
it.coverImageUrl,
|
||||
it.title,
|
||||
it.fileType
|
||||
)
|
||||
localMediaList.add(taxiPassengerVideoPlay)
|
||||
}
|
||||
if (isNewData) {
|
||||
if (!isVisible) {
|
||||
updateMediaListDataAndView(localMediaList)
|
||||
} else {
|
||||
mNewMediaList.clear()
|
||||
mNewMediaList.addAll(localMediaList)
|
||||
}
|
||||
} else {
|
||||
updateMediaListDataAndView(localMediaList)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun updateMediaListDataAndView(newList: MutableList<TaxiPassengerVideoPlay>) {
|
||||
mediaList.clear()
|
||||
mediaList.addAll(newList)
|
||||
UiThreadHandler.post {
|
||||
initView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun getPlayer(carouselLayoutManager: com.mogo.och.charter.passenger.ui.softcontrol.layoutmanage.CarouselLayoutManager): Pair<Int, ConsultVideoPlayer?> {
|
||||
@@ -115,6 +169,7 @@ class VideoView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
MediaDataSourceManager.unInit(TAG)
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
|
||||
@@ -133,40 +188,16 @@ class VideoView @JvmOverloads constructor(
|
||||
player.onVideoReset()
|
||||
}
|
||||
}
|
||||
try {
|
||||
// 在播放完成的时机更新整体数据
|
||||
if (mNewMediaList.isNotEmpty()) {
|
||||
updateMediaListDataAndView(mNewMediaList)
|
||||
mNewMediaList.clear()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initConsultData() {
|
||||
arrayListOf.clear()
|
||||
arrayListOf.add(
|
||||
com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png",
|
||||
"蘑菇车联覆盖生活的方方面面"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png",
|
||||
"蘑菇车联之红旗车队"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png",
|
||||
"蘑菇车联牵手成都大运会"
|
||||
)
|
||||
)
|
||||
arrayListOf.add(
|
||||
com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png",
|
||||
"多视角体验蘑菇车联自动驾驶"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
import com.mogo.och.common.module.wigets.media.MediaItem;
|
||||
import com.mogo.och.common.module.wigets.toast.ToastCharterUtils;
|
||||
import com.mogo.och.charter.passenger.R;
|
||||
import com.mogo.och.charter.passenger.bean.TaxiPassengerVideoPlay;
|
||||
@@ -62,27 +63,40 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter<RecyclerItemVideo
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull final RecyclerItemVideoHolder holder, int position) {
|
||||
final TaxiPassengerVideoPlay taxiPassengerVideoPlay = itemDataList.get(position);
|
||||
boolean isVideo = taxiPassengerVideoPlay.getType() == MediaItem.MEDIA_TYPE_VIDEO;
|
||||
|
||||
AutoSizeCompat.autoConvertDensityOfGlobal(holder.itemView.getResources());
|
||||
holder.gsyVideoOptionBuilder
|
||||
.setEnlargeImageRes(R.drawable.charter_p_change_full)
|
||||
.setUrl(taxiPassengerVideoPlay.getUrl())
|
||||
.setCacheWithPlay(true)
|
||||
.setPlayTag(taxiPassengerVideoPlay.getImageUrl()+position)
|
||||
.setPlayTag(taxiPassengerVideoPlay.getUrl()+position)
|
||||
.setThumbPlay(false)
|
||||
.setStartAfterPrepared(isVideo ? true : false)
|
||||
.build(holder.gsyVideoPlayer);
|
||||
holder.gsyVideoPlayer.getTitleTextView().setText(taxiPassengerVideoPlay.getTitle());
|
||||
String imageUrl;
|
||||
if (isVideo) {
|
||||
imageUrl = taxiPassengerVideoPlay.getImageUrl();
|
||||
} else {
|
||||
imageUrl = taxiPassengerVideoPlay.getUrl();
|
||||
}
|
||||
Glide.with(context)
|
||||
.load(taxiPassengerVideoPlay.getImageUrl())
|
||||
.load(imageUrl)
|
||||
.apply(new RequestOptions().placeholder(R.drawable.charter_p_video_holder).centerCrop())
|
||||
.into(holder.gsyVideoPlayer.coverImage);
|
||||
holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(onThumbImageClilckListener!=null){
|
||||
holder.gsyVideoPlayer.getTitleTextView().setText(taxiPassengerVideoPlay.getTitle());
|
||||
holder.gsyVideoPlayer.getFullscreenButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE);
|
||||
holder.gsyVideoPlayer.getStartButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE);
|
||||
holder.gsyVideoPlayer.showOrHideStartPlayButton(isVideo ? true : false);
|
||||
if (isVideo) {
|
||||
holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(v -> {
|
||||
if (onThumbImageClilckListener != null) {
|
||||
onThumbImageClilckListener.onDxChanged(holder.getAbsoluteAdapterPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(null);
|
||||
}
|
||||
holder.gsyVideoPlayer.setVideoAllCallBack(new GSYSampleCallBack(){
|
||||
@Override
|
||||
public void onAutoComplete(String url, Object... objects) {
|
||||
|
||||
@@ -171,6 +171,34 @@
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerochm1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png",
|
||||
"title": "蘑菇车联覆盖生活的方方面面"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png",
|
||||
"title": "蘑菇车联之红旗车队"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png",
|
||||
"title": "蘑菇车联牵手成都大运会"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png",
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"dali": {
|
||||
@@ -345,6 +373,34 @@
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerochm1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png",
|
||||
"title": "蘑菇车联覆盖生活的方方面面"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png",
|
||||
"title": "蘑菇车联之红旗车队"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png",
|
||||
"title": "蘑菇车联牵手成都大运会"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png",
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"yantai": {
|
||||
@@ -423,6 +479,34 @@
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerochm1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png",
|
||||
"title": "蘑菇车联覆盖生活的方方面面"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png",
|
||||
"title": "蘑菇车联之红旗车队"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png",
|
||||
"title": "蘑菇车联牵手成都大运会"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png",
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"saas": {
|
||||
@@ -597,6 +681,34 @@
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
},
|
||||
"charterpassengerochm1": {
|
||||
"medias": [
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png",
|
||||
"title": "蘑菇车联覆盖生活的方方面面"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png",
|
||||
"title": "蘑菇车联之红旗车队"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png",
|
||||
"title": "蘑菇车联牵手成都大运会"
|
||||
},
|
||||
{
|
||||
"fileUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v",
|
||||
"fileType": 2,
|
||||
"coverImageUrl": "https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png",
|
||||
"title": "多视角体验蘑菇车联自动驾驶"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user