diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt index 4fc77d7681..f2d0ce3b69 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/TaxiPassengerBaseFragment.kt @@ -20,15 +20,7 @@ import com.mogo.och.taxi.passenger.presenter.BaseTaxiPassengerPresenter import com.mogo.och.taxi.passenger.ui.bottom.BottomBar import com.mogo.och.taxi.passenger.ui.arrived.ArrivedView import com.mogo.och.taxi.passenger.ui.startautopilot.StartAutopilotView -import kotlinx.android.synthetic.main.taxi_p_base_fragment.aciv_xiaozhi_normal -import kotlinx.android.synthetic.main.taxi_p_base_fragment.bottom -import kotlinx.android.synthetic.main.taxi_p_base_fragment.ck_setting -import kotlinx.android.synthetic.main.taxi_p_base_fragment.itinerary -import kotlinx.android.synthetic.main.taxi_p_base_fragment.mapBizView -import kotlinx.android.synthetic.main.taxi_p_base_fragment.overMapView -import kotlinx.android.synthetic.main.taxi_p_base_fragment.pcnActionView -import kotlinx.android.synthetic.main.taxi_p_base_fragment.romaPView -import kotlinx.android.synthetic.main.taxi_p_base_fragment.rv_location_center +import kotlinx.android.synthetic.main.taxi_p_base_fragment.* import java.lang.ref.WeakReference /** @@ -93,6 +85,7 @@ class TaxiPassengerBaseFragment() : rv_location_center.visibility = View.VISIBLE pcnActionView.visibility = View.VISIBLE CallerHmiManager.showTrafficLightView() + infoVideoView.visibility = View.GONE } BottomBar.SelectView.OVERMAPVIEW -> { overMapView.visibility = View.VISIBLE @@ -103,6 +96,7 @@ class TaxiPassengerBaseFragment() : rv_location_center.visibility = View.VISIBLE pcnActionView.visibility = View.VISIBLE CallerHmiManager.showTrafficLightView() + infoVideoView.visibility = View.GONE } BottomBar.SelectView.VIDEO -> { overMapView.visibility = View.GONE @@ -113,6 +107,7 @@ class TaxiPassengerBaseFragment() : rv_location_center.visibility = View.GONE pcnActionView.visibility = View.GONE CallerHmiManager.hideTrafficLightView() + infoVideoView.visibility = View.VISIBLE } } diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt new file mode 100644 index 0000000000..62e011e446 --- /dev/null +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/InfoVideoView.kt @@ -0,0 +1,214 @@ +package com.mogo.och.taxi.passenger.ui.video + +import android.content.Context +import android.graphics.Color +import android.util.AttributeSet +import android.view.LayoutInflater +import android.view.View +import android.widget.FrameLayout +import androidx.constraintlayout.widget.ConstraintLayout +import androidx.recyclerview.widget.RecyclerView +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 +import com.mogo.och.taxi.passenger.ui.video.layoutmanage.CarouselZoomPostLayoutListener +import com.mogo.och.taxi.passenger.ui.video.layoutmanage.CenterScrollListener +import com.mogo.och.taxi.passenger.widget.ConsultVideoPlayer +import com.mogo.och.taxi.passenger.widget.indicator.IndicatorView +import com.mogo.och.taxi.passenger.widget.indicator.enums.IndicatorOrientation +import com.mogo.och.taxi.passenger.widget.indicator.enums.IndicatorSlideMode +import com.mogo.och.taxi.passenger.widget.indicator.enums.IndicatorStyle +import com.shuyu.gsyvideoplayer.video.base.GSYVideoView +import kotlin.math.floor + +/** + * @author ChenFufeng + * 蘑菇资讯视频 + */ +internal class InfoVideoView @JvmOverloads constructor( + context: Context, + attrs: AttributeSet? = null, + defStyleAttr: Int = 0 +) : FrameLayout( + context, + attrs, + defStyleAttr +) { + + companion object{ + private const val TAG = "VideoView" + } + + init { + LayoutInflater.from(context).inflate(R.layout.taxi_p_mogo_video_layout, this, true) + initView() + } + + private var rvVideoPlaylist: RecyclerView? = null + private lateinit var indicatorView: IndicatorView + private lateinit var clContain: ConstraintLayout + + private val arrayListOf by lazy { + arrayListOf().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( + com.mogo.och.taxi.passenger.bean.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", + "多视角体验蘑菇车联自动驾驶" + ) + ) + } + } + + fun exitFullScreenMode() { + val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager + val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager) + player?.let { + it.exitFullScreenMode() + } + } + + override fun onAttachedToWindow() { + super.onAttachedToWindow() + configPage() + } + + override fun onVisibilityChanged(changedView: View, visibility: Int) { + super.onVisibilityChanged(changedView, visibility) + val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager + val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager) + when (visibility) { + View.VISIBLE -> { + player?.let { + if (!player.isIfCurrentIsFullscreen) { + when (player.currentState) { + GSYVideoView.CURRENT_STATE_PAUSE -> { + player.onVideoResume(false) + } + else -> {} + } + } + } + } + else -> { + player?.let { + if (!player.isIfCurrentIsFullscreen) { + player.onVideoPause() + } + } + } + } + } + + private fun initView() { + rvVideoPlaylist = findViewById(R.id.infoVideoPlaylist) + indicatorView = findViewById(R.id.infoIndicatorView) + 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.setSlideMode(IndicatorSlideMode.SCALE) + indicatorView.setOrientation(IndicatorOrientation.INDICATOR_HORIZONTAL) + indicatorView.setIndicatorStyle(IndicatorStyle.ROUND_RECT) + indicatorView.setSliderColor( + Color.parseColor("#80000000"), Color.parseColor("#3FACFD"), + Color.parseColor("#3FACFD") + ) + indicatorView.setSliderWidth(9f, 54f) + indicatorView.setSliderHeight(9f) + indicatorView.setSliderGap(36f) + rvVideoPlaylist?.addOnScrollListener(object : CenterScrollListener() { + var prePlayerPosition = 0 + override fun pageSelect(recyclerView: RecyclerView?, newState: Int) { + //播放视频 + val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager) + indicatorView.onPageSelected(centerItemPosition) + if (player is ConsultVideoPlayer) { + if (prePlayerPosition != centerItemPosition) { + if (player.currentState == GSYVideoView.CURRENT_STATE_PAUSE) { + player.onVideoReset() + } + val playerHolder = + carouselLayoutManager.findViewByPosition(prePlayerPosition) + val prePlayer = + playerHolder?.findViewById(R.id.video_item_player) + prePlayer?.onVideoReset() + val taxiPassengerVideoPlay = arrayListOf[centerItemPosition] + } else { + player.onVideoResume(false) + } + } + prePlayerPosition = centerItemPosition + } + + override fun pageStop() { + val (_: Int, player) = getPlayer(carouselLayoutManager) + if (player is ConsultVideoPlayer) { + player.onVideoPause() + } + } + + }) + carouselLayoutManager.addOnDargAutoDiffListener { adapterPosition, currentPosition -> + val fl = adapterPosition - floor(adapterPosition) + var currentIndex = currentPosition + if (fl > 0.5) { + if (currentPosition == 0) { + currentIndex = rvVideoPlaylist?.adapter!!.itemCount - 1 + } else { + currentIndex -= 1 + } + } + indicatorView.onPageScrolled(currentIndex, fl, 0) + } + val recyclerVideoAdapter = RecyclerVideoAdapter(context, arrayListOf, rvVideoPlaylist) + recyclerVideoAdapter.setOnThumbImageClilckListener { + val (_: Int, player) = getPlayer(carouselLayoutManager) + if (player is ConsultVideoPlayer) { + player.onVideoReset() + player.thumbImageViewLayout.visibility = View.VISIBLE + } + rvVideoPlaylist?.smoothScrollToPosition(it) + } + rvVideoPlaylist?.layoutManager = carouselLayoutManager + rvVideoPlaylist?.setHasFixedSize(true) + rvVideoPlaylist?.adapter = recyclerVideoAdapter + } + + private fun getPlayer(carouselLayoutManager: CarouselLayoutManager): Pair { + val centerItemPosition: Int = carouselLayoutManager.centerItemPosition + val playerHolder = carouselLayoutManager.findViewByPosition(centerItemPosition) + val player = playerHolder?.findViewById(R.id.video_item_player) + return Pair(centerItemPosition, player) + } + + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + } +} \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java index 49fac8a530..fb8e3c05b1 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java +++ b/OCH/mogo-och-taxi-passenger/src/main/java/com/mogo/och/taxi/passenger/ui/video/RecyclerVideoAdapter.java @@ -52,7 +52,7 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter - + \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/bg_taxi_p_video_light_bg_shape.xml b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/bg_taxi_p_video_light_bg_shape.xml new file mode 100644 index 0000000000..387f89e2eb --- /dev/null +++ b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/bg_taxi_p_video_light_bg_shape.xml @@ -0,0 +1,10 @@ + + + + + diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_video_seekbar_style.xml b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_video_seekbar_style.xml index c7f6f83c1c..30ed19fa3c 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_video_seekbar_style.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/drawable/taxi_video_seekbar_style.xml @@ -3,22 +3,22 @@ xmlns:android="http://schemas.android.com/apk/res/android"> - - + + - - + + - + diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/layout/list_video_item_light.xml b/OCH/mogo-och-taxi-passenger/src/main/res/layout/list_video_item_light.xml new file mode 100644 index 0000000000..c4c17d3f8c --- /dev/null +++ b/OCH/mogo-och-taxi-passenger/src/main/res/layout/list_video_item_light.xml @@ -0,0 +1,18 @@ + + + + + + diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml index 8c996a51c3..975ae40446 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_base_fragment.xml @@ -15,6 +15,12 @@ app:mapStylePath="style.data" /> + + + + + + + + + + \ No newline at end of file diff --git a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_video_show.xml b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_video_show.xml index c112692d65..e514c8bd11 100644 --- a/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_video_show.xml +++ b/OCH/mogo-och-taxi-passenger/src/main/res/layout/taxi_p_video_show.xml @@ -45,10 +45,11 @@ android:id="@+id/fullscreen" app:layout_constraintTop_toTopOf="parent" app:layout_constraintEnd_toEndOf="parent" - android:layout_width="wrap_content" - android:layout_height="match_parent" - android:paddingEnd="40dp" - android:paddingStart="93dp" + app:layout_constraintBottom_toBottomOf="parent" + android:layout_width="69dp" + android:layout_height="69dp" + android:layout_marginEnd="49dp" + android:scaleType="fitXY" android:src="@drawable/taxi_p_change_full" />