[宣传视频] refactor: taxi无人化乘客屏 增加数据后台可配置,本次本地数据抽取到json配置文件中,因为之前taxi都是视频文件且可全屏,本次新增图片展示但是增加限制图片不可全屏;
This commit is contained in:
@@ -40,7 +40,7 @@ class MediaPlayerFragment :
|
||||
override fun onMediaDataSourceChanged(list: List<MediaItem>) {
|
||||
val isNewData = arrayListOf.isNotEmpty()
|
||||
CallerLogger.d(
|
||||
TAG, "onAdDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}"
|
||||
TAG, "onMediaDataSourceChanged:isNewData=$isNewData, list=${GsonUtils.toJson(list)}"
|
||||
)
|
||||
arrayListOf.clear()
|
||||
arrayListOf.addAll(list)
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
package com.mogo.och.taxi.passenger.bean
|
||||
|
||||
class TaxiPassengerVideoPlay(var url: String, var imageUrl: String, var title: String)
|
||||
class TaxiPassengerVideoPlay(var url: String, var imageUrl: String, var title: String, var type: Int)
|
||||
@@ -7,7 +7,16 @@ import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.FrameLayout
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.main.MainMoGoApplication
|
||||
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.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.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.bean.TaxiPassengerVideoPlay
|
||||
import com.mogo.och.taxi.passenger.ui.video.layoutmanage.CarouselLayoutManager
|
||||
@@ -35,7 +44,7 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
defStyleAttr
|
||||
) {
|
||||
|
||||
companion object{
|
||||
companion object {
|
||||
private const val TAG = "VideoView"
|
||||
}
|
||||
|
||||
@@ -47,35 +56,9 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
private var rvVideoPlaylist: RecyclerView? = null
|
||||
private lateinit var indicatorView: IndicatorView
|
||||
private lateinit var clContain: ConstraintLayout
|
||||
|
||||
private val arrayListOf by lazy {
|
||||
arrayListOf<TaxiPassengerVideoPlay>().apply {
|
||||
add(TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708596763/全车型混剪增加红旗车队.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969511280/车队.png",
|
||||
"蘑菇车联覆盖生活的方方面面"
|
||||
))
|
||||
add(TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708554279/红旗车队.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969553174/红旗重新排版.png",
|
||||
"蘑菇车联之红旗车队"
|
||||
))
|
||||
add(
|
||||
TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708499497/大运会合作解说版.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969536177/大运会.png",
|
||||
"蘑菇车联牵手成都大运会"
|
||||
)
|
||||
)
|
||||
add(
|
||||
TaxiPassengerVideoPlay(
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655708409810/20210610重新排版3屏.m4v",
|
||||
"https://img.zhidaohulian.com/fileServer/online_car_hailing/1655969579713/三屏.png",
|
||||
"多视角体验蘑菇车联自动驾驶"
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
private val mediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
//新的数据,在view不展示的时候完成新数据更新
|
||||
private val mNewMediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
|
||||
fun exitFullScreenMode(resetVideoPlayer: Boolean) {
|
||||
val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager
|
||||
@@ -83,7 +66,7 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
player?.let {
|
||||
it.exitFullScreenMode()
|
||||
it.onVideoPause()
|
||||
if(resetVideoPlayer) {
|
||||
if (resetVideoPlayer) {
|
||||
it.onVideoReset()
|
||||
}
|
||||
}
|
||||
@@ -91,12 +74,50 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
configPage()
|
||||
initData()
|
||||
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 {
|
||||
initData()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onVisibilityChanged(changedView: View, visibility: Int) {
|
||||
super.onVisibilityChanged(changedView, visibility)
|
||||
if(changedView!=this){
|
||||
if (changedView != this) {
|
||||
return
|
||||
}
|
||||
val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager
|
||||
@@ -109,17 +130,28 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
GSYVideoView.CURRENT_STATE_PAUSE -> {
|
||||
//player.onVideoResume(false)
|
||||
}
|
||||
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else -> {
|
||||
player?.let {
|
||||
if (!player.isIfCurrentIsFullscreen) {
|
||||
player.onVideoPause()
|
||||
}
|
||||
}
|
||||
try {
|
||||
// 在播放完成的时机更新整体数据
|
||||
if (mNewMediaList.isNotEmpty()) {
|
||||
updateMediaListDataAndView(mNewMediaList)
|
||||
mNewMediaList.clear()
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -130,16 +162,11 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
clContain = findViewById(R.id.infoContainer)
|
||||
}
|
||||
|
||||
private fun configPage() {
|
||||
// FullVideoUtils.dismissOverlayView(true)
|
||||
initData()
|
||||
}
|
||||
|
||||
private fun initData() {
|
||||
val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true)
|
||||
carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener())
|
||||
carouselLayoutManager.maxVisibleItems = 1
|
||||
indicatorView.notifyDataChanged(arrayListOf.size)
|
||||
indicatorView.notifyDataChanged(mediaList.size)
|
||||
indicatorView.setSlideMode(IndicatorSlideMode.SCALE)
|
||||
indicatorView.setOrientation(IndicatorOrientation.INDICATOR_HORIZONTAL)
|
||||
indicatorView.setIndicatorStyle(IndicatorStyle.ROUND_RECT)
|
||||
@@ -193,7 +220,7 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
}
|
||||
indicatorView.onPageScrolled(currentIndex, fl, 0)
|
||||
}
|
||||
val recyclerVideoAdapter = RecyclerVideoAdapter(context, arrayListOf, rvVideoPlaylist)
|
||||
val recyclerVideoAdapter = RecyclerVideoAdapter(context, mediaList, rvVideoPlaylist)
|
||||
recyclerVideoAdapter.setOnThumbImageClilckListener {
|
||||
val (_: Int, player) = getPlayer(carouselLayoutManager)
|
||||
if (player is ConsultVideoPlayer) {
|
||||
@@ -219,7 +246,7 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager
|
||||
val (_: Int, player) = getPlayer(carouselLayoutManager)
|
||||
player?.let {
|
||||
if(it.isInPlayingState&&!it.isIfCurrentIsFullscreen&&!hasWindowFocus){
|
||||
if (it.isInPlayingState && !it.isIfCurrentIsFullscreen && !hasWindowFocus) {
|
||||
player.onVideoPause()
|
||||
}
|
||||
}
|
||||
@@ -227,6 +254,7 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
MediaDataSourceManager.unInit(TAG)
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
}
|
||||
@@ -53,17 +53,27 @@ 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() == 2;
|
||||
|
||||
AutoSizeCompat.autoConvertDensityOfGlobal(holder.itemView.getResources());
|
||||
holder.gsyVideoOptionBuilder
|
||||
.setEnlargeImageRes(R.drawable.taxi_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.taxi_p_video_holder).centerCrop())
|
||||
.into(holder.gsyVideoPlayer.coverImage);
|
||||
holder.gsyVideoPlayer.getThumbImageViewLayout().setOnClickListener(v -> {
|
||||
@@ -71,6 +81,9 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter<RecyclerItemVideo
|
||||
onThumbImageClilckListener.onDxChanged(holder.getAbsoluteAdapterPosition());
|
||||
}
|
||||
});
|
||||
holder.gsyVideoPlayer.getFullscreenButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE);
|
||||
holder.gsyVideoPlayer.getStartButton().setVisibility(isVideo ? View.VISIBLE : View.INVISIBLE);
|
||||
holder.gsyVideoPlayer.showOrHideStartPlayButton(isVideo ? true : false);
|
||||
holder.gsyVideoPlayer.setVideoAllCallBack(new GSYSampleCallBack(){
|
||||
@Override
|
||||
public void onAutoComplete(String url, Object... objects) {
|
||||
|
||||
@@ -527,5 +527,9 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
fun getVideoAllCallBack(): VideoAllCallBack? {
|
||||
return mVideoAllCallBack
|
||||
}
|
||||
|
||||
fun showOrHideStartPlayButton(isShow: Boolean) {
|
||||
aivStartPlay?.visibility = if (isShow ) View.VISIBLE else View.GONE
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -143,6 +143,34 @@
|
||||
"title": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerochdfhq": {
|
||||
"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": {
|
||||
@@ -289,6 +317,34 @@
|
||||
"title": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerochdfhq": {
|
||||
"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": {
|
||||
@@ -339,6 +395,34 @@
|
||||
"title": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerochdfhq": {
|
||||
"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": {
|
||||
@@ -485,6 +569,34 @@
|
||||
"title": "2"
|
||||
}
|
||||
]
|
||||
},
|
||||
"taxiunmannedpassengerochdfhq": {
|
||||
"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