光环助手V3.7.0 DEV(20190927-1830)视频详情(测试汇总)(5、8、9、10-15)https://gitlab.ghzs.com/pm/halo-app-issues/issues/659

This commit is contained in:
张玉久
2019-10-11 16:31:09 +08:00
parent 9674515171
commit 23906131ec
7 changed files with 122 additions and 43 deletions

View File

@ -23,7 +23,7 @@ open class VideoEntity(
@SerializedName("vote_recently")
val voteRecently: Int = 0,
@SerializedName("comment_count")
val commentCount: Int = 0,
var commentCount: Int = 0,
val user: UserEntity = UserEntity(),
val me: MeEntity = MeEntity(),
val size: Long = 0,

View File

@ -62,23 +62,38 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
likeIv.setImageDrawable(ContextCompat.getDrawable(context, R.drawable.ic_video_detail_like))
likeIv.setOnClickListener {
CheckLoginUtils.checkLogin(context, "(游戏详情)") {
mViewModel?.voteVideo(mVideoEntity)
when (videoEntity.status) {
"pass" -> {
mViewModel?.voteVideo(mVideoEntity)
}
"pending" ,"fail"-> {
Utils.toast(context, "该作品正在审核中,暂时无法点赞哦")
}
}
}
}
}
shareContainer.setOnClickListener {
val shareIcon = videoEntity.getThumb()
when (videoEntity.status) {
"pass" -> {
val shareIcon = videoEntity.getThumb()
val shareSummary = "@" + videoEntity.user.name + "在光环助手发布了游戏小视频,快点开看看吧"
val shareSummary = "@" + videoEntity.user.name + "在光环助手发布了游戏小视频,快点开看看吧"
ShareUtils.getInstance(context).showShareWindows(context as Activity,
(context as Activity).window.decorView,
"https://resource.ghzs.com/page/video_play/video/video.html?video=${videoEntity.id}",
shareIcon,
videoEntity.title,
shareSummary,
ShareUtils.ShareType.video)
ShareUtils.getInstance(context).showShareWindows(context as Activity,
(context as Activity).window.decorView,
"https://resource.ghzs.com/page/video_play/video/video.html?video=${videoEntity.id}",
shareIcon,
videoEntity.title,
shareSummary,
ShareUtils.ShareType.video)
}
"pending" ,"fail"-> {
Utils.toast(context, "该作品正在审核中,暂时无法分享哦")
}
}
}
likeCountTv.text = videoEntity.vote.toString()
@ -98,9 +113,15 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
}
commentContainer.setOnClickListener {
// TODO 草稿和数量变更
val intent = CommentActivity.getVideoCommentIntent(context, videoEntity.id, videoEntity.commentCount, "", false)
(context as Activity).startActivityForResult(intent, CommentActivity.REQUEST_CODE)
when (videoEntity.status) {
"pass" -> {
val intent = CommentActivity.getVideoCommentIntent(context, videoEntity.id, videoEntity.commentCount, "", false)
(context as Activity).startActivityForResult(intent, CommentActivity.REQUEST_CODE)
}
"pending" ,"fail"-> {
Utils.toast(context, "该作品正在审核中,暂时无法评论哦")
}
}
}
censoringContainer.setOnClickListener { DirectUtils.directToWebView(context, "https://resource.ghzs.com/page/video_rule/video_rule.html", mEntrance) }
@ -137,9 +158,11 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
"暂时不了",
{
HaloApp.put(Constants.SHOULD_SHOW_VIDEO_MOBILE_WARNING, false)
startButton.performClick()
startPlayLogic()
},
null)
{
(context as Activity).finish()
})
}
fun updateThumb(url: String) {
@ -215,8 +238,6 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
override fun changeUiToError() {
super.changeUiToError()
Utils.toast(context, "网络错误,视频播放失败")
setViewShowState(mStartButton, View.INVISIBLE)
errorContainer.visibility = View.VISIBLE
}
@ -229,6 +250,14 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
errorContainer.visibility = View.VISIBLE
}
//监控播放错误
override fun onError(what: Int, extra: Int) {
super.onError(what, extra)
Utils.toast(context, "网络错误,视频播放失败")
setViewShowState(mStartButton, View.INVISIBLE)
errorContainer.visibility = View.VISIBLE
}
override fun updateStartImage() {
// no need to change
}

View File

@ -8,8 +8,8 @@ import com.gh.gamecenter.entity.VideoEntity
import com.halo.assistant.HaloApp
import com.shuyu.gsyvideoplayer.builder.GSYVideoOptionBuilder
class VideoAdapter(val mContext:Context,val mViewModel: VideoDetailContainerViewModel) :RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var videoList= arrayListOf<VideoEntity>()
class VideoAdapter(val mContext: Context, val mViewModel: VideoDetailContainerViewModel) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
var videoList = arrayListOf<VideoEntity>()
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val params = RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.MATCH_PARENT)
@ -19,7 +19,7 @@ class VideoAdapter(val mContext:Context,val mViewModel: VideoDetailContainerView
return object : RecyclerView.ViewHolder(view) {}
}
override fun getItemCount(): Int =videoList.size
override fun getItemCount(): Int = videoList.size
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
val videoView = (holder.itemView as DetailPlayerView)
@ -41,8 +41,9 @@ class VideoAdapter(val mContext:Context,val mViewModel: VideoDetailContainerView
videoView.isNeedShowWifiTip = HaloApp.get(Constants.SHOULD_SHOW_VIDEO_MOBILE_WARNING, false) as Boolean?
?: false
//if (videoView.currentState == GSYVideoView.CURRENT_STATE_PAUSE || !videoView.isInPlayingState) {
videoView.startPlayLogic()
//}
if (position == mViewModel.startPosition) {
videoView.startButton.performClick()
}
}
}

View File

@ -27,12 +27,13 @@ class VideoDetailActivity : BaseActivity() {
supportFragmentManager.beginTransaction().replace(R.id.placeholder, containerFragment).commitNowAllowingStateLoss()
}
override fun onStop() {
override fun onPause() {
GSYVideoManager.onPause()
super.onStop()
super.onPause()
}
override fun onResume() {
// GSYVideoManager.onResume()
super.onResume()
}

View File

@ -1,6 +1,8 @@
package com.gh.gamecenter.video.detail
import android.app.Activity
import android.app.Dialog
import android.content.Intent
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.view.Gravity
@ -15,6 +17,9 @@ import com.gh.gamecenter.R
import com.gh.gamecenter.entity.VideoEntity
import com.gh.gamecenter.manager.UserManager
import com.gh.gamecenter.normal.NormalFragment
import com.gh.gamecenter.qa.comment.CommentActivity
import com.scwang.smartrefresh.layout.footer.ClassicsFooter
import com.shuyu.gsyvideoplayer.video.base.GSYVideoView
import kotlinx.android.synthetic.main.fragment_video_detail_container1.*
import kotlinx.android.synthetic.main.reuse_no_connection.*
@ -42,6 +47,7 @@ class VideoDetailContainerFragment1 : NormalFragment() {
mViewModel = viewModelProviderFromParent()
mViewModel.getVideoDetailList(mInitialVideoId, mLocation, isLoadNext = true)
mViewModel.showComment = arguments?.getBoolean(EntranceUtils.KEY_SHOW_COMMENT) ?: false
ClassicsFooter.REFRESH_FOOTER_NOTHING = "没有内容了"
}
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -60,6 +66,7 @@ class VideoDetailContainerFragment1 : NormalFragment() {
}
}
}
smartRefreshLayout.setNoMoreData(true)
mViewModel.videoList.observeNonNull(this) {
hideNetworkErrorView()
@ -102,12 +109,14 @@ class VideoDetailContainerFragment1 : NormalFragment() {
}
override fun onPageSelected(position: Int, isBottom: Boolean) {
val pos = mViewPagerLayoutManager.findFirstCompletelyVisibleItemPosition()
val holder = recyclerview.findViewHolderForAdapterPosition(pos)
if (holder?.itemView != null) {
val videoView = (holder.itemView as DetailPlayerView)
smartRefreshLayout.isEnableLoadMore = isBottom
smartRefreshLayout.setNoMoreData(isBottom)
videoView.startPlayLogic()
val pos = mViewPagerLayoutManager.findFirstCompletelyVisibleItemPosition()
val videoView = findFirstCompletelyVisibleVideoViewByPosition()
if (videoView?.isInPlayingState != true) {
videoView?.startPlayLogic()
}
mViewModel.videoList.value?.apply {
@ -134,16 +143,27 @@ class VideoDetailContainerFragment1 : NormalFragment() {
}
mViewModel.needToUpdateVideoInfo.observeNonNull(this) {
val pos = mViewPagerLayoutManager.findFirstCompletelyVisibleItemPosition()
val holder = recyclerview.findViewHolderForAdapterPosition(pos)
if (holder?.itemView != null) {
val videoView = (holder.itemView as DetailPlayerView)
videoView.updateViewDetail(it)
}
findFirstCompletelyVisibleVideoViewByPosition()?.updateViewDetail(it)
}
}
override fun onResume() {
super.onResume()
val videoView = findFirstCompletelyVisibleVideoViewByPosition()
if (videoView?.currentState == GSYVideoView.CURRENT_STATE_PAUSE || videoView?.isInPlayingState != true) {
val seekOnStart = videoView?.currentPositionWhenPlaying
videoView?.seekOnStart = seekOnStart?.toLong() ?: 0
videoView?.startPlayLogic()
}
}
private fun findFirstCompletelyVisibleVideoViewByPosition(): DetailPlayerView? {
val pos = mViewPagerLayoutManager.findFirstCompletelyVisibleItemPosition()
val holder = recyclerview.findViewHolderForAdapterPosition(pos)
return holder?.itemView as? DetailPlayerView
}
private fun showNetworkErrorView() {
errorContainer.visibility = View.VISIBLE
reuse_no_connection.visibility = View.VISIBLE
@ -220,4 +240,18 @@ class VideoDetailContainerFragment1 : NormalFragment() {
ShareUtils.ShareType.video)
}
}
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (resultCode == Activity.RESULT_OK && data != null) {
if (requestCode == CommentActivity.REQUEST_CODE) {
val commentCount = data.getIntExtra(CommentActivity.COMMENT_COUNT, -1)
if (commentCount > 0) {
val videoEntity = mAdapter.videoList[mViewModel.startPosition]
videoEntity.commentCount = commentCount
findFirstCompletelyVisibleVideoViewByPosition()?.updateViewDetail(videoEntity)
}
}
}
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/black">
@ -8,11 +9,24 @@
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />-->
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
<com.scwang.smartrefresh.layout.SmartRefreshLayout
android:id="@+id/smartRefreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent" />
android:layout_height="match_parent"
app:srlEnableRefresh="false"
app:srlEnableLoadMore="true">
<com.scwang.smartrefresh.layout.header.ClassicsHeader
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<com.scwang.smartrefresh.layout.footer.ClassicsFooter
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:srlTextSizeTitle="12sp"/>
</com.scwang.smartrefresh.layout.SmartRefreshLayout>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">