parent
51c5e5f32c
commit
ec096b5831
|
@ -160,7 +160,7 @@ interface LiveApi {
|
|||
fun donation(
|
||||
@Body request: LiveRoomDonationRequest,
|
||||
@Header("Authorization") authHeader: String
|
||||
): Single<ApiResponse<Any>>
|
||||
): Single<ApiResponse<String>>
|
||||
|
||||
@POST("/live/room/donation/refund/{id}")
|
||||
fun refundDonation(
|
||||
|
|
|
@ -163,7 +163,7 @@ class LiveRepository(
|
|||
can: Int,
|
||||
message: String,
|
||||
token: String
|
||||
): Single<ApiResponse<Any>> {
|
||||
): Single<ApiResponse<String>> {
|
||||
return api.donation(
|
||||
request = LiveRoomDonationRequest(
|
||||
roomId = roomId,
|
||||
|
|
|
@ -30,6 +30,7 @@ import androidx.core.content.ContextCompat
|
|||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import coil.transform.CircleCropTransformation
|
||||
import com.bumptech.glide.Glide
|
||||
import com.github.dhaval2404.imagepicker.ImagePicker
|
||||
import com.google.gson.Gson
|
||||
import com.orhanobut.logger.Logger
|
||||
|
@ -1254,16 +1255,18 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
|
||||
private fun donation(can: Int, message: String) {
|
||||
val rawMessage = "${can}캔을 후원하셨습니다.\uD83D\uDCB0\uD83E\uDE99"
|
||||
val donationRawMessage = Gson().toJson(
|
||||
LiveRoomChatRawMessage(
|
||||
type = LiveRoomChatRawMessageType.DONATION,
|
||||
message = rawMessage,
|
||||
can = can,
|
||||
donationMessage = message
|
||||
)
|
||||
)
|
||||
|
||||
viewModel.donation(roomId, can, message) {
|
||||
viewModel.donation(roomId, can, message) { signatureImage ->
|
||||
val donationRawMessage = Gson().toJson(
|
||||
LiveRoomChatRawMessage(
|
||||
type = LiveRoomChatRawMessageType.DONATION,
|
||||
message = rawMessage,
|
||||
can = can,
|
||||
signatureImageUrl = signatureImage,
|
||||
donationMessage = message
|
||||
)
|
||||
)
|
||||
|
||||
agora.sendRawMessageToGroup(
|
||||
rawMessage = donationRawMessage.toByteArray(),
|
||||
onSuccess = {
|
||||
|
@ -1283,6 +1286,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
)
|
||||
invalidateChat()
|
||||
viewModel.addDonationCan(can)
|
||||
showSignatureImage(signatureImage)
|
||||
}
|
||||
},
|
||||
onFailure = {
|
||||
|
@ -1389,6 +1393,9 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
)
|
||||
invalidateChat()
|
||||
viewModel.addDonationCan(rawMessage.can)
|
||||
showSignatureImage(
|
||||
signatureImageUrl = rawMessage.signatureImageUrl ?: ""
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1718,6 +1725,22 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
|||
}
|
||||
}
|
||||
|
||||
private fun showSignatureImage(signatureImageUrl: String) {
|
||||
if (signatureImageUrl.isNotBlank()) {
|
||||
Glide
|
||||
.with(this)
|
||||
.asGif()
|
||||
.load(signatureImageUrl)
|
||||
.into(binding.ivSignature)
|
||||
|
||||
binding.ivSignature.visibility = View.VISIBLE
|
||||
handler.postDelayed({
|
||||
binding.ivSignature.setImageDrawable(null)
|
||||
binding.ivSignature.visibility = View.GONE
|
||||
}, 3500)
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val noChattingTime = 180L
|
||||
}
|
||||
|
|
|
@ -508,7 +508,7 @@ class LiveRoomViewModel(
|
|||
)
|
||||
}
|
||||
|
||||
fun donation(roomId: Long, can: Int, message: String, onSuccess: () -> Unit) {
|
||||
fun donation(roomId: Long, can: Int, message: String, onSuccess: (String) -> Unit) {
|
||||
_isLoading.postValue(true)
|
||||
compositeDisposable.add(
|
||||
repository.donation(roomId, can, message, "Bearer ${SharedPreferenceManager.token}")
|
||||
|
@ -519,7 +519,7 @@ class LiveRoomViewModel(
|
|||
_isLoading.value = false
|
||||
if (it.success) {
|
||||
SharedPreferenceManager.can -= can
|
||||
onSuccess()
|
||||
onSuccess(it.data ?: "")
|
||||
} else {
|
||||
if (it.message != null) {
|
||||
_toastLiveData.postValue(it.message)
|
||||
|
|
|
@ -6,6 +6,7 @@ data class LiveRoomChatRawMessage(
|
|||
@SerializedName("type") val type: LiveRoomChatRawMessageType,
|
||||
@SerializedName("message") val message: String,
|
||||
@SerializedName("can") val can: Int,
|
||||
@SerializedName("signatureImageUrl") val signatureImageUrl: String? = null,
|
||||
@SerializedName("donationMessage") val donationMessage: String?,
|
||||
@SerializedName("isActiveRoulette") val isActiveRoulette: Boolean? = null
|
||||
)
|
||||
|
|
|
@ -640,4 +640,16 @@
|
|||
android:contentDescription="@null"
|
||||
android:src="@drawable/btn_message_send" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_signature"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="200dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:contentDescription="@null"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
Loading…
Reference in New Issue