视频流分享统计

This commit is contained in:
张玉久
2020-03-17 09:53:49 +08:00
parent d98edc8f77
commit bcd846024e
6 changed files with 29 additions and 6 deletions

View File

@ -36,6 +36,8 @@ open class VideoEntity(
@SerializedName("game_active")
val gameActive: Boolean = false,//游戏是否被隐藏 false隐藏
var game: GameEntity? = null,
@SerializedName("share")
var shareCount: Int = 0,//分享数量 v3.7.5新增
var videoIsMuted: Boolean = false//是否静音标记
) : Parcelable {

View File

@ -1922,6 +1922,12 @@ public interface ApiService {
@DELETE("users/{user_id}/favorites/videos/{video_id}")
Single<ResponseBody> undoCollectVideo(@Path("user_id") String userId, @Path("video_id") String videoId);
/**
* 提交分享视频统计
*/
@POST("videos/{video_id}:share")
Single<ResponseBody> shareVideoStatistics(@Path("video_id") String videoId);
/**
* 给一个视频新增评论
*/
@ -2267,7 +2273,7 @@ public interface ApiService {
*/
@POST("halo_addons/unread_count:refresh")
Single<ResponseBody> refreshUnreadCount(@Body RequestBody body);
/**
* 获取用户数据 (暂用于游戏详情的动态页面)
*/

View File

@ -181,6 +181,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
like()
}
shareCountTv.text = videoEntity.shareCount.toString()
likeCountTv.text = videoEntity.vote.toString()
commentCountTv.text = videoEntity.commentCount.toString()
@ -246,7 +247,7 @@ class DetailPlayerView @JvmOverloads constructor(context: Context, attrs: Attrib
shareSummary,
ShareUtils.ShareType.video,object :ShareUtils.ShareCallBack{
override fun onSuccess() {
ToastUtils.showToast("分享成功")
mViewModel?.shareVideoStatistics(mVideoEntity)
}
override fun onCancel() {

View File

@ -640,7 +640,7 @@ class VideoDetailContainerFragment : BaseLazyFragment(), OnBackPressedListener {
shareSummary,
ShareUtils.ShareType.video, object : ShareUtils.ShareCallBack {
override fun onSuccess() {
ToastUtils.showToast("分享成功")
mViewModel.shareVideoStatistics(mViewModel.currentDisplayingVideo)
}
override fun onCancel() {

View File

@ -2,7 +2,6 @@ package com.gh.gamecenter.video.detail
import android.annotation.SuppressLint
import android.app.Application
import android.location.Location
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.MutableLiveData
import com.gh.common.history.HistoryDatabase
@ -308,6 +307,21 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
}
fun shareVideoStatistics(videoEntity: VideoEntity?) {
RetrofitManager.getInstance(getApplication())
.api.shareVideoStatistics(videoEntity!!.id)
.subscribeOn(Schedulers.io())
.subscribe(object : BiResponse<ResponseBody>() {
override fun onSuccess(data: ResponseBody) {
videoEntity.let {
it.shareCount++
}
needToUpdateVideoInfo.postValue(videoEntity)
}
})
}
private fun addGamePositionAndPackage(game: GameEntity?, position: Int) {
if (game == null) return