parent
e964679154
commit
ad0c18dceb
|
@ -24,6 +24,7 @@ import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationRequest
|
|||
import kr.co.vividnext.sodalive.live.room.donation.LiveRoomDonationResponse
|
||||
import kr.co.vividnext.sodalive.live.room.info.GetRoomInfoResponse
|
||||
import kr.co.vividnext.sodalive.live.room.kick_out.LiveRoomKickOutRequest
|
||||
import kr.co.vividnext.sodalive.live.room.like.GetLiveRoomHeartTotalResponse
|
||||
import kr.co.vividnext.sodalive.live.room.like.LiveRoomLikeHeartRequest
|
||||
import kr.co.vividnext.sodalive.live.room.profile.GetLiveRoomUserProfileResponse
|
||||
import kr.co.vividnext.sodalive.live.room.tag.GetLiveTagResponse
|
||||
|
@ -219,4 +220,10 @@ interface LiveApi {
|
|||
@Body request: LiveRoomLikeHeartRequest,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<Any>>
|
||||
|
||||
@GET("/live/room/{id}/heart-total")
|
||||
fun getTotalHeartCount(
|
||||
@Path("id") id: Long,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<GetLiveRoomHeartTotalResponse>>
|
||||
}
|
||||
|
|
|
@ -251,4 +251,9 @@ class LiveRepository(
|
|||
),
|
||||
authHeader = token
|
||||
)
|
||||
|
||||
fun getTotalHeartCount(roomId: Long, token: String) = api.getTotalHeartCount(
|
||||
roomId,
|
||||
authHeader = token
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1091,7 +1091,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
binding.tvTotalCan.text = it.moneyFormat()
|
||||
}
|
||||
|
||||
viewModel.totalLikeHeart.observe(this) {
|
||||
viewModel.totalHeartCount.observe(this) {
|
||||
binding.tvTotalHeart.text = it.moneyFormat()
|
||||
}
|
||||
|
||||
|
|
|
@ -66,9 +66,9 @@ class LiveRoomViewModel(
|
|||
val totalDonationCan: LiveData<Int>
|
||||
get() = _totalDonationCan
|
||||
|
||||
private val _totalLikeHeart = MutableLiveData(0)
|
||||
val totalLikeHeart: LiveData<Int>
|
||||
get() = _totalLikeHeart
|
||||
private val _totalHeartCount = MutableLiveData(0)
|
||||
val totalHeartCount: LiveData<Int>
|
||||
get() = _totalHeartCount
|
||||
|
||||
private val _userProfileLiveData = MutableLiveData<GetLiveRoomUserProfileResponse>()
|
||||
val userProfileLiveData: LiveData<GetLiveRoomUserProfileResponse>
|
||||
|
@ -223,6 +223,7 @@ class LiveRoomViewModel(
|
|||
}
|
||||
|
||||
getTotalDonationCan(roomId = roomId)
|
||||
getTotalHeart(roomId = roomId)
|
||||
|
||||
if (it.data.isAdult && !SharedPreferenceManager.isAuth) {
|
||||
_changeIsAdultLiveData.value = true
|
||||
|
@ -683,7 +684,7 @@ class LiveRoomViewModel(
|
|||
|
||||
suspend fun addHeartDonation() {
|
||||
mutex.withLock {
|
||||
_totalLikeHeart.postValue(totalLikeHeart.value!! + 1)
|
||||
_totalHeartCount.postValue(totalHeartCount.value!! + 1)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -728,6 +729,27 @@ class LiveRoomViewModel(
|
|||
}
|
||||
}
|
||||
|
||||
private fun getTotalHeart(roomId: Long) {
|
||||
compositeDisposable.add(
|
||||
repository.getTotalHeartCount(
|
||||
roomId = roomId,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
{
|
||||
if (it.success && it.data != null) {
|
||||
_totalHeartCount.postValue(it.data.totalHeartCount)
|
||||
}
|
||||
},
|
||||
{
|
||||
_totalHeartCount.postValue(0)
|
||||
}
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
private fun getTotalDonationCan(roomId: Long) {
|
||||
compositeDisposable.add(
|
||||
repository.getTotalDonationCan(
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
package kr.co.vividnext.sodalive.live.room.like
|
||||
|
||||
import androidx.annotation.Keep
|
||||
import com.google.gson.annotations.SerializedName
|
||||
|
||||
@Keep
|
||||
data class GetLiveRoomHeartTotalResponse(
|
||||
@SerializedName("totalHeartCount") val totalHeartCount: Int
|
||||
)
|
Loading…
Reference in New Issue