[视频播放、到达目的地ui修改]
This commit is contained in:
yangyakun
2023-07-26 21:15:35 +08:00
parent 328245f3af
commit 19e9f4b21a
8 changed files with 188 additions and 140 deletions

View File

@@ -1,6 +1,5 @@
package com.mogo.och.taxi.passenger.ui
import android.graphics.drawable.AnimationDrawable
import android.os.Bundle
import android.view.View
import com.mogo.commons.mvp.MvpFragment
@@ -249,7 +248,7 @@ class TaxiPassengerBaseFragment() :
*/
fun showOrHideStartAutopilotView(isShow: Boolean) {
if (isShow) {
exitFullVideoScreen()
exitFullVideoScreen(false)
if (mStartAutopilotView == null || mStartAutopilotView!!.get() == null) {
mStartAutopilotView = WeakReference(StartAutopilotView(requireContext()))
}
@@ -274,7 +273,7 @@ class TaxiPassengerBaseFragment() :
*/
fun showOrHideArrivedEndLayout(isShow: Boolean) {
if (isShow) {
exitFullVideoScreen()
exitFullVideoScreen(true)
if (mArrivedEndView == null || mArrivedEndView!!.get() == null) {
mArrivedEndView = WeakReference(ArrivedView(context))
}
@@ -292,8 +291,8 @@ class TaxiPassengerBaseFragment() :
}
}
private fun exitFullVideoScreen(){
infoVideoView.exitFullScreenMode()
private fun exitFullVideoScreen(resetVideoPlayer: Boolean) {
infoVideoView.exitFullScreenMode(resetVideoPlayer)
}
fun showOrHideOverMapView(){
@@ -317,7 +316,7 @@ class TaxiPassengerBaseFragment() :
) {
try {
if (isShow) {
exitFullVideoScreen()
exitFullVideoScreen(false)
if (mArrivedCheckView == null || mArrivedCheckView!!.get() == null) {
initCheckView()
}

View File

@@ -0,0 +1,123 @@
package com.mogo.och.taxi.passenger.ui.arrived
import android.content.Context
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.LayoutInflater
import androidx.constraintlayout.widget.ConstraintLayout
import com.bumptech.glide.Priority
import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions
import com.bumptech.glide.request.target.CustomTarget
import com.bumptech.glide.request.transition.Transition
import com.mogo.eagle.core.function.api.autopilot.IMoGoBackCameraVideoListener
import com.mogo.eagle.core.function.api.autopilot.IMoGoRoboBusJinlvM1StitchedVideoListener
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager.setIsSubscribeBackCameraVideoVideo
import com.mogo.eagle.core.function.call.autopilot.CallerBackCameraVideoListenerManager
import com.mogo.eagle.core.function.call.autopilot.CallerRoboBusJinlvM1StitchedVideoListenerManager
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp
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.util.ThreadUtils
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
import com.mogo.och.taxi.passenger.R
import kotlinx.android.synthetic.main.taxi_p_right_rear_cam.view.actv_cam_position_group
import kotlinx.android.synthetic.main.taxi_p_right_rear_cam.view.v_video_right_rear
/**
*
* 评价View
* Created on 2022/5/16
*/
class RightRearCamView : ConstraintLayout , IMoGoBackCameraVideoListener,
IMoGoRoboBusJinlvM1StitchedVideoListener {
constructor(context: Context) : super(context)
constructor(context: Context, attributeSet: AttributeSet) : super(context, attributeSet)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int) : super(context, attributeSet, defStyleAttr)
constructor(context: Context, attributeSet: AttributeSet, defStyleAttr: Int, defStyleRes: Int) : super(context, attributeSet, defStyleAttr, defStyleRes)
private val requestOptions = RequestOptions()
.priority(Priority.HIGH)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.dontAnimate()
private val target: CustomTarget<Bitmap?> = object : CustomTarget<Bitmap?>() {
override fun onResourceReady(resource: Bitmap, transition: Transition<in Bitmap?>?) {
if (!resource.isRecycled&&v_video_right_rear!=null) {
v_video_right_rear.setImageBitmap(resource)
}
}
override fun onLoadCleared(placeholder: Drawable?) {
//这个方法在target被回收时调用如果在除了imageView以外的地方引用了imageView中的bitmap在这里清除引用以避免崩溃
}
}
private fun initView() {
d(SceneConstant.M_TAXI_P + TAG, "initView")
LayoutInflater.from(context).inflate(R.layout.taxi_p_right_rear_cam, this, true)
}
override fun onAttachedToWindow() {
super.onAttachedToWindow()
setIsSubscribeBackCameraVideoVideo(1, true)
CallerBackCameraVideoListenerManager.addListener(TAG, this)
CallerRoboBusJinlvM1StitchedVideoListenerManager.addListener(TAG, this)
}
override fun onDetachedFromWindow() {
super.onDetachedFromWindow()
setIsSubscribeBackCameraVideoVideo(1, false)
CallerBackCameraVideoListenerManager.removeListener(this)
CallerRoboBusJinlvM1StitchedVideoListenerManager.removeListener(this)
}
companion object {
const val TAG = "RightRearCamView"
}
init {
try {
initView()
} catch (e: Exception) {
e.printStackTrace()
}
}
private fun draw(data: ByteArray) {
ThreadUtils.runOnUiThread {
if(actv_cam_position_group.visibility == GONE) {
actv_cam_position_group.visibility = VISIBLE
}
GlideApp.with(v_video_right_rear)
.asBitmap()
.load(data)
.placeholder(R.drawable.taxi_p_right_rear_cam)
.apply(requestOptions)
.into(target)
}
}
override fun onBackCameraVideo(data: ByteArray) {
draw(data)
}
override fun onRoboBusJinlvM1StitchedVideo(data: ByteArray) {
draw(data)
}
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
super.onSizeChanged(w, h, oldw, oldh)
outlineProvider = TextureVideoViewOutlineProvider(36f)
clipToOutline = true
}
}

View File

@@ -1,107 +0,0 @@
package com.mogo.och.taxi.passenger.ui.arrived;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import com.bumptech.glide.Priority;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.mogo.eagle.core.function.api.autopilot.IMoGoBackCameraVideoListener;
import com.mogo.eagle.core.function.api.autopilot.IMoGoRoboBusJinlvM1StitchedVideoListener;
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotControlManager;
import com.mogo.eagle.core.function.call.autopilot.CallerBackCameraVideoListenerManager;
import com.mogo.eagle.core.function.call.autopilot.CallerRoboBusJinlvM1StitchedVideoListenerManager;
import com.mogo.eagle.core.utilcode.mogo.glide.GlideApp;
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider;
/**
* 图片帧展示View
*/
public class RightRearGlideView extends AppCompatImageView implements IMoGoBackCameraVideoListener, IMoGoRoboBusJinlvM1StitchedVideoListener {
private static final String TAG = RightRearGlideView.class.getSimpleName();
private final RequestOptions requestOptions = new RequestOptions()
.priority(Priority.HIGH)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.dontAnimate();
public RightRearGlideView(@NonNull Context context) {
super(context);
}
public RightRearGlideView(@NonNull Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
}
public RightRearGlideView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
CallerAutoPilotControlManager.INSTANCE.setIsSubscribeBackCameraVideoVideo(1, true);
CallerBackCameraVideoListenerManager.INSTANCE.addListener(TAG, this);
CallerRoboBusJinlvM1StitchedVideoListenerManager.INSTANCE.addListener(TAG, this);
}
@Override
protected void onDetachedFromWindow() {
super.onDetachedFromWindow();
CallerAutoPilotControlManager.INSTANCE.setIsSubscribeBackCameraVideoVideo(1, false);
CallerBackCameraVideoListenerManager.INSTANCE.removeListener(this);
CallerRoboBusJinlvM1StitchedVideoListenerManager.INSTANCE.removeListener(this);
}
private final CustomTarget<Bitmap> target = new CustomTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @Nullable Transition<? super Bitmap> transition) {
//回调内容
if (!resource.isRecycled()) {
RightRearGlideView.this.setImageBitmap(resource);
}
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
//这个方法在target被回收时调用如果在除了imageView以外的地方引用了imageView中的bitmap在这里清除引用以避免崩溃
}
};
private void draw(@NonNull byte[] data) {
ThreadUtils.runOnUiThread(() -> GlideApp.with(RightRearGlideView.this)
.asBitmap()
.load(data)
.placeholder(RightRearGlideView.this.getDrawable())
.apply(requestOptions)
.into(target));
}
@Override
public void onBackCameraVideo(@NonNull byte[] data) {
draw(data);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
setOutlineProvider(new TextureVideoViewOutlineProvider(36F));
setClipToOutline(true);
}
@Override
public void onRoboBusJinlvM1StitchedVideo(@NonNull byte[] data) {
draw(data);
}
}

View File

@@ -77,11 +77,15 @@ internal class InfoVideoView @JvmOverloads constructor(
}
}
fun exitFullScreenMode() {
fun exitFullScreenMode(resetVideoPlayer: Boolean) {
val carouselLayoutManager = rvVideoPlaylist?.layoutManager as CarouselLayoutManager
val (centerItemPosition: Int, player) = getPlayer(carouselLayoutManager)
player?.let {
it.exitFullScreenMode()
it.onVideoPause()
if(resetVideoPlayer) {
it.onVideoReset()
}
}
}

View File

@@ -145,10 +145,12 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
override fun onWindowFocusChanged(hasWindowFocus: Boolean) {
super.onWindowFocusChanged(hasWindowFocus)
if(hasWindowFocus){//获取焦点
onVideoResume()
}else{
onVideoPause()
if(isIfCurrentIsFullscreen&&smalllPlayer!=null){
if(hasWindowFocus){//获取焦点
onVideoResume()
}else{
onVideoPause()
}
}
}
@@ -333,8 +335,10 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
}
fun exitFullScreenMode() {
fullVideoPlayer?.let { clearFullscreenLayout(it) }
FullVideoUtils.dismissOverlayView(false)
fullVideoPlayer?.let {
clearFullscreenLayout(it)
FullVideoUtils.dismissOverlayView(false)
}
}
private fun startWindowFullscreenOwn(context:Context){

Binary file not shown.

Before

Width:  |  Height:  |  Size: 136 KiB

After

Width:  |  Height:  |  Size: 71 KiB

View File

@@ -49,34 +49,15 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<com.mogo.och.taxi.passenger.ui.arrived.RightRearGlideView
<com.mogo.och.taxi.passenger.ui.arrived.RightRearCamView
android:id="@+id/v_video_right_rear"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:layout_marginStart="@dimen/dp_90"
android:src="@drawable/taxi_p_right_rear_cam"
android:layout_marginBottom="@dimen/dp_90"
android:layout_width="@dimen/dp_900"
android:layout_height="@dimen/dp_506"/>
<androidx.appcompat.widget.AppCompatImageView
android:src="@drawable/taxi_p_arrived_glide"
app:layout_constraintStart_toStartOf="@+id/v_video_right_rear"
app:layout_constraintBottom_toBottomOf="@+id/v_video_right_rear"
android:layout_width="@dimen/dp_318"
android:layout_height="@dimen/dp_77"/>
<androidx.appcompat.widget.AppCompatTextView
app:layout_constraintStart_toStartOf="@+id/v_video_right_rear"
app:layout_constraintBottom_toBottomOf="@+id/v_video_right_rear"
android:layout_marginStart="@dimen/dp_44"
android:layout_marginBottom="@dimen/dp_11"
android:text="后向摄像头"
android:textSize="@dimen/dp_40"
android:textColor="@color/taxi_p_76D7FF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<View
android:id="@+id/v_xiaozhi_belt_info_bg"

View File

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="@dimen/dp_900"
android:layout_height="@dimen/dp_506"
tools:parentTag="androidx.constraintlayout.widget.ConstraintLayout"
tools:ignore="MissingDefaultResource">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/v_video_right_rear"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:src="@drawable/taxi_p_right_rear_cam"
android:layout_width="@dimen/dp_900"
android:layout_height="@dimen/dp_506"/>
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/actv_cam_position"
android:src="@drawable/taxi_p_arrived_glide"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="@dimen/dp_318"
android:layout_height="@dimen/dp_77"/>
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/actv_cam_position_title"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginStart="@dimen/dp_44"
android:layout_marginBottom="@dimen/dp_11"
android:text="后向摄像头"
android:textSize="@dimen/dp_40"
android:textColor="@color/taxi_p_76D7FF"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<androidx.constraintlayout.widget.Group
android:id="@+id/actv_cam_position_group"
app:constraint_referenced_ids="actv_cam_position,actv_cam_position_title"
android:visibility="gone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</merge>