全屏切换
@@ -26,6 +26,7 @@ import com.mogo.och.taxi.passenger.R;
|
||||
import com.mogo.och.taxi.passenger.callback.ITPClickStartAutopilotCallback;
|
||||
import com.mogo.och.taxi.passenger.presenter.BaseTaxiPassengerPresenter;
|
||||
import com.mogo.och.taxi.passenger.ui.comment.TaxiPassengerArrivedView;
|
||||
import com.mogo.och.taxi.passenger.ui.leftmenu.OverlayLeftViewUtils;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
@@ -122,8 +123,8 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
});
|
||||
|
||||
findViewById(R.id.iv_temp).setOnClickListener(view -> {
|
||||
//OverlayLeftViewUtils.INSTANCE.showOverlayView(getActivity());
|
||||
showOrHideArrivedEndLayout(true, "北京北京北京", "1527481606997577728");
|
||||
OverlayLeftViewUtils.INSTANCE.showOverlayView(getActivity());
|
||||
//showOrHideArrivedEndLayout(true, "北京北京北京", "1527481606997577728");
|
||||
//showOrHidePressengerCheckPager(true, "开始站点开", "开始站点开始站点开始", "2", "京A888888", "18811539480");
|
||||
//OCHFloatWindowManager.getInstance().ShowFloatWindow(getContext());
|
||||
//OverlayViewUtils.showOverlayView(getActivity(),new TaxiPassengerMogoConsultView(getContext()));
|
||||
@@ -258,6 +259,7 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
if (ochServingOrderFragment == null){
|
||||
ochServingOrderFragment = new TaxiPassengerServingOrderFragment().newInstance();
|
||||
}
|
||||
OverlayLeftViewUtils.INSTANCE.showOverlayView(getActivity());
|
||||
if (ochServingOrderFragment.isHidden()){
|
||||
transaction.show(ochServingOrderFragment).commitAllowingStateLoss();
|
||||
return;
|
||||
@@ -274,6 +276,7 @@ public class TaxiPassengerBaseFragment extends MvpFragment<TaxiPassengerBaseFrag
|
||||
if (ochServingOrderFragment != null){
|
||||
transaction.hide(ochServingOrderFragment).commitAllowingStateLoss();
|
||||
}
|
||||
OverlayLeftViewUtils.INSTANCE.dismissOverlayView();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,9 +46,6 @@ object OverlayLeftViewUtils {
|
||||
const val DEVIATION_WIDTH = -669
|
||||
|
||||
|
||||
/**
|
||||
* 记录上一次的View
|
||||
*/
|
||||
private var overlayView: View?=null
|
||||
|
||||
private var subscribe: Disposable?=null
|
||||
@@ -61,6 +58,9 @@ object OverlayLeftViewUtils {
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun showOverlayView(context: Activity, ani: Int = -1) {
|
||||
if (isShowing) {
|
||||
return
|
||||
}
|
||||
if (applicationContext == null) {
|
||||
applicationContext = context.applicationContext
|
||||
}
|
||||
@@ -77,7 +77,7 @@ object OverlayLeftViewUtils {
|
||||
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||
layoutParams(ani)
|
||||
layoutParams(ani,view)
|
||||
|
||||
// 如果正在展示中,并且lastOverlayView不为null,先做移除操作,保证覆盖在最上面的View只有一个,防止叠加导致无法移除
|
||||
dismissOverlayView()
|
||||
@@ -181,6 +181,13 @@ object OverlayLeftViewUtils {
|
||||
private fun open(overlayView: View,windowManager: WindowManager?) {
|
||||
params?.x = 0
|
||||
windowManager?.updateViewLayout(overlayView, params)
|
||||
closeByTime(overlayView, windowManager)
|
||||
}
|
||||
|
||||
private fun closeByTime(
|
||||
overlayView: View,
|
||||
windowManager: WindowManager?
|
||||
) {
|
||||
subscribe?.let {
|
||||
if (!it.isDisposed) {
|
||||
it.dispose()
|
||||
@@ -189,8 +196,8 @@ object OverlayLeftViewUtils {
|
||||
subscribe = Observable.timer(3000, TimeUnit.MILLISECONDS)
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe {
|
||||
if(params?.x==0){
|
||||
close(overlayView,windowManager)
|
||||
if (params?.x == 0) {
|
||||
close(overlayView, windowManager)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -203,7 +210,7 @@ object OverlayLeftViewUtils {
|
||||
windowManager?.updateViewLayout(overlayView, params)
|
||||
}
|
||||
|
||||
private fun layoutParams(ani: Int) {
|
||||
private fun layoutParams(ani: Int,view :View) {
|
||||
if(params ==null) {
|
||||
params = WindowManager.LayoutParams()
|
||||
}
|
||||
@@ -212,7 +219,7 @@ object OverlayLeftViewUtils {
|
||||
it.height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
it.alpha = 1.0f
|
||||
it.gravity = Gravity.START or Gravity.TOP
|
||||
it.x = DEVIATION_WIDTH
|
||||
it.x = 0
|
||||
it.y = 0
|
||||
it.format = PixelFormat.RGBA_8888
|
||||
// 设置窗口类型为应用子窗口,和PopupWindow同类型
|
||||
@@ -224,6 +231,7 @@ object OverlayLeftViewUtils {
|
||||
if (ani != -1) {
|
||||
it.windowAnimations = ani
|
||||
}
|
||||
closeByTime(view, windowManager)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.mogo.och.taxi.passenger.ui.video
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.mogo.och.taxi.passenger.ui.video.FullVideoUtils
|
||||
import java.lang.Exception
|
||||
|
||||
/**
|
||||
* 遮罩层工具类
|
||||
*
|
||||
* @author mogoauto
|
||||
*/
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
object FullVideoUtils {
|
||||
private const val TAG = "OverlayViewUtils"
|
||||
private var windowManager: WindowManager? = null
|
||||
private var applicationContext: Context? = null
|
||||
|
||||
@Volatile
|
||||
private var isShowing = false
|
||||
|
||||
/**
|
||||
* 记录上一次的View
|
||||
*/
|
||||
private var lastOverlayView: View? = null
|
||||
|
||||
/**
|
||||
* 添加覆盖View在Activity上面
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun showOverlayView(context: Activity, overlayView: View, ani: Int = -1) {
|
||||
if (applicationContext == null) {
|
||||
applicationContext = context.applicationContext
|
||||
}
|
||||
if (windowManager == null) {
|
||||
windowManager = context.windowManager
|
||||
}
|
||||
|
||||
// 设置View显示模式,沉浸式的侵入到状态栏,导航栏
|
||||
overlayView.systemUiVisibility = (View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
|
||||
or View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY
|
||||
or View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
|
||||
or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
||||
or View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION)
|
||||
val params = WindowManager.LayoutParams()
|
||||
params.width = WindowManager.LayoutParams.MATCH_PARENT
|
||||
params.height = WindowManager.LayoutParams.MATCH_PARENT
|
||||
params.alpha = 1.0f
|
||||
// 设置窗口类型为应用子窗口,和PopupWindow同类型
|
||||
params.type = WindowManager.LayoutParams.TYPE_APPLICATION_PANEL
|
||||
// 没有边界限制,允许窗口扩展到屏幕外
|
||||
params.flags = WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS
|
||||
if (ani != -1) {
|
||||
params.windowAnimations = ani
|
||||
}
|
||||
try {
|
||||
// 后门逻辑,长时间触摸消失
|
||||
lastOverlayView = overlayView
|
||||
windowManager!!.addView(overlayView, params)
|
||||
isShowing = true
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除覆盖View在Activity上面
|
||||
*/
|
||||
fun dismissOverlayView() {
|
||||
if (!isShowing) {
|
||||
return
|
||||
}
|
||||
try {
|
||||
if (windowManager != null) {
|
||||
windowManager!!.removeView(lastOverlayView)
|
||||
}
|
||||
if (lastOverlayView != null) {
|
||||
lastOverlayView = null
|
||||
}
|
||||
isShowing = false
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,15 +19,12 @@ public class RecyclerItemVideoHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
public ConsultVideoPlayer gsyVideoPlayer;
|
||||
|
||||
ImageView imageView;
|
||||
|
||||
GSYVideoOptionBuilder gsyVideoOptionBuilder;
|
||||
|
||||
public RecyclerItemVideoHolder(Context context, View v) {
|
||||
super(v);
|
||||
this.context = context;
|
||||
gsyVideoPlayer = v.findViewById(R.id.video_item_player);
|
||||
imageView = new ImageView(context);
|
||||
gsyVideoOptionBuilder = new GSYVideoOptionBuilder();
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +46,17 @@ public class RecyclerVideoAdapter extends RecyclerView.Adapter<RecyclerItemVideo
|
||||
public void onBindViewHolder(@NonNull final RecyclerItemVideoHolder holder, int position) {
|
||||
final TaxiPassengerVideoPlay taxiPassengerVideoPlay = itemDataList.get(position);
|
||||
|
||||
holder.gsyVideoOptionBuilder.setUrl(taxiPassengerVideoPlay.getUrl()).setCacheWithPlay(true).setPlayTag(taxiPassengerVideoPlay.getImageUrl()+position)
|
||||
holder.gsyVideoOptionBuilder
|
||||
.setUrl(taxiPassengerVideoPlay.getUrl())
|
||||
.setCacheWithPlay(true)
|
||||
.setPlayTag(taxiPassengerVideoPlay.getImageUrl()+position)
|
||||
.setThumbImageView(holder.gsyVideoPlayer.coverImage)
|
||||
.setThumbPlay(true)
|
||||
.build(holder.gsyVideoPlayer);
|
||||
holder.gsyVideoPlayer.setTitle(taxiPassengerVideoPlay.getTitle());
|
||||
Glide.with(context)
|
||||
.load(taxiPassengerVideoPlay.getImageUrl())
|
||||
.apply(new RequestOptions().centerCrop())
|
||||
.apply(new RequestOptions().placeholder(R.drawable.taxi_p_video_holder).centerCrop())
|
||||
.into(holder.gsyVideoPlayer.coverImage);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ class TaxiPassengerMogoConsultView :RelativeLayout {
|
||||
arrayListOf.add(TaxiPassengerVideoPlay("https://gohome-1253308323.cos.ap-beijing.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4","https://gohome-1253308323.cos.ap-beijing.myqcloud.com/12111.jpg","title"))
|
||||
arrayListOf.add(TaxiPassengerVideoPlay("https://gohome-1253308323.cos.ap-beijing.myqcloud.com/McTk51586843620689.mp4","https://gohome-1253308323.cos.ap-beijing.myqcloud.com/McTk51586843620689.png","title"))
|
||||
arrayListOf.add(TaxiPassengerVideoPlay("https://gohome-1253308323.cos.ap-beijing.myqcloud.com/9890_4e292f9a3dd011e6b4078980237cc3d3.f20.mp4","https://gohome-1253308323.cos.ap-beijing.myqcloud.com/12111.jpg","title"))
|
||||
//TaxiPassengerMogoMoviesView
|
||||
|
||||
val recyclerVideoAdapter = RecyclerVideoAdapter(context, arrayListOf)
|
||||
val carouselLayoutManager = CarouselLayoutManager(CarouselLayoutManager.HORIZONTAL, true)
|
||||
carouselLayoutManager.setPostLayoutListener(CarouselZoomPostLayoutListener ())
|
||||
@@ -160,21 +160,34 @@ class TaxiPassengerMogoConsultView :RelativeLayout {
|
||||
if (player is ConsultVideoPlayer) {
|
||||
if(hasWindowFocus){// 获取焦点两种情况
|
||||
// 恢复播放和开始播放
|
||||
when (player.currentState) {
|
||||
GSYVideoView.CURRENT_STATE_PAUSE -> {
|
||||
player.onVideoResume(false)
|
||||
}
|
||||
else -> {
|
||||
val recyclerVideoAdapter =
|
||||
rvVideoPlaylist.adapter as RecyclerVideoAdapter
|
||||
setBackageAndPlayNext(recyclerVideoAdapter.getItemByPosition(centerItemPosition), player, centerItemPosition)
|
||||
player.startPlayLogic()
|
||||
if(player.isIfCurrentIsFullscreen){// 全屏了
|
||||
|
||||
}else {
|
||||
when (player.currentState) {
|
||||
GSYVideoView.CURRENT_STATE_PAUSE -> {
|
||||
player.onVideoResume(false)
|
||||
}
|
||||
GSYVideoView.CURRENT_STATE_PLAYING -> {
|
||||
}
|
||||
else -> {
|
||||
val recyclerVideoAdapter =
|
||||
rvVideoPlaylist.adapter as RecyclerVideoAdapter
|
||||
setBackageAndPlayNext(
|
||||
recyclerVideoAdapter.getItemByPosition(centerItemPosition),
|
||||
player, centerItemPosition
|
||||
)
|
||||
player.startPlayLogic()
|
||||
}
|
||||
}
|
||||
}
|
||||
}else {
|
||||
// 离开应用 暂停视频
|
||||
// 关闭 onDetachedFromWindow 会reset
|
||||
player.onVideoPause()
|
||||
if(player.isIfCurrentIsFullscreen){// 全屏了
|
||||
|
||||
}else {
|
||||
player.onVideoPause()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,6 +207,7 @@ class TaxiPassengerMogoConsultView :RelativeLayout {
|
||||
player.onVideoReset()
|
||||
}
|
||||
}
|
||||
FullVideoUtils.dismissOverlayView()
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,26 @@
|
||||
package com.mogo.och.taxi.passenger.widget
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.util.AttributeSet
|
||||
import android.view.Surface
|
||||
import android.view.View
|
||||
import android.view.*
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
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.TimeTransformUtils
|
||||
import com.mogo.eagle.core.widget.media.video.TextureVideoViewOutlineProvider
|
||||
import com.mogo.och.taxi.passenger.R
|
||||
import com.mogo.och.taxi.passenger.model.TaxiPassengerModel
|
||||
import com.shuyu.gsyvideoplayer.GSYVideoManager
|
||||
import com.mogo.och.taxi.passenger.ui.video.FullVideoUtils
|
||||
import com.shuyu.gsyvideoplayer.utils.CommonUtil
|
||||
import com.shuyu.gsyvideoplayer.utils.Debuger
|
||||
import com.shuyu.gsyvideoplayer.utils.GSYVideoType
|
||||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYBaseVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoPlayer
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
|
||||
import com.shuyu.gsyvideoplayer.video.base.GSYVideoViewBridge
|
||||
import java.lang.reflect.Constructor
|
||||
|
||||
/**
|
||||
* @author lixiaopeng
|
||||
@@ -31,6 +34,7 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
lateinit var coverImage: ImageView
|
||||
private lateinit var currentTimeTextView: TextView
|
||||
private lateinit var totalTimeTextView: TextView
|
||||
private lateinit var tvTitle: TextView
|
||||
private lateinit var layoutBottom: ConstraintLayout
|
||||
|
||||
constructor(context: Context?) : super(context)
|
||||
@@ -38,12 +42,15 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
constructor(context: Context?, fullFlag: Boolean?) : super(context, fullFlag)
|
||||
|
||||
override fun init(context: Context) {
|
||||
mEnlargeImageRes = R.drawable.taxi_p_change_full
|
||||
super.init(context)
|
||||
start = findViewById(R.id.start)
|
||||
coverImage = findViewById(R.id.thumbImage)
|
||||
currentTimeTextView = findViewById(R.id.current)
|
||||
totalTimeTextView = findViewById(R.id.total)
|
||||
layoutBottom = findViewById(R.id.layout_bottom)
|
||||
tvTitle = findViewById(R.id.tv_title)
|
||||
fullscreenButton.setOnClickListener(this)
|
||||
if (mThumbImageViewLayout != null
|
||||
&& (mCurrentState == -1 || mCurrentState == CURRENT_STATE_NORMAL || mCurrentState == CURRENT_STATE_ERROR)
|
||||
) {
|
||||
@@ -56,9 +63,8 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
return R.layout.taxi_p_video_show
|
||||
}
|
||||
|
||||
override fun getGSYVideoManager(): GSYVideoViewBridge {
|
||||
GSYVideoManager.instance().initContext(context.applicationContext)
|
||||
return GSYVideoManager.instance()
|
||||
fun setTitle(title:String){
|
||||
tvTitle.text = title
|
||||
}
|
||||
|
||||
override fun updateStartImage() {
|
||||
@@ -98,10 +104,20 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
|
||||
mProgressBar?.progress = 0
|
||||
mFullPauseBitmap = null
|
||||
if(mIfCurrentIsFullscreen){
|
||||
FullVideoUtils.dismissOverlayView()
|
||||
clearFullscreenLayout()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onClick(v: View?) {
|
||||
super.onClick(v)
|
||||
when (v?.id) {
|
||||
R.id.fullscreen -> {
|
||||
startWindowFullscreenOwn(context, false, false)
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCompletion() {
|
||||
@@ -144,6 +160,14 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
override fun onAutoCompletion() {
|
||||
super.onAutoCompletion()
|
||||
if(mIfCurrentIsFullscreen){
|
||||
FullVideoUtils.dismissOverlayView()
|
||||
clearFullscreenLayout()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) {
|
||||
super.onSizeChanged(w, h, oldw, oldh)
|
||||
if (!mIfCurrentIsFullscreen) {
|
||||
@@ -152,5 +176,210 @@ class ConsultVideoPlayer : StandardGSYVideoPlayer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 保存大小和状态
|
||||
*/
|
||||
private fun saveLocationStatus(context: Context, statusBar: Boolean, actionBar: Boolean) {
|
||||
getLocationOnScreen(mListItemRect)
|
||||
if (context is Activity) {
|
||||
val statusBarH = CommonUtil.getStatusBarHeight(context)
|
||||
val actionBerH = CommonUtil.getActionBarHeight(context)
|
||||
val isTranslucent =
|
||||
(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS and context.window.attributes.flags
|
||||
== WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS)
|
||||
if (statusBar && !isTranslucent) {
|
||||
mListItemRect[1] = mListItemRect[1] - statusBarH
|
||||
}
|
||||
if (actionBar) {
|
||||
mListItemRect[1] = mListItemRect[1] - actionBerH
|
||||
}
|
||||
}
|
||||
mListItemSize[0] = width
|
||||
mListItemSize[1] = height
|
||||
}
|
||||
|
||||
private fun startWindowFullscreenOwn(context:Context, actionBar:Boolean, statusBar:Boolean){
|
||||
val gsyBaseVideoPlayer = startWindowFullscreen(context, actionBar, statusBar)
|
||||
gsyBaseVideoPlayer?.let {
|
||||
val gsyVideoPlayer = it as StandardGSYVideoPlayer
|
||||
gsyVideoPlayer.setLockClickListener(mLockClickListener)
|
||||
gsyVideoPlayer.isNeedLockFull = isNeedLockFull
|
||||
initFullUI(gsyVideoPlayer)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initFullUI(standardGSYVideoPlayer: StandardGSYVideoPlayer) {
|
||||
if (mBottomProgressDrawable != null) {
|
||||
standardGSYVideoPlayer.setBottomProgressBarDrawable(mBottomProgressDrawable)
|
||||
}
|
||||
if (mBottomShowProgressDrawable != null && mBottomShowProgressThumbDrawable != null) {
|
||||
standardGSYVideoPlayer.setBottomShowProgressBarDrawable(
|
||||
mBottomShowProgressDrawable,
|
||||
mBottomShowProgressThumbDrawable
|
||||
)
|
||||
}
|
||||
if (mVolumeProgressDrawable != null) {
|
||||
standardGSYVideoPlayer.setDialogVolumeProgressBar(mVolumeProgressDrawable)
|
||||
}
|
||||
if (mDialogProgressBarDrawable != null) {
|
||||
standardGSYVideoPlayer.setDialogProgressBar(mDialogProgressBarDrawable)
|
||||
}
|
||||
if (mDialogProgressHighLightColor >= 0 && mDialogProgressNormalColor >= 0) {
|
||||
standardGSYVideoPlayer.setDialogProgressColor(
|
||||
mDialogProgressHighLightColor,
|
||||
mDialogProgressNormalColor
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
override fun startWindowFullscreen(context:Context, actionBar:Boolean, statusBar:Boolean):GSYBaseVideoPlayer?{
|
||||
mSystemUiVisibility = (context as Activity).window.decorView.systemUiVisibility
|
||||
CommonUtil.hideSupportActionBar(context, actionBar, statusBar)
|
||||
if (mHideKey) {
|
||||
CommonUtil.hideNavKey(context)
|
||||
}
|
||||
mActionBar = actionBar
|
||||
mStatusBar = statusBar
|
||||
mListItemRect = IntArray(2)
|
||||
mListItemSize = IntArray(2)
|
||||
|
||||
if (mTextureViewContainer.childCount > 0) {
|
||||
mTextureViewContainer.removeAllViews()
|
||||
}
|
||||
saveLocationStatus(context, statusBar, actionBar)
|
||||
var hadNewConstructor = true
|
||||
|
||||
//切换时关闭非全屏定时器
|
||||
cancelProgressTimer()
|
||||
try {
|
||||
this@ConsultVideoPlayer.javaClass.getConstructor(
|
||||
Context::class.java,
|
||||
Boolean::class.java
|
||||
)
|
||||
} catch (e: java.lang.Exception) {
|
||||
hadNewConstructor = false
|
||||
}
|
||||
try {
|
||||
//通过被重载的不同构造器来选择
|
||||
val constructor: Constructor<ConsultVideoPlayer>
|
||||
val gsyVideoPlayer: ConsultVideoPlayer
|
||||
if (!hadNewConstructor) {
|
||||
constructor = this@ConsultVideoPlayer.javaClass.getConstructor(Context::class.java)
|
||||
gsyVideoPlayer = constructor.newInstance(mContext)
|
||||
} else {
|
||||
constructor = this@ConsultVideoPlayer.javaClass.getConstructor(
|
||||
Context::class.java,
|
||||
Boolean::class.java
|
||||
)
|
||||
gsyVideoPlayer = constructor.newInstance(mContext, true)
|
||||
}
|
||||
gsyVideoPlayer.id = fullId
|
||||
gsyVideoPlayer.isIfCurrentIsFullscreen = true
|
||||
gsyVideoPlayer.setVideoAllCallBack(mVideoAllCallBack)
|
||||
cloneParams(this, gsyVideoPlayer)
|
||||
val frameLayout = FrameLayout(context)
|
||||
if (gsyVideoPlayer.fullscreenButton != null) {
|
||||
gsyVideoPlayer.fullscreenButton.setImageResource(R.drawable.taxi_p_change_normal)
|
||||
gsyVideoPlayer.fullscreenButton.setOnClickListener { v ->
|
||||
if (mBackFromFullScreenListener == null) {
|
||||
FullVideoUtils.dismissOverlayView()
|
||||
clearFullscreenLayout(gsyVideoPlayer)
|
||||
} else {
|
||||
mBackFromFullScreenListener.onClick(v)
|
||||
}
|
||||
}
|
||||
}
|
||||
frameLayout.setBackgroundColor(Color.BLACK)
|
||||
|
||||
val lp = LayoutParams(
|
||||
width, height
|
||||
)
|
||||
frameLayout.addView(gsyVideoPlayer, lp)
|
||||
FullVideoUtils.showOverlayView(context,frameLayout)
|
||||
gsyVideoPlayer.visibility = INVISIBLE
|
||||
frameLayout.visibility = INVISIBLE
|
||||
resolveFullVideoShow(context, gsyVideoPlayer, frameLayout)
|
||||
|
||||
gsyVideoPlayer.addTextureView()
|
||||
gsyVideoPlayer.startProgressTimer()
|
||||
gsyVideoManager.setLastListener(this)
|
||||
gsyVideoManager.setListener(gsyVideoPlayer)
|
||||
checkoutState()
|
||||
return gsyVideoPlayer
|
||||
} catch (e: java.lang.Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* 全屏
|
||||
*/
|
||||
override fun resolveFullVideoShow(
|
||||
context: Context?,
|
||||
gsyVideoPlayer: GSYBaseVideoPlayer,
|
||||
frameLayout: FrameLayout
|
||||
) {
|
||||
val lp = gsyVideoPlayer.layoutParams as LayoutParams
|
||||
lp.setMargins(0, 0, 0, 0)
|
||||
lp.height = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
lp.width = ViewGroup.LayoutParams.MATCH_PARENT
|
||||
lp.gravity = Gravity.CENTER
|
||||
gsyVideoPlayer.layoutParams = lp
|
||||
gsyVideoPlayer.isIfCurrentIsFullscreen = true
|
||||
val isVertical = isVerticalFullByVideoSize
|
||||
val isLockLand = isLockLandByAutoFullSize
|
||||
if (isShowFullAnimation) {
|
||||
mInnerHandler.postDelayed({ //autoFull模式下,非横屏视频视频不横屏,并且不自动旋转
|
||||
if (!isVertical && isLockLand && mOrientationUtils != null && mOrientationUtils.isLand != 1) {
|
||||
mOrientationUtils.resolveByClick()
|
||||
}
|
||||
gsyVideoPlayer.visibility = VISIBLE
|
||||
frameLayout.visibility = VISIBLE
|
||||
}, 300)
|
||||
} else {
|
||||
if (!isVertical && isLockLand && mOrientationUtils != null) {
|
||||
mOrientationUtils.resolveByClick()
|
||||
}
|
||||
gsyVideoPlayer.visibility = VISIBLE
|
||||
frameLayout.visibility = VISIBLE
|
||||
}
|
||||
if (mVideoAllCallBack != null) {
|
||||
Debuger.printfError("onEnterFullscreen")
|
||||
mVideoAllCallBack.onEnterFullscreen(mOriginUrl, mTitle, gsyVideoPlayer)
|
||||
}
|
||||
mIfCurrentIsFullscreen = true
|
||||
checkoutState()
|
||||
checkAutoFullWithSizeAndAdaptation(gsyVideoPlayer)
|
||||
}
|
||||
|
||||
fun clearFullscreenLayout(gsyVideoPlayer:GSYVideoPlayer) {
|
||||
mIfCurrentIsFullscreen = false
|
||||
val delay = 0
|
||||
mInnerHandler.postDelayed({ resolveNormalVideoShow(gsyVideoPlayer) }, delay.toLong())
|
||||
}
|
||||
|
||||
private fun resolveNormalVideoShow(gsyVideoPlayer: GSYVideoPlayer) {
|
||||
mCurrentState = gsyVideoManager.lastState
|
||||
cloneParams(gsyVideoPlayer, this)
|
||||
gsyVideoManager.setListener(gsyVideoManager.lastListener())
|
||||
gsyVideoManager.setLastListener(null)
|
||||
setStateAndUi(mCurrentState)
|
||||
addTextureView()
|
||||
mSaveChangeViewTIme = System.currentTimeMillis()
|
||||
if (mVideoAllCallBack != null) {
|
||||
Debuger.printfError("onQuitFullscreen")
|
||||
mVideoAllCallBack.onQuitFullscreen(mOriginUrl, mTitle, this)
|
||||
}
|
||||
mIfCurrentIsFullscreen = false
|
||||
if (mHideKey) {
|
||||
CommonUtil.showNavKey(mContext, mSystemUiVisibility)
|
||||
}
|
||||
CommonUtil.showSupportActionBar(mContext, mActionBar, mStatusBar)
|
||||
if (fullscreenButton != null) {
|
||||
fullscreenButton.setImageResource(enlargeImageRes)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
After Width: | Height: | Size: 901 B |
|
After Width: | Height: | Size: 888 B |
|
After Width: | Height: | Size: 1.5 MiB |
|
After Width: | Height: | Size: 901 B |
|
After Width: | Height: | Size: 888 B |
|
After Width: | Height: | Size: 1.4 MiB |
|
After Width: | Height: | Size: 1.4 MiB |
@@ -17,11 +17,43 @@
|
||||
android:layout_height="match_parent">
|
||||
<ImageView
|
||||
android:id="@+id/thumbImage"
|
||||
android:scaleType="fitXY"
|
||||
android:background="@drawable/taxi_p_video_holder"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_centerInParent="true" />
|
||||
</RelativeLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/layout_top"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="158px"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/fullscreen"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
android:layout_marginTop="60px"
|
||||
android:layout_marginEnd="60px"
|
||||
android:layout_width="66px"
|
||||
android:layout_height="66px"
|
||||
android:src="@drawable/taxi_p_change_full" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toTopOf="@+id/fullscreen"
|
||||
app:layout_constraintBottom_toBottomOf="@+id/fullscreen"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
android:layout_marginStart="50px"
|
||||
android:text="02:23"
|
||||
android:textColor="@android:color/white"
|
||||
android:textSize="46px" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<!--局部播放器-->
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/layout_bottom"
|
||||
|
||||