房间相册 公屏消息 解锁
This commit is contained in:
@@ -47,6 +47,7 @@ import com.yizhuan.erban.avroom.dialog.RoomOperationDialog
|
||||
import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog
|
||||
import com.yizhuan.erban.avroom.presenter.BaseRoomPresenter
|
||||
import com.yizhuan.erban.avroom.redpackage.RedPackageSendDialog
|
||||
import com.yizhuan.erban.avroom.room_album.RoomAlbumModel
|
||||
import com.yizhuan.erban.avroom.view.IBaseRoomView
|
||||
import com.yizhuan.erban.avroom.widget.BottomView
|
||||
import com.yizhuan.erban.avroom.widget.MessageView
|
||||
@@ -284,6 +285,16 @@ open class BaseRoomFragment<V : IBaseRoomView?, P : BaseRoomPresenter<V>?> :
|
||||
|
||||
//获取免费礼物详情
|
||||
mvpPresenter?.queryFreeFlower()
|
||||
initRoomAlbum()
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun initRoomAlbum() {
|
||||
RoomAlbumModel.listUnlockRoomPhoto(AvRoomDataManager.get().roomUid)
|
||||
.compose(bindToLifecycle())
|
||||
.subscribe({
|
||||
AvRoomDataManager.get().unlockedRoomAlbumPhotos = it
|
||||
}, { toast(it.message) })
|
||||
}
|
||||
|
||||
@CallSuper
|
||||
|
@@ -3,15 +3,18 @@ package com.yizhuan.erban.avroom.room_album
|
||||
import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo
|
||||
import com.yizhuan.xchat_android_core.Constants
|
||||
import com.yizhuan.xchat_android_core.bean.response.ServiceResult
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_core.utils.net.launchRequest
|
||||
import com.yizhuan.xchat_android_library.net.rxnet.RxNet
|
||||
import io.reactivex.Single
|
||||
import retrofit2.http.Field
|
||||
import retrofit2.http.FormUrlEncoded
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
import retrofit2.http.Query
|
||||
|
||||
object RoomAlbumModel {
|
||||
object RoomAlbumModel {
|
||||
private val api = RxNet.create(Api::class.java)
|
||||
|
||||
suspend fun loadPhotos(roomUid: Long, type: Int, page: Int): List<RoomAlbumPhotoInfo>? {
|
||||
@@ -20,24 +23,35 @@ object RoomAlbumModel {
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun uploadPhotos(roomUid: Long, type: Int, photoUrls: String, giftId: Int?) : String? {
|
||||
suspend fun uploadPhotos(roomUid: Long, type: Int, photoUrls: String, giftId: Int?): String? {
|
||||
return launchRequest {
|
||||
api.uploadPhotos(roomUid, type, photoUrls, giftId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun sendPhoto(roomUid: Long, photoId: Int) : String? {
|
||||
suspend fun sendPhoto(roomUid: Long, photoId: Int): String? {
|
||||
return launchRequest {
|
||||
api.sendPhoto(roomUid, photoId)
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun deletePhoto(photoId: Int) : String? {
|
||||
suspend fun deletePhoto(photoId: Int): String? {
|
||||
return launchRequest {
|
||||
api.deletePhoto(photoId)
|
||||
}
|
||||
}
|
||||
|
||||
fun unlockRoomPhoto(roomUid: Long, photoId: Int): Single<GiftReceiveInfo> {
|
||||
return api.unlockRoomPhoto(roomUid, photoId)
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
fun listUnlockRoomPhoto(roomUid: Long): Single<List<Int>> {
|
||||
return api.listUnlockRoomPhoto(roomUid)
|
||||
.compose(RxHelper.handleCommon())
|
||||
.compose(RxHelper.handleSchAndExce())
|
||||
}
|
||||
|
||||
private interface Api {
|
||||
|
||||
@@ -70,5 +84,17 @@ object RoomAlbumModel {
|
||||
suspend fun deletePhoto(
|
||||
@Field("id") photoId: Int,
|
||||
): ServiceResult<String>
|
||||
|
||||
@FormUrlEncoded
|
||||
@POST("roomAlbum/unlockPhoto")
|
||||
fun unlockRoomPhoto(
|
||||
@Field("roomUid") roomUid: Long,
|
||||
@Field("id") photoId: Int
|
||||
): Single<ServiceResult<GiftReceiveInfo>>
|
||||
|
||||
@GET("roomAlbum/listUnlockPhoto")
|
||||
fun listUnlockRoomPhoto(
|
||||
@Query("roomUid") roomUid: Long,
|
||||
): Single<ServiceResult<List<Int>>>
|
||||
}
|
||||
}
|
@@ -6,8 +6,8 @@ import com.hjq.toast.ToastUtils
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.databinding.DialogLockRoomAlbumPhotoBinding
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo
|
||||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager
|
||||
import com.yizhuan.xchat_android_core.room.model.AvRoomModel
|
||||
|
||||
class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>(){
|
||||
|
||||
@@ -26,18 +26,20 @@ class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>()
|
||||
binding.tvValue.text = price.toString()
|
||||
|
||||
binding.tvAction.setOnClickListener {
|
||||
AvRoomModel.get().unlockRoomPhoto(AvRoomDataManager.get().roomUid, photoId)
|
||||
RoomAlbumModel.unlockRoomPhoto(AvRoomDataManager.get().roomUid, photoId)
|
||||
.subscribe({
|
||||
onUnlockRoomPhotoListener?.onUnlockRoomPhoto()
|
||||
onUnlockRoomPhotoListener?.onUnlockRoomPhoto(it)
|
||||
dismiss()
|
||||
}, {
|
||||
ToastUtils.show(it.message)
|
||||
})
|
||||
}
|
||||
|
||||
binding.ivClose.setOnClickListener { dismiss() }
|
||||
}
|
||||
|
||||
companion object{
|
||||
fun newInstance(photoId:Int, giftUrl: String, giftName:String, price:Int): UnlockRoomAlbumPhotoDialog {
|
||||
fun newInstance(photoId:Int, giftUrl: String?, giftName:String, price:Int): UnlockRoomAlbumPhotoDialog {
|
||||
val args = Bundle()
|
||||
args.putInt("photoId", photoId)
|
||||
args.putString("giftUrl", giftUrl)
|
||||
@@ -50,6 +52,6 @@ class UnlockRoomAlbumPhotoDialog : BaseDialog<DialogLockRoomAlbumPhotoBinding>()
|
||||
}
|
||||
|
||||
fun interface OnUnlockRoomPhotoListener{
|
||||
fun onUnlockRoomPhoto()
|
||||
fun onUnlockRoomPhoto(unlockRoomAlbumPhotoInfo: GiftReceiveInfo)
|
||||
}
|
||||
}
|
@@ -98,6 +98,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiver;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
|
||||
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.yizhuan.xchat_android_core.gift.toolbox.GiftToolbox;
|
||||
import com.yizhuan.xchat_android_core.helper.ImHelperUtils;
|
||||
import com.yizhuan.xchat_android_core.home.event.FollowRoomEvent;
|
||||
import com.yizhuan.xchat_android_core.home.model.CollectionRoomModel;
|
||||
@@ -137,6 +138,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.RoomReceivedLuckyGiftAttach
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.RoomTipAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.TarotMsgBean;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.User;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.VipMessageAttachment;
|
||||
import com.yizhuan.xchat_android_core.im.custom.bean.WelcomeAttachment;
|
||||
import com.yizhuan.xchat_android_core.level.UserLevelResourceType;
|
||||
@@ -1039,43 +1041,81 @@ public class MessageView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void setRoomAlbumMsg(ChatRoomMessage chatRoomMessage, MessageViewHolder baseViewHolder) {
|
||||
ImageView ivUserLevel = baseViewHolder.itemView.findViewById(R.id.iv_user_level);
|
||||
ImageView ivUserCharm = baseViewHolder.itemView.findViewById(R.id.iv_user_charm);
|
||||
ImageView ivPhoto = baseViewHolder.itemView.findViewById(R.id.iv_photo);
|
||||
ImageView ivGift = baseViewHolder.itemView.findViewById(R.id.iv_gift);
|
||||
TextView tvNick = baseViewHolder.itemView.findViewById(R.id.tv_nick);
|
||||
TextView tvValue = baseViewHolder.itemView.findViewById(R.id.tv_value);
|
||||
TextView tvUnlock = baseViewHolder.itemView.findViewById(R.id.tv_unlock);
|
||||
|
||||
RoomAlbumAttachment attachment = (RoomAlbumAttachment) chatRoomMessage.getAttachment();
|
||||
RoomAlbumMsgInfo mRoomAlbumMsgInfo = attachment.getMRoomAlbumMsgInfo();
|
||||
|
||||
if (mRoomAlbumMsgInfo == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
RoomPhoto roomPhoto = mRoomAlbumMsgInfo.getRoomPhoto();
|
||||
User user = mRoomAlbumMsgInfo.getUser();
|
||||
|
||||
ImageView ivUserLevel = baseViewHolder.itemView.findViewById(R.id.iv_user_level);
|
||||
ImageView ivUserCharm = baseViewHolder.itemView.findViewById(R.id.iv_user_charm);
|
||||
ImageView ivPhoto = baseViewHolder.itemView.findViewById(R.id.iv_photo);
|
||||
ImageView ivGift = baseViewHolder.itemView.findViewById(R.id.iv_gift);
|
||||
ImageView ivDiamond = baseViewHolder.itemView.findViewById(R.id.iv_diamond);
|
||||
TextView tvNick = baseViewHolder.itemView.findViewById(R.id.tv_nick);
|
||||
TextView tvValue = baseViewHolder.itemView.findViewById(R.id.tv_value);
|
||||
TextView tvUnlock = baseViewHolder.itemView.findViewById(R.id.tv_unlock);
|
||||
View vBottomMask = baseViewHolder.itemView.findViewById(R.id.v_bottom_mask);
|
||||
|
||||
ImageLoadUtilsV2.loadImage(ivUserLevel, mRoomAlbumMsgInfo.getUserLevel().getExperUrl());
|
||||
ImageLoadUtilsV2.loadImage(ivUserCharm, mRoomAlbumMsgInfo.getUserLevel().getCharmUrl());
|
||||
RoomPhoto roomPhoto = mRoomAlbumMsgInfo.getRoomPhoto();
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, roomPhoto.getPhotoUrl());
|
||||
ImageLoadUtilsV2.loadImage(ivGift, roomPhoto.getGiftUrl());
|
||||
tvNick.setText(mRoomAlbumMsgInfo.getUser().getNick());
|
||||
tvValue.setText(String.valueOf(roomPhoto.getTotalGoldPrice()));
|
||||
tvNick.setText(user.getNick());
|
||||
tvUnlock.setText("解鎖");
|
||||
tvUnlock.setBackgroundResource(R.drawable.bg_9168fa_6);
|
||||
|
||||
if (roomPhoto.getType() == 1) {
|
||||
vBottomMask.setVisibility(View.INVISIBLE);
|
||||
ivGift.setVisibility(View.INVISIBLE);
|
||||
ivDiamond.setVisibility(View.INVISIBLE);
|
||||
tvValue.setVisibility(View.INVISIBLE);
|
||||
tvUnlock.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
vBottomMask.setVisibility(View.VISIBLE);
|
||||
ivGift.setVisibility(View.VISIBLE);
|
||||
ivDiamond.setVisibility(View.VISIBLE);
|
||||
tvValue.setVisibility(View.VISIBLE);
|
||||
tvUnlock.setVisibility(View.VISIBLE);
|
||||
|
||||
boolean isMyself = UserModel.get().isMyseft(user.getUid());
|
||||
if (isMyself) {
|
||||
tvUnlock.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
List<Integer> unlockedIds= AvRoomDataManager.get().getUnlockedRoomAlbumPhotos();
|
||||
if (isMyself || unlockedIds.contains(roomPhoto.getId())) {
|
||||
ImageLoadUtilsV2.loadImage(ivPhoto, roomPhoto.getPhotoUrl());
|
||||
tvUnlock.setText("已解鎖");
|
||||
tvUnlock.setBackgroundResource(R.drawable.bg_9e9ea8_6);
|
||||
vBottomMask.setVisibility(View.INVISIBLE);
|
||||
ivGift.setVisibility(View.INVISIBLE);
|
||||
ivDiamond.setVisibility(View.INVISIBLE);
|
||||
tvValue.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
ImageLoadUtils.loadImageWithBlur(mContext, roomPhoto.getPhotoUrl(), ivPhoto, 25, 4);
|
||||
}
|
||||
|
||||
ImageLoadUtilsV2.loadImage(ivGift, roomPhoto.getGiftUrl());
|
||||
tvValue.setText(String.valueOf(roomPhoto.getTotalGoldPrice()));
|
||||
}
|
||||
|
||||
|
||||
tvUnlock.setOnClickListener(v -> {
|
||||
UnlockRoomAlbumPhotoDialog unlockRoomAlbumPhotoDialog = UnlockRoomAlbumPhotoDialog.Companion
|
||||
.newInstance(roomPhoto.getId(), roomPhoto.getGiftUrl(), roomPhoto.getGiftName(), roomPhoto.getTotalGoldPrice());
|
||||
unlockRoomAlbumPhotoDialog.setOnUnlockRoomPhotoListener(() -> {
|
||||
unlockRoomAlbumPhotoDialog.setOnUnlockRoomPhotoListener(giftReceiveInfo -> {
|
||||
giftReceiveInfo.setRoomAlbum(true);
|
||||
GiftToolbox.sendGiftRoomMessage(giftReceiveInfo);
|
||||
|
||||
int position = baseViewHolder.getAbsoluteAdapterPosition();
|
||||
AvRoomDataManager.get().addUnlockedRoomAlbumPhoto(roomPhoto.getId());
|
||||
notifyItemChanged(position);
|
||||
});
|
||||
unlockRoomAlbumPhotoDialog.show(mContext);
|
||||
//new DialogManager(mContext).showOkDialog("是否解锁", () -> {
|
||||
// AvRoomModel.get().unlockRoomPhoto(AvRoomDataManager.get().getRoomUid(), mRoomAlbumMsgInfo.getRoomPhoto().getId())
|
||||
// .subscribe(data -> {
|
||||
// ToastUtils.show("成功");
|
||||
// }, e -> {});
|
||||
//});
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void setFairyMsg(ChatRoomMessage chatRoomMessage, TextView tvContent) {
|
||||
|
8
app/src/main/res/drawable/bg_9e9ea8_6.xml
Normal file
8
app/src/main/res/drawable/bg_9e9ea8_6.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<corners android:radius="@dimen/dp_6"/>
|
||||
|
||||
<solid android:color="@color/color_9E9EA8" />
|
||||
|
||||
</shape>
|
8
app/src/main/res/drawable/bg_white_round_20.xml
Normal file
8
app/src/main/res/drawable/bg_white_round_20.xml
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<corners android:radius="@dimen/dp_10" />
|
||||
<solid android:color="@color/white" />
|
||||
|
||||
</shape>
|
@@ -3,7 +3,7 @@
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@drawable/bg_white_cornor_8">
|
||||
android:background="@drawable/bg_white_round_20">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_title"
|
||||
|
@@ -701,5 +701,6 @@
|
||||
<color name="color_C2A66FFF">#C2A66FFF</color>
|
||||
<color name="color_306065">#306065</color>
|
||||
<color name="color_1E686868">#1E686868</color>
|
||||
<color name="color_9E9EA8">#9E9EA8</color>
|
||||
|
||||
</resources>
|
||||
|
Reference in New Issue
Block a user