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