diff --git a/app/src/main/java/com/gh/gamecenter/entity/LinkEntity.kt b/app/src/main/java/com/gh/gamecenter/entity/LinkEntity.kt index 89a967edcf..a1b5f3a207 100644 --- a/app/src/main/java/com/gh/gamecenter/entity/LinkEntity.kt +++ b/app/src/main/java/com/gh/gamecenter/entity/LinkEntity.kt @@ -13,9 +13,9 @@ open class LinkEntity( var type: String? = "", var text: String? = "", var value: String? = "", - @SerializedName("community_id",alternate = ["community"]) + @SerializedName("community_id") var communityId: String? = "", - @SerializedName("link_community") + @SerializedName("link_community",alternate = ["community"]) var community: CommunityEntity? = CommunityEntity(), var display: Display? = null // 板块 ) : Parcelable \ No newline at end of file diff --git a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java index 5f900338d6..5138854911 100644 --- a/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java +++ b/app/src/main/java/com/gh/gamecenter/personal/PersonalFragment.java @@ -258,7 +258,10 @@ public class PersonalFragment extends BaseFragment implements Observer { - (context as? VideoDetailActivity)?.isPauseVideo = false + if (mViewModel != null) { + VideoDetailContainerFragment.pauseVideo[mViewModel!!.uuid] = false + } val intent = CommentActivity.getVideoCommentIntent(context, videoEntity.id, videoEntity.commentCount, "", false) (context as Activity).startActivityForResult(intent, CommentActivity.REQUEST_CODE) } @@ -374,24 +376,24 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib override fun onClickUiToggle() { byStartedClick = true //处理小于30s视频点击空白不能隐藏控件 - if (mCurrentState == GSYVideoView.CURRENT_STATE_PLAYING) { - if (mStartButton != null) { - if (mStartButton.visibility == View.VISIBLE) { - changeUiToPlayingClear() - } else { - changeUiToPlayingShow() - } - } - } else if (mCurrentState == GSYVideoView.CURRENT_STATE_PAUSE) - if (mStartButton != null) { - if (mStartButton.visibility == View.VISIBLE) { - changeUiToPauseClear() - } else { - changeUiToPauseShow() - } - } else { - super.onClickUiToggle() - } + /* if (mCurrentState == GSYVideoView.CURRENT_STATE_PLAYING) { + if (mStartButton != null) { + if (mStartButton.visibility == View.VISIBLE) { + changeUiToPlayingClear() + } else { + changeUiToPlayingShow() + } + } + } else if (mCurrentState == GSYVideoView.CURRENT_STATE_PAUSE) + if (mStartButton != null) { + if (mStartButton.visibility == View.VISIBLE) { + changeUiToPauseClear() + } else { + changeUiToPauseShow() + } + } else { + super.onClickUiToggle() + }*/ } override fun onStartTrackingTouch(seekBar: SeekBar) { @@ -416,6 +418,10 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib } } uploadVideoStreamingPlaying("结束拖动", (currentPositionWhenPlaying / 1000).toString()) + //拖动进度条松开手指后,直接从当前具体的秒数开始播放 + if (mCurrentState == GSYVideoView.CURRENT_STATE_PAUSE) { + onVideoResume() + } } override fun getEnlargeImageRes(): Int { @@ -517,6 +523,9 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib override fun onClick(v: View) { when (v.id) { + R.id.surface_container -> { + mStartButton.performClick() + } R.id.start -> { if (currentState != GSYVideoView.CURRENT_STATE_PLAYING) { MtaHelper.onEvent("视频详情", "播放", mCombinedTitleAndId) @@ -621,5 +630,13 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib gameName.getLocationInWindow(location) return location[1] } + + fun getCurrentPosition(): Long { + return mCurrentPosition + } + + fun setCurrentPosition(mCurrentPosition: Long) { + this.mCurrentPosition = mCurrentPosition + } } diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt b/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt index 684e5bc8c8..28f0348c6a 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/VideoAdapter.kt @@ -32,6 +32,7 @@ import com.lightgame.download.DownloadStatus import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder import com.shuyu.gsyvideoplayer.listener.GSYSampleCallBack import com.shuyu.gsyvideoplayer.utils.OrientationUtils +import com.shuyu.gsyvideoplayer.video.base.GSYVideoView import kotlinx.android.synthetic.main.layout_video_detail_surface.view.* import java.util.* @@ -97,6 +98,11 @@ class VideoAdapter(val mContext: Context, val mRecyclerView: RecyclerView, val m fullVideoPlayer.hideAllButton(true) fullVideoPlayer.updateViewDetail(videoList[position]) fullVideoPlayer.updateMuteStatus() + //金进入全屏后直接播放 + if (fullVideoPlayer.currentState == GSYVideoView.CURRENT_STATE_PAUSE) { + fullVideoPlayer.setCurrentPosition(videoView.getCurrentPosition()) + fullVideoPlayer.onVideoResume() + } } videoView.isNeedShowWifiTip = HaloApp.get(Constants.SHOULD_SHOW_VIDEO_MOBILE_WARNING, false) as Boolean? @@ -126,7 +132,7 @@ class VideoAdapter(val mContext: Context, val mRecyclerView: RecyclerView, val m DownloadItemUtils.setOnClickListener(mContext, this, game, 0, this@VideoAdapter, - mViewModel.path, BaseActivity.mergeEntranceAndPath(mViewModel.path, "视频详情"), exposureEvent,object :EmptyCallback{ + mViewModel.path, BaseActivity.mergeEntranceAndPath(mViewModel.path, "视频详情"), exposureEvent, object : EmptyCallback { override fun onCallback() { when (download_btn.text) { "下载" -> MtaHelper.onEvent("视频详情", "下载游戏", "${videoList[position].title}(${videoList[position].id})") @@ -201,6 +207,7 @@ class VideoAdapter(val mContext: Context, val mRecyclerView: RecyclerView, val m } } } + private fun setDownloadBtnStatus(context: Context, gameEntity: GameEntity, downloadBtn: TextView, pluginLocation: PluginLocation) { val status = GameUtils.getDownloadBtnText(context, gameEntity, pluginLocation) downloadBtn.setTextColor(Color.WHITE) diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailActivity.kt b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailActivity.kt index d2dc14c34f..4b92162650 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailActivity.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailActivity.kt @@ -12,7 +12,7 @@ import java.util.* // 由于兼容性问题,本游戏详情页不应该被低于 Android 4.4 的设备打开 class VideoDetailActivity : BaseActivity() { var uuid = UUID.randomUUID() - var isPauseVideo = true//跳转页面时是否需要暂停视频 +// var isPauseVideo = true//跳转页面时是否需要暂停视频 var mLastTime = 0L var mIsDown = false private val mIntervalTime = 500 @@ -50,21 +50,21 @@ class VideoDetailActivity : BaseActivity() { return super.dispatchTouchEvent(ev) } - override fun onPause() { + /*override fun onPause() { if (isPauseVideo) { CustomManager.onPause("detail_$uuid") } super.onPause() - } + }*/ - override fun onResume() { + /*override fun onResume() { if (isPauseVideo) { CustomManager.onResume("detail_$uuid") } else { isPauseVideo = true } super.onResume() - } + }*/ override fun onDestroy() { CustomManager.releaseAllVideos("detail_$uuid") diff --git a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt index 0d971c3e41..f24443b449 100644 --- a/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt +++ b/app/src/main/java/com/gh/gamecenter/video/detail/VideoDetailContainerFragment.kt @@ -58,6 +58,10 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { private var mExposureListener: ExposureListener? = null + companion object { + var pauseVideo = HashMap()//跳转页面时是否需要暂停视频 + } + private val dataWatcher = object : DataWatcher() { override fun onDataChanged(downloadEntity: DownloadEntity) { if (::mAdapter.isInitialized) { @@ -87,6 +91,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { mViewModel.showComment = arguments?.getBoolean(EntranceUtils.KEY_SHOW_COMMENT) ?: false mViewModel.location = mLocation mViewModel.isHomeVideo = mIsHomeVideo + pauseVideo[mViewModel.uuid] = true mViewModel.getVideoDetailList(mInitialVideoId, mLocation, isLoadNext = true) ClassicsFooter.REFRESH_FOOTER_NOTHING = "没有内容了" @@ -391,14 +396,20 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { override fun onFragmentResume() { findFirstCompletelyVisibleVideoViewByPosition()?.uploadVideoStreamingPlaying("恢复页面") DownloadManager.getInstance(requireContext()).addObserver(dataWatcher) - CustomManager.onResume("detail_${mViewModel.uuid}") + if (pauseVideo[mViewModel.uuid] == true) { + CustomManager.onResume("detail_${mViewModel.uuid}") + } else { + pauseVideo[mViewModel.uuid] = true + } super.onFragmentResume() } override fun onFragmentPause() { DownloadManager.getInstance(requireContext()).removeObserver(dataWatcher) findFirstCompletelyVisibleVideoViewByPosition()?.uploadVideoStreamingPlaying("暂停页面") - CustomManager.onPause("detail_${mViewModel.uuid}") + if (pauseVideo[mViewModel.uuid] == true) { + CustomManager.onPause("detail_${mViewModel.uuid}") + } super.onFragmentPause() } @@ -409,6 +420,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener { if (mAdCountDownTimer != null && !mAdCountDownTimer!!.isDisposed) { mAdCountDownTimer?.dispose() } + pauseVideo.remove(mViewModel.uuid) super.onDestroyView() } diff --git a/app/src/main/res/drawable-xxhdpi/video_detail_loading.png b/app/src/main/res/drawable-xxhdpi/video_detail_loading.png new file mode 100644 index 0000000000..b4305d16ec Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/video_detail_loading.png differ diff --git a/app/src/main/res/drawable/progressbar_video_detail_circle.xml b/app/src/main/res/drawable/progressbar_video_detail_circle.xml index 06314d972d..fd7f7f0224 100644 --- a/app/src/main/res/drawable/progressbar_video_detail_circle.xml +++ b/app/src/main/res/drawable/progressbar_video_detail_circle.xml @@ -1,4 +1,4 @@ - + + \ No newline at end of file diff --git a/app/src/main/res/layout/layout_video_detail_surface.xml b/app/src/main/res/layout/layout_video_detail_surface.xml index 65233b1bcd..45eb020e7f 100644 --- a/app/src/main/res/layout/layout_video_detail_surface.xml +++ b/app/src/main/res/layout/layout_video_detail_surface.xml @@ -256,8 +256,8 @@ android:id="@+id/likeContainer" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_toLeftOf="@+id/commentContainer" android:gravity="center" + android:layout_alignParentRight="true" android:orientation="vertical">