【光环助手V5.10.0】视频模板活动问题汇总(4) https://git.shanqu.cc/pm/halo-app-issues/-/issues/1852
This commit is contained in:
@ -2014,6 +2014,15 @@ public interface ApiService {
|
||||
@GET("activities/videos/{video_id}/stream")
|
||||
Single<ArrayList<VideoEntity>> getActivitiesVideoStream(@Path("video_id") String videoId, @Query("type") String type, @Query("act") String act, @Query("filter") String filter);
|
||||
|
||||
/**
|
||||
* 获取活动的视频流(可滑动)
|
||||
*
|
||||
* @param type hot最热,new最新,award获奖(只返回获奖视频)
|
||||
* @param act 活动名称
|
||||
*/
|
||||
@GET("videos/{video_id}/scroll")
|
||||
Single<ArrayList<VideoEntity>> getActivitiesVideoStreamScroll(@Path("video_id") String videoId, @Query("type") String type, @Query("act_id") String actId, @Query("filter") String filter);
|
||||
|
||||
/**
|
||||
* 点赞视频
|
||||
*/
|
||||
|
||||
@ -132,82 +132,87 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
}
|
||||
|
||||
private fun getNormalVideoStream(videoId: String, location: String, isLoadNext: Boolean) {
|
||||
val videoListSingle = if (location == Location.GAME_ZONE.value) {
|
||||
RetrofitManager.getInstance()
|
||||
val videoListSingle = when (location) {
|
||||
Location.GAME_ZONE.value -> {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getVideoDetailList(videoId, getFilter(location, isLoadNext), fieldId, sectionName)
|
||||
} else if (location == Location.VIDEO_ACTIVITY.value) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getActivitiesVideoStream(videoId, type, act, getFilter(location, isLoadNext))
|
||||
} else {
|
||||
RetrofitManager.getInstance()
|
||||
}
|
||||
Location.VIDEO_ACTIVITY.value -> {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getActivitiesVideoStreamScroll(videoId, type, act, getFilter(location, isLoadNext))
|
||||
}
|
||||
else -> {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getVideoDetailList(videoId, getFilter(location, isLoadNext))
|
||||
}
|
||||
}
|
||||
|
||||
videoListSingle.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
startPosition = data.indexOfFirst { video -> videoId == video.id }
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
val index = data.indexOfFirst { video -> videoId == video.id }
|
||||
startPosition = if (index >= 0) index else 0
|
||||
}
|
||||
|
||||
if (mIsFirstLoad || !(data.size == 1 && data[0].id == videoId)) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
}
|
||||
if (mIsFirstLoad || !(data.size == 1 && data[0].id == videoId)) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
}
|
||||
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取最新排序的视频流
|
||||
private fun getNewestVideoStream(isLoadNext: Boolean) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getVideoStream(page)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
}
|
||||
page++
|
||||
//下拉刷新清除列表数据
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
.api.getVideoStream(page)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
}
|
||||
page++
|
||||
//下拉刷新清除列表数据
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
}
|
||||
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取关注用户的视频流
|
||||
@ -220,49 +225,49 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
if (page == 1) {
|
||||
deleteAttentionCacheVideo()
|
||||
RetrofitManager.getInstance()
|
||||
.api.getAttentionVideoStreamRefresh(UserManager.getInstance().userId, body, page)
|
||||
.api.getAttentionVideoStreamRefresh(UserManager.getInstance().userId, body, page)
|
||||
} else {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getAttentionVideoStream(UserManager.getInstance().userId, body, page)
|
||||
.api.getAttentionVideoStream(UserManager.getInstance().userId, body, page)
|
||||
}
|
||||
}
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<retrofit2.Response<java.util.ArrayList<VideoEntity>>>() {
|
||||
override fun onSuccess(data: retrofit2.Response<java.util.ArrayList<VideoEntity>>) {
|
||||
val headers = data.headers()
|
||||
total = headers.get("total")?.toInt() ?: 0
|
||||
.compose(singleToMain())
|
||||
.subscribe(object : BiResponse<retrofit2.Response<java.util.ArrayList<VideoEntity>>>() {
|
||||
override fun onSuccess(data: retrofit2.Response<java.util.ArrayList<VideoEntity>>) {
|
||||
val headers = data.headers()
|
||||
total = headers.get("total")?.toInt() ?: 0
|
||||
|
||||
val videoEntities = data.body() ?: arrayListOf()
|
||||
val videoEntities = data.body() ?: arrayListOf()
|
||||
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (videoEntities.isEmpty()) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
}
|
||||
page++
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(videoEntities, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(videoEntities, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (videoEntities.isEmpty()) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
}
|
||||
page++
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(videoEntities, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(videoEntities, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
}
|
||||
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun getVideoStream(type: String, videoId: String, isLoadNext: Boolean) {
|
||||
@ -276,80 +281,80 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
}
|
||||
if (type == Location.GAME_DETAIL.value) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getGameDetailVideoStream(type, body, videoId, gameId, page)
|
||||
.api.getGameDetailVideoStream(type, body, videoId, gameId, page)
|
||||
} else {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getVideoStream(type, body, videoId, cacheId, page)
|
||||
.api.getVideoStream(type, body, videoId, cacheId, page)
|
||||
}
|
||||
}.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
startPosition = 0
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
page++
|
||||
//总播放算法-当获取的数据总数少于page_size时,重新将page设为1再重新循环
|
||||
if (type == Location.VIDEO_CHOICENESS.value && data.size < 20) {
|
||||
page = 1
|
||||
}
|
||||
if (mIsFirstLoad || !(data.size == 1 && data[0].id == videoId)) {
|
||||
//下拉刷新清除列表数据
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
}
|
||||
startPosition = 0
|
||||
}
|
||||
page++
|
||||
//总播放算法-当获取的数据总数少于page_size时,重新将page设为1再重新循环
|
||||
if (type == Location.VIDEO_CHOICENESS.value && data.size < 20) {
|
||||
page = 1
|
||||
}
|
||||
if (mIsFirstLoad || !(data.size == 1 && data[0].id == videoId)) {
|
||||
//下拉刷新清除列表数据
|
||||
if (isLoadNext) {
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else if (!isLoadNext && mRecyclerViewRef?.get()?.computeVerticalScrollOffset() == 0) {
|
||||
//下拉刷新并且列表没有滚动清除列表数据,数据发生变化
|
||||
videoList.value?.clear()
|
||||
mergeVideoList(data, isLoadNext)
|
||||
} else {
|
||||
//下拉刷新并且列表滚动中关闭下拉刷新动画,数据不变
|
||||
refreshFinish.postValue(true)
|
||||
}
|
||||
}
|
||||
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取活动的视频流
|
||||
private fun getActivityVideoStream(videoId: String, isLoadNext: Boolean) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.getActivitiesVideoStream(videoId, page, type, act)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
.api.getActivitiesVideoStream(videoId, page, type, act)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ArrayList<VideoEntity>>() {
|
||||
override fun onSuccess(data: ArrayList<VideoEntity>) {
|
||||
if (mIsFirstLoad) {
|
||||
// 无数据时直接显示无数据页面
|
||||
if (data.size == 0) {
|
||||
noDataError.postValue(true)
|
||||
return
|
||||
}
|
||||
page++
|
||||
mergeVideoList(data, isLoadNext)
|
||||
}
|
||||
page++
|
||||
mergeVideoList(data, isLoadNext)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
if (mIsFirstLoad) {
|
||||
networkError.postValue(true)
|
||||
mIsFirstLoad = false
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
//获取视频缓存ids
|
||||
@ -358,14 +363,14 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
Single.create { emitter -> emitter.onSuccess(cacheVideoIds!!) }
|
||||
} else {
|
||||
HistoryDatabase.instance.videoHistoryDao()
|
||||
.getVideoStreamRecord(100, 0)
|
||||
.getVideoStreamRecord(100, 0)
|
||||
}
|
||||
}
|
||||
|
||||
//获取关注视频缓存ids
|
||||
private fun getAttentionCacheVideoIds(): Single<MutableList<String>> {
|
||||
return HistoryDatabase.instance.videoHistoryDao()
|
||||
.getAttentionVideoRecord()
|
||||
.getAttentionVideoRecord()
|
||||
}
|
||||
|
||||
private fun deleteAttentionCacheVideo() {
|
||||
@ -428,80 +433,80 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
|
||||
fun voteVideo(videoDetail: VideoEntity?) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.voteVideo(videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
//Utils.toast(getApplication(), "已点赞")
|
||||
EnergyTaskHelper.postEnergyTask("vote_video", videoDetail.id)
|
||||
}
|
||||
.api.voteVideo(videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
//Utils.toast(getApplication(), "已点赞")
|
||||
EnergyTaskHelper.postEnergyTask("vote_video", videoDetail.id)
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
videoDetail.let {
|
||||
it.vote--
|
||||
it.me.isVoted = false
|
||||
}
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
videoDetail.let {
|
||||
it.vote--
|
||||
it.me.isVoted = false
|
||||
}
|
||||
})
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun undoVoteVideo(videoDetail: VideoEntity?) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.undoVoteVideo(videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
Utils.toast(getApplication(), "取消点赞")
|
||||
}
|
||||
.api.undoVoteVideo(videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
Utils.toast(getApplication(), "取消点赞")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
videoDetail.let {
|
||||
it.vote++
|
||||
it.me.isVoted = true
|
||||
}
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
videoDetail.let {
|
||||
it.vote++
|
||||
it.me.isVoted = true
|
||||
}
|
||||
})
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun collectVideo(videoDetail: VideoEntity?) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.collectVideo(UserManager.getInstance().userId, videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
videoDetail.me.isVideoFavorite = true
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
Utils.toast(getApplication(), "收藏成功")
|
||||
}
|
||||
.api.collectVideo(UserManager.getInstance().userId, videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
videoDetail.me.isVideoFavorite = true
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
Utils.toast(getApplication(), "收藏成功")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
Utils.toast(getApplication(), exception.localizedMessage)
|
||||
}
|
||||
})
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
Utils.toast(getApplication(), exception.localizedMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
private fun undoCollectVideo(videoDetail: VideoEntity?) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.undoCollectVideo(UserManager.getInstance().userId, videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
videoDetail.me.isVideoFavorite = false
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
Utils.toast(getApplication(), "取消收藏")
|
||||
}
|
||||
.api.undoCollectVideo(UserManager.getInstance().userId, videoDetail!!.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<ResponseBody>() {
|
||||
override fun onSuccess(data: ResponseBody) {
|
||||
videoDetail.me.isVideoFavorite = false
|
||||
needToUpdateVideoInfo.postValue(videoDetail)
|
||||
Utils.toast(getApplication(), "取消收藏")
|
||||
}
|
||||
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
Utils.toast(getApplication(), exception.localizedMessage)
|
||||
}
|
||||
})
|
||||
override fun onFailure(exception: Exception) {
|
||||
super.onFailure(exception)
|
||||
Utils.toast(getApplication(), exception.localizedMessage)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun addHistoryRecord(videoEntity: VideoEntity) {
|
||||
@ -513,8 +518,10 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
length = videoEntity.length
|
||||
time = System.currentTimeMillis()
|
||||
title = videoEntity.title
|
||||
user = User(videoEntity.user.id ?: "", videoEntity.user.name
|
||||
?: "", videoEntity.user.icon ?: "")
|
||||
user = User(
|
||||
videoEntity.user.id ?: "", videoEntity.user.name
|
||||
?: "", videoEntity.user.icon ?: ""
|
||||
)
|
||||
commentCount = videoEntity.commentCount
|
||||
videoStreamRecord = when (location) {
|
||||
Location.VIDEO_CHOICENESS.value, Location.VIDEO_HOT.value -> {
|
||||
@ -536,35 +543,35 @@ class VideoDetailContainerViewModel(application: Application) : AndroidViewModel
|
||||
if (videoEntity == null) return
|
||||
|
||||
RetrofitManager.getInstance()
|
||||
.api.shareVideoStatistics(videoEntity.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<JsonObject>() {
|
||||
override fun onSuccess(data: JsonObject) {
|
||||
val msg = data.get("msg").asString
|
||||
if ("success" == msg) {
|
||||
videoEntity.let {
|
||||
it.shareCount++
|
||||
}
|
||||
needToUpdateVideoInfo.postValue(videoEntity)
|
||||
.api.shareVideoStatistics(videoEntity.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : BiResponse<JsonObject>() {
|
||||
override fun onSuccess(data: JsonObject) {
|
||||
val msg = data.get("msg").asString
|
||||
if ("success" == msg) {
|
||||
videoEntity.let {
|
||||
it.shareCount++
|
||||
}
|
||||
needToUpdateVideoInfo.postValue(videoEntity)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
fun follow(videoEntity: VideoEntity?) {
|
||||
RetrofitManager.getInstance()
|
||||
.api.postFollowing(videoEntity!!.user.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
videoEntity.me.isFollower = true
|
||||
followVideoInfo.postValue(videoEntity)
|
||||
Utils.toast(getApplication(), "关注成功")
|
||||
EventBus.getDefault().post(EBUserFollow(videoEntity.user.id, true))
|
||||
}
|
||||
})
|
||||
.api.postFollowing(videoEntity!!.user.id)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.subscribe(object : Response<ResponseBody>() {
|
||||
override fun onResponse(response: ResponseBody?) {
|
||||
super.onResponse(response)
|
||||
videoEntity.me.isFollower = true
|
||||
followVideoInfo.postValue(videoEntity)
|
||||
Utils.toast(getApplication(), "关注成功")
|
||||
EventBus.getDefault().post(EBUserFollow(videoEntity.user.id, true))
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user