[8.0.0]
[fea] [咨询功能]
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
package com.mogo.och.unmanned.passenger.bean
|
||||
|
||||
class TaxiPassengerVideoPlay(var url: String, var imageUrl: String, var title: String, var type: Int)
|
||||
class TaxiPassengerVideoPlay(var url: String, var imageUrl: String, var title: String, var type: Int,var isPlayiing:Boolean=false)
|
||||
@@ -3,12 +3,13 @@ package com.mogo.och.unmanned.passenger.ui.video
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
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.ToastUtils
|
||||
import com.mogo.eagle.core.utilcode.util.UiThreadHandler
|
||||
import com.mogo.och.common.module.wigets.WrapContentLinearLayoutManager
|
||||
import com.mogo.och.common.module.wigets.media.IMediaDataSourceListener
|
||||
@@ -17,11 +18,17 @@ import com.mogo.och.common.module.wigets.media.MediaFileCacheManager
|
||||
import com.mogo.och.common.module.wigets.media.MediaItem
|
||||
import com.mogo.och.common.module.wigets.media.MediaPlayLogger
|
||||
import com.mogo.och.unmanned.passenger.bean.TaxiPassengerVideoPlay
|
||||
import com.mogo.och.unmanned.taxi.passenger.R
|
||||
import com.mogo.och.unmanned.passenger.ui.video.RecyclerVideoAdapterNew.OnThumbImageClilckListener
|
||||
import com.mogo.och.unmanned.passenger.ui.video.layoutmanage.CarouselLayoutManager
|
||||
import com.mogo.och.unmanned.passenger.widget.ConsultVideoPlayer
|
||||
import com.mogo.och.unmanned.taxi.passenger.R
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||
import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack
|
||||
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
|
||||
import kotlinx.android.synthetic.main.taxt_u_p_mogo_video_layout.view.infoVideoPlaylist
|
||||
import kotlinx.android.synthetic.main.taxt_u_p_mogo_video_layout.view.tv_playing_title
|
||||
import kotlinx.android.synthetic.main.taxt_u_p_mogo_video_layout.view.video_item_player
|
||||
|
||||
/**
|
||||
* @author ChenFufeng
|
||||
@@ -42,9 +49,13 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private val mediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
|
||||
//新的数据,在view不展示的时候完成新数据更新
|
||||
private val mNewMediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
|
||||
private var currentMedia: TaxiPassengerVideoPlay? = null
|
||||
|
||||
private var currentMediaIndex = 0
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.taxt_u_p_mogo_video_layout, this, true)
|
||||
@@ -70,7 +81,13 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
MediaDataSourceManager.init(TAG, object : IMediaDataSourceListener {
|
||||
override fun onMediaDataSourceChanged(list: List<MediaItem>) {
|
||||
val isNewData = mediaList.isNotEmpty()
|
||||
MediaPlayLogger.printInfoLog("onMediaDataSourceChanged:isNewData=$isNewData, dataSize=${list.size}, list=${GsonUtils.toJson(list)}")
|
||||
MediaPlayLogger.printInfoLog(
|
||||
"onMediaDataSourceChanged:isNewData=$isNewData, dataSize=${list.size}, list=${
|
||||
GsonUtils.toJson(
|
||||
list
|
||||
)
|
||||
}"
|
||||
)
|
||||
val localMediaList = mutableListOf<TaxiPassengerVideoPlay>()
|
||||
list.forEach {
|
||||
val taxiPassengerVideoPlay = TaxiPassengerVideoPlay(
|
||||
@@ -102,21 +119,74 @@ internal class InfoVideoView @JvmOverloads constructor(
|
||||
mediaList.addAll(newList)
|
||||
mediaList.addAll(newList)
|
||||
UiThreadHandler.post {
|
||||
initView()
|
||||
updateData()
|
||||
infoVideoPlaylist.adapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
infoVideoPlaylist.layoutManager = WrapContentLinearLayoutManager(context,RecyclerView.VERTICAL,false)
|
||||
infoVideoPlaylist.layoutManager =
|
||||
WrapContentLinearLayoutManager(context, RecyclerView.VERTICAL, false)
|
||||
infoVideoPlaylist.addItemDecoration(SpacesItemDecoration(40, 140))
|
||||
infoVideoPlaylist.adapter = RecyclerVideoAdapterNew(context, mediaList)
|
||||
infoVideoPlaylist.adapter = RecyclerVideoAdapterNew(context, mediaList).apply {
|
||||
setOnThumbImageClilckListener(object : OnThumbImageClilckListener{
|
||||
override fun onDxChanged(targetPosition: Int) {
|
||||
currentMediaIndex = targetPosition
|
||||
updateData()
|
||||
}
|
||||
})
|
||||
}
|
||||
video_item_player.onStatusChangeListener = object :ConsultVideoPlayer.OnPlayStatusListener{
|
||||
override fun onStatusChange(status: Int) {
|
||||
mediaList.forEachIndexed { index, taxiPassengerVideoPlay ->
|
||||
if (taxiPassengerVideoPlay.isPlayiing) {
|
||||
taxiPassengerVideoPlay.isPlayiing = false
|
||||
infoVideoPlaylist.adapter?.notifyItemChanged(index)
|
||||
}
|
||||
}
|
||||
when (status) {
|
||||
GSYVideoView.CURRENT_STATE_PLAYING ->{
|
||||
currentMedia?.isPlayiing = true
|
||||
infoVideoPlaylist.adapter?.notifyItemChanged(currentMediaIndex)
|
||||
}
|
||||
else ->{
|
||||
currentMedia?.isPlayiing = false
|
||||
infoVideoPlaylist.adapter?.notifyItemChanged(currentMediaIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
video_item_player.setVideoAllCallBack(object : GSYSampleCallBack() {
|
||||
override fun onAutoComplete(url: String?, vararg objects: Any?) {
|
||||
if (currentMediaIndex + 1 >= mediaList.size) {
|
||||
currentMediaIndex = 0
|
||||
} else {
|
||||
currentMediaIndex += 1
|
||||
}
|
||||
updateData()
|
||||
}
|
||||
|
||||
override fun onClickStartIcon(url: String?, vararg objects: Any?) {
|
||||
CallerLogger.d(TAG,"开始播放了:${url}")
|
||||
}
|
||||
|
||||
override fun onPlayError(url: String?, vararg objects: Any?) {
|
||||
ToastUtils.showLong("哎呀,出错了,看看其他视频吧")
|
||||
}
|
||||
|
||||
override fun onClickStartError(url: String?, vararg objects: Any?) {
|
||||
ToastUtils.showLong("哎呀,出错了,看看其他视频吧")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getPlayer(carouselLayoutManager: CarouselLayoutManager): Pair<Int, ConsultVideoPlayer?> {
|
||||
val centerItemPosition: Int = carouselLayoutManager.centerItemPosition
|
||||
val playerHolder = carouselLayoutManager.findViewByPosition(centerItemPosition)
|
||||
val player = playerHolder?.findViewById<ConsultVideoPlayer>(R.id.video_item_player)
|
||||
return Pair(centerItemPosition, player)
|
||||
private fun updateData() {
|
||||
if (mediaList.isNotEmpty() && currentMediaIndex < mediaList.size) {
|
||||
currentMedia = mediaList[currentMediaIndex]
|
||||
tv_playing_title.text = currentMedia?.title
|
||||
video_item_player.setData(currentMedia!!)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter<RecyclerItemVideo
|
||||
} else {
|
||||
imageUrl = taxiPassengerVideoPlay.getUrl();
|
||||
}
|
||||
Drawable placeholderDrawable = SkinResources.getInstance().getDrawable(R.drawable.road_video_bg);
|
||||
Drawable placeholderDrawable = SkinResources.getInstance().getDrawable(R.drawable.taxi_p_road_video_bg);
|
||||
Glide.with(context)
|
||||
.load(imageUrl)
|
||||
.apply(new RequestOptions().placeholder(placeholderDrawable).centerCrop())
|
||||
|
||||
@@ -22,14 +22,15 @@ class RecyclerVideoAdapterNew(
|
||||
private var onThumbImageClilckListener: OnThumbImageClilckListener? = null
|
||||
|
||||
|
||||
val placeholderDrawable = SkinResources.getInstance().getDrawable(R.drawable.road_video_bg)
|
||||
val placeholderDrawable = SkinResources.getInstance().getDrawable(R.drawable.taxi_p_road_video_bg)
|
||||
|
||||
fun setOnThumbImageClilckListener(onThumbImageClilckListener: OnThumbImageClilckListener?) {
|
||||
this.onThumbImageClilckListener = onThumbImageClilckListener
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SwitchLineViewHolder {
|
||||
val v = LayoutInflater.from(context).inflate(R.layout.taxt_u_p_list_video_item, parent, false)
|
||||
val v =
|
||||
LayoutInflater.from(context).inflate(R.layout.taxt_u_p_list_video_item, parent, false)
|
||||
return SwitchLineViewHolder(v)
|
||||
}
|
||||
|
||||
@@ -37,10 +38,11 @@ class RecyclerVideoAdapterNew(
|
||||
|
||||
AutoSizeCompat.autoConvertDensityOfGlobal(holder.itemView.resources)
|
||||
|
||||
val taxiPassengerVideoPlay = itemDataList[position]
|
||||
val currentPosition = holder.bindingAdapterPosition
|
||||
val taxiPassengerVideoPlay = itemDataList[currentPosition]
|
||||
val isVideo = taxiPassengerVideoPlay.type == MediaItem.MEDIA_TYPE_VIDEO
|
||||
|
||||
holder.adName.setText(taxiPassengerVideoPlay.title)
|
||||
holder.adName.text = taxiPassengerVideoPlay.title
|
||||
|
||||
val imageUrl = if (isVideo) {
|
||||
taxiPassengerVideoPlay.imageUrl
|
||||
@@ -51,7 +53,16 @@ class RecyclerVideoAdapterNew(
|
||||
Glide.with(context)
|
||||
.load(imageUrl)
|
||||
.apply(RequestOptions().placeholder(placeholderDrawable).centerCrop())
|
||||
.into(holder.adHeader);
|
||||
.into(holder.adHeader)
|
||||
holder.itemView.setOnClickListener {
|
||||
this.onThumbImageClilckListener?.onDxChanged(currentPosition)
|
||||
}
|
||||
|
||||
if(taxiPassengerVideoPlay.isPlayiing){
|
||||
holder.isPlaying.visibility = View.VISIBLE
|
||||
}else{
|
||||
holder.isPlaying.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.mogo.och.unmanned.passenger.widget
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import android.os.Build
|
||||
import android.util.AttributeSet
|
||||
@@ -18,15 +19,22 @@ import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.app.ActivityCompat
|
||||
import com.bumptech.glide.Glide
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.mogo.eagle.core.utilcode.mogo.logger.CallerLogger
|
||||
import com.mogo.eagle.core.utilcode.util.TAG
|
||||
import com.mogo.eagle.core.utilcode.util.TimeTransformUtils
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import com.mogo.och.common.module.manager.audiofocus.AudioFocusManager
|
||||
import com.mogo.och.common.module.wigets.media.MediaItem
|
||||
import com.mogo.och.unmanned.passenger.bean.TaxiPassengerVideoPlay
|
||||
import com.mogo.och.unmanned.passenger.ui.statusview.StatusBarView
|
||||
import com.mogo.och.unmanned.taxi.passenger.R
|
||||
import com.mogo.och.unmanned.passenger.ui.video.FullVideoUtils
|
||||
import com.mogo.och.unmanned.passenger.utils.ZoomDrawable
|
||||
import com.mogo.och.unmanned.taxi.passenger.R
|
||||
import com.mogo.skin.utils.SkinResources
|
||||
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
|
||||
import com.shuyu.gsyvideoplayer.listener.VideoAllCallBack
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
@@ -59,6 +67,12 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
private var currentTime = 0
|
||||
private var fileType = 0
|
||||
|
||||
private var gsyVideoOptionBuilder: GSYVideoOptionBuilder? = null
|
||||
|
||||
var placeholderDrawable: Drawable = SkinResources.getInstance().getDrawable(R.drawable.taxi_p_road_video_bg)
|
||||
|
||||
var onStatusChangeListener:OnPlayStatusListener?= null
|
||||
|
||||
constructor(context: Context?) : super(context)
|
||||
constructor(context: Context?, attrs: AttributeSet?) : super(context, attrs)
|
||||
constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
|
||||
@@ -135,6 +149,8 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
}
|
||||
|
||||
override fun updateStartImage() {
|
||||
CallerLogger.d(TAG,"当前的状态:${mCurrentState}")
|
||||
this.onStatusChangeListener?.onStatusChange(mCurrentState)
|
||||
when (mCurrentState) {
|
||||
GSYVideoView.CURRENT_STATE_PLAYING ->{
|
||||
start.setImageResource(R.drawable.notice_video_pause)
|
||||
@@ -547,5 +563,36 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
}
|
||||
aivStartPlay?.visibility = if (isShow ) View.VISIBLE else View.GONE
|
||||
}
|
||||
fun playStatusListener(){
|
||||
|
||||
}
|
||||
|
||||
fun setData(currentMedia: TaxiPassengerVideoPlay) {
|
||||
if(gsyVideoOptionBuilder==null){
|
||||
gsyVideoOptionBuilder = GSYVideoOptionBuilder()
|
||||
}
|
||||
|
||||
gsyVideoOptionBuilder
|
||||
?.setEnlargeImageRes(R.drawable.taxt_u_p_change_full)
|
||||
?.setUrl(currentMedia.url)
|
||||
?.setCacheWithPlay(true)
|
||||
?.setPlayTag(currentMedia.url)
|
||||
?.setThumbPlay(false)
|
||||
?.setStartAfterPrepared(currentMedia.type == MediaItem.MEDIA_TYPE_VIDEO)
|
||||
?.build(this)
|
||||
setFileType(currentMedia.type)
|
||||
|
||||
coverImage
|
||||
|
||||
Glide.with(context)
|
||||
.load(currentMedia.imageUrl)
|
||||
.apply(RequestOptions().placeholder(placeholderDrawable).centerCrop())
|
||||
.into(coverImage)
|
||||
}
|
||||
|
||||
interface OnPlayStatusListener {
|
||||
fun onStatusChange(status: Int)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 317 KiB |
@@ -33,6 +33,7 @@
|
||||
android:layout_marginStart="@dimen/dp_18"
|
||||
android:layout_marginEnd="@dimen/dp_10"
|
||||
android:textSize="@dimen/dp_29"
|
||||
android:ellipsize="end"
|
||||
android:textColor="@color/white"
|
||||
android:singleLine="true"
|
||||
android:text="蘑菇车联湖南衡阳蘑菇车联湖南衡阳智…"
|
||||
|
||||
@@ -8,6 +8,29 @@
|
||||
android:background="@drawable/taxt_u_p_video_light_bg"
|
||||
tools:ignore="MissingDefaultResource">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_playing_title"
|
||||
android:text="蘑菇车联湖南衡阳智能运营中心全揭露"
|
||||
android:textColor="@color/taxi_cp_394047"
|
||||
android:textSize="@dimen/dp_40"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginTop="@dimen/dp_180"
|
||||
android:layout_marginStart="@dimen/dp_90"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<com.mogo.och.unmanned.passenger.widget.ConsultVideoPlayer
|
||||
android:id="@+id/video_item_player"
|
||||
android:layout_gravity="center"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="@dimen/dp_90"
|
||||
android:layout_marginTop="@dimen/dp_261"
|
||||
android:layout_width="@dimen/dp_1920"
|
||||
android:layout_height="1080dp" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/infoVideoPlaylist"
|
||||
android:layout_width="@dimen/dp_410"
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true"
|
||||
android:background="@drawable/road_video_bg"
|
||||
android:scaleType="fitXY" />
|
||||
</RelativeLayout>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user