fix(live-room): 잘못 사용 되어 효과가 없는 mutex 제거
This commit is contained in:
@@ -12,9 +12,9 @@ import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Path
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.Rect
|
||||
import android.graphics.Typeface
|
||||
import android.graphics.drawable.Drawable
|
||||
@@ -47,7 +47,6 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.toColorInt
|
||||
import androidx.core.graphics.withTranslation
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.transform.CircleCropTransformation
|
||||
@@ -70,7 +69,6 @@ import io.agora.rtm.RtmEventListener
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Observable
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kotlinx.coroutines.launch
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.agora.Agora
|
||||
import kr.co.vividnext.sodalive.base.BaseActivity
|
||||
@@ -1408,7 +1406,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
)
|
||||
)
|
||||
invalidateChat()
|
||||
lifecycleScope.launch { viewModel.addDonationCan(can) }
|
||||
viewModel.addDonationCan(can)
|
||||
addSignature(signature)
|
||||
}
|
||||
},
|
||||
@@ -1656,9 +1654,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
)
|
||||
)
|
||||
invalidateChat()
|
||||
lifecycleScope.launch {
|
||||
viewModel.addDonationCan(message.can)
|
||||
}
|
||||
|
||||
if (message.signature != null) {
|
||||
addSignature(message.signature)
|
||||
@@ -1684,27 +1680,23 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
)
|
||||
)
|
||||
invalidateChat()
|
||||
lifecycleScope.launch {
|
||||
viewModel.addDonationCan(message.can)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
LiveRoomChatRawMessageType.HEART_DONATION -> {
|
||||
handler.post {
|
||||
addHeartMessage(nickname)
|
||||
viewModel.addHeartDonation()
|
||||
addHeartAnimation()
|
||||
lifecycleScope.launch { viewModel.addHeartDonation() }
|
||||
}
|
||||
}
|
||||
|
||||
LiveRoomChatRawMessageType.BIG_HEART_DONATION -> {
|
||||
handler.post {
|
||||
addHeartMessage(nickname)
|
||||
addBigHeartAnimation()
|
||||
lifecycleScope.launch {
|
||||
viewModel.addHeartDonation(heartCount = message.can)
|
||||
}
|
||||
addBigHeartAnimation()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2076,7 +2068,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
handler.post {
|
||||
addHeartMessage(nickname)
|
||||
addHeartAnimation()
|
||||
lifecycleScope.launch { viewModel.addHeartDonation() }
|
||||
viewModel.addHeartDonation()
|
||||
}
|
||||
},
|
||||
onFailure = {
|
||||
@@ -2129,7 +2121,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
handler.post {
|
||||
addHeartMessage(nickname)
|
||||
addBigHeartAnimation()
|
||||
lifecycleScope.launch { viewModel.addHeartDonation(100) }
|
||||
viewModel.addHeartDonation(100)
|
||||
}
|
||||
},
|
||||
onFailure = {
|
||||
@@ -2566,7 +2558,8 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
val v0 = 100f + (1500f * Math.random().toFloat()) // 200..3000 px/s (초기 속도)
|
||||
|
||||
val rotateEnabled = Math.random() < 0.3
|
||||
val rotationSpeed = if (rotateEnabled) 300f * Math.random().toFloat() else 0f // deg/s
|
||||
val rotationSpeed =
|
||||
if (rotateEnabled) 300f * Math.random().toFloat() else 0f // deg/s
|
||||
val rotation0 = (-180f + 360f * Math.random().toFloat())
|
||||
|
||||
|
||||
@@ -2865,7 +2858,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||
)
|
||||
)
|
||||
invalidateChat()
|
||||
lifecycleScope.launch { viewModel.addDonationCan(can) }
|
||||
viewModel.addDonationCan(can)
|
||||
}
|
||||
},
|
||||
onFailure = {
|
||||
|
||||
@@ -7,8 +7,6 @@ import com.orhanobut.logger.Logger
|
||||
import io.reactivex.rxjava3.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.rxjava3.core.Single
|
||||
import io.reactivex.rxjava3.schedulers.Schedulers
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||
import kr.co.vividnext.sodalive.common.ApiResponse
|
||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||
@@ -100,8 +98,6 @@ class LiveRoomViewModel(
|
||||
|
||||
private val blockedMemberIdList: MutableList<Long> = mutableListOf()
|
||||
|
||||
val mutex = Mutex()
|
||||
|
||||
fun getUserNickname(memberId: Int): String {
|
||||
for (manager in roomInfoResponse.managerList) {
|
||||
if (manager.id.toInt() == memberId) {
|
||||
@@ -569,7 +565,11 @@ class LiveRoomViewModel(
|
||||
|
||||
fun likeHeart(roomId: Long, heartCount: Int = 1, onSuccess: () -> Unit, onFailure: () -> Unit) {
|
||||
compositeDisposable.add(
|
||||
repository.likeHeart(roomId, heartCount = heartCount, token = "Bearer ${SharedPreferenceManager.token}")
|
||||
repository.likeHeart(
|
||||
roomId,
|
||||
heartCount = heartCount,
|
||||
token = "Bearer ${SharedPreferenceManager.token}"
|
||||
)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(
|
||||
@@ -676,17 +676,13 @@ class LiveRoomViewModel(
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun addDonationCan(can: Int) {
|
||||
mutex.withLock {
|
||||
fun addDonationCan(can: Int) {
|
||||
_totalDonationCan.postValue(totalDonationCan.value!! + can)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun addHeartDonation(heartCount: Int = 1) {
|
||||
mutex.withLock {
|
||||
fun addHeartDonation(heartCount: Int = 1) {
|
||||
_totalHeartCount.postValue(totalHeartCount.value!! + heartCount)
|
||||
}
|
||||
}
|
||||
|
||||
fun donationStatus(roomId: Long, onSuccess: (GetLiveRoomDonationStatusResponse) -> Unit) {
|
||||
_isLoading.value = true
|
||||
|
||||
Reference in New Issue
Block a user