修复视频流接口相关问题

This commit is contained in:
张玉久
2020-01-10 22:30:13 +08:00
parent 5318693650
commit f53c8377e6
4 changed files with 34 additions and 5 deletions

View File

@ -49,7 +49,11 @@ class VideoAdapter(context: Context,
ImageUtils.display(holder.binding.videoCover, entity.poster)
holder.binding.videoLikeCount.text = entity.vote.toSimpleCount()
holder.itemView.setOnClickListener {
DirectUtils.directToVideoDetail(mContext, entity.id, VideoDetailContainerViewModel.Location.USER_FAVORITE_VIDEO.value, false, path = getPath())
if (mVideoStyle == VideoFragment.VideoStyle.COLLECT.value) {
DirectUtils.directToVideoDetail(mContext, entity.id, VideoDetailContainerViewModel.Location.USER_FAVORITE_VIDEO.value, false, path = getPath())
} else {
DirectUtils.directToVideoDetail(mContext, entity.id, VideoDetailContainerViewModel.Location.SINGLE_VIDEO.value, false, path = getPath())
}
}
} else if (holder is FooterViewHolder) {
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)

View File

@ -1,5 +1,6 @@
package com.gh.gamecenter.gamedetail
import android.annotation.SuppressLint
import android.app.Application
import android.os.Build
import androidx.lifecycle.AndroidViewModel
@ -12,7 +13,9 @@ import com.gh.common.util.ConcernUtils
import com.gh.common.util.DataUtils
import com.gh.gamecenter.entity.GameDetailEntity
import com.gh.gamecenter.entity.GameEntity
import com.gh.gamecenter.entity.GameVideoInfo
import com.gh.gamecenter.mvvm.Resource
import com.gh.gamecenter.retrofit.BiResponse
import com.gh.gamecenter.retrofit.Response
import com.gh.gamecenter.retrofit.RetrofitManager
import io.reactivex.android.schedulers.AndroidSchedulers
@ -93,7 +96,8 @@ class GameDetailViewModel(application: Application,
displayTopVideo = response.topVideo != null
&& Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
gameDetailLiveData.postValue(Resource.success(response))
getGameVideoInfo(response)
// gameDetailLiveData.postValue(Resource.success(response))
}
override fun onFailure(e: HttpException?) {
@ -102,6 +106,25 @@ class GameDetailViewModel(application: Application,
})
}
@SuppressLint("CheckResult")
private fun getGameVideoInfo(response: GameDetailEntity) {
mApi.getGameVideoInfo(game?.id)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : BiResponse<GameVideoInfo>() {
override fun onSuccess(data: GameVideoInfo) {
response.introVideo?.videoCount = data.videoCount
gameDetailLiveData.postValue(Resource.success(response))
}
override fun onFailure(exception: Exception) {
gameDetailLiveData.postValue(Resource.success(response))
}
})
}
fun concernCommand(isConcern: Boolean) {
val listener = object : ConcernUtils.onConcernListener {
override fun onSuccess() {

View File

@ -20,7 +20,8 @@ import com.gh.gamecenter.video.detail.VideoDetailContainerViewModel
class GameVideoAdapter(context: Context,
private val mViewModel: NormalListViewModel<MyVideoEntity>,
private val mEntrance: String,
private val mSortValue: String?) : ListAdapter<MyVideoEntity>(context) {
private val mSortValue: String?,
val gameId:String) : ListAdapter<MyVideoEntity>(context) {
override fun getItemViewType(position: Int): Int {
if (position == itemCount - 1) return ItemViewType.ITEM_FOOTER
@ -62,7 +63,7 @@ class GameVideoAdapter(context: Context,
fromLocation = VideoDetailContainerViewModel.Location.NEWEST_GAME_VIDEO.value
path = "视频合集-最新"
}
DirectUtils.directToVideoDetail(mContext, entity.id, fromLocation, false, gameId = entity.gameId, entrance = mEntrance, path = path)
DirectUtils.directToVideoDetail(mContext, entity.id, fromLocation, false, gameId = gameId, entrance = mEntrance, path = path)
}
} else if (holder is FooterViewHolder) {
holder.initFooterViewHolder(mViewModel, mIsLoading, mIsNetworkError, mIsOver)

View File

@ -24,7 +24,8 @@ class GameVideoFragment : ListFragment<MyVideoEntity, NormalListViewModel<MyVide
mAdapter = GameVideoAdapter(context!!,
mListViewModel,
mEntrance,
arguments?.getString(EntranceUtils.KEY_SORT))
arguments?.getString(EntranceUtils.KEY_SORT),
arguments?.getString(EntranceUtils.KEY_GAMEID)?:"")
}
return mAdapter!!
}