房间相册 公屏消息 解锁

This commit is contained in:
wzq
2023-10-18 13:14:49 +08:00
parent 2074039de2
commit b75ba89d75
15 changed files with 171 additions and 49 deletions

View File

@@ -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

View File

@@ -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>>>
}
}

View File

@@ -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)
}
}

View File

@@ -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) {

View 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>

View 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>

View File

@@ -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"

View File

@@ -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>

View File

@@ -74,6 +74,7 @@ import com.yizhuan.xchat_android_core.family.bean.FamilyInfo;
import com.yizhuan.xchat_android_core.family.event.FamilyMineEvent;
import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftReceiveInfo;
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftDataEvent;
import com.yizhuan.xchat_android_core.helper.AtProxy;
import com.yizhuan.xchat_android_core.im.custom.bean.ActivityTimerAttachment;
@@ -663,7 +664,6 @@ public final class IMNetEaseManager {
//自定義消息
CustomAttachment customAttachment = (CustomAttachment) msg.getAttachment();
if (customAttachment.getFirst() == CUSTOM_MSG_HEADER_TYPE_AUCTION
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_GIFT
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_ROOM_TIP
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_FOLLOW_ROOM
|| customAttachment.getFirst() == CustomAttachment.CUSTOM_MSG_HEADER_TYPE_SEND_MAGIC
@@ -761,17 +761,24 @@ public final class IMNetEaseManager {
case CUSTOM_MSG_HEADER_TYPE_GIFT:
if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_GIFT) {
GiftAttachment giftAttachment = (GiftAttachment) attachment;
GiftInfo giftInfo = giftAttachment.getGiftReceiveInfo().getGift();
GiftReceiveInfo giftReceiveInfo = giftAttachment.getGiftReceiveInfo();
GiftInfo giftInfo = giftReceiveInfo.getGift();
// 兼容舊版發過來的giftAttachment沒有發送giftInfo的問題
giftInfo = giftInfo == null ?
GiftModel.get().findGiftInfoById(giftAttachment.getGiftReceiveInfo().getGiftId()) : giftInfo;
giftAttachment.getGiftReceiveInfo().setGift(giftInfo);
GiftModel.get().findGiftInfoById(giftReceiveInfo.getGiftId()) : giftInfo;
giftReceiveInfo.setGift(giftInfo);
GiftModel.get().addNewGift(giftInfo);
messages.add(msg);
gift = true;
if (!giftReceiveInfo.isRoomAlbum()) {
addMessages(msg);
}
} else if (customAttachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_TYPE_SEND_LUCKY_GIFT) {
messages.add(msg);
gift = true;
addMessages(msg);
} else {
addMessages(msg);
}
break;
case CUSTOM_MSG_HEADER_TYPE_MULTI_GIFT:
@@ -1823,7 +1830,19 @@ public final class IMNetEaseManager {
public void addMessagesImmediately(ChatRoomMessage msg) {
if (AvRoomDataManager.get().mCurrentRoomInfo != null && AvRoomDataManager.get().mCurrentRoomInfo.isCloseScreen())
return;
if (msg != null && !checkNoNeedMsg(msg)) {
if (msg == null) {
return;
}
if (msg.getAttachment() != null && msg.getAttachment() instanceof GiftAttachment) {
GiftAttachment attachment = (GiftAttachment) msg.getAttachment();
if (attachment.getGiftReceiveInfo().isRoomAlbum()) {
return;
}
}
if (!checkNoNeedMsg(msg)) {
noticeReceiverMessageImmediately(msg);
}
}

View File

@@ -27,4 +27,6 @@ public class GiftReceiveInfo implements Serializable {
//礼物值
private List<IndexGiftValue> giftValueVos;
private long currentTime;
private boolean isRoomAlbum;
}

View File

@@ -52,6 +52,7 @@ public class GiftAttachment extends CustomAttachment {
giftReceiveInfo.setGiftNum(data.getIntValue("giftNum"));
giftReceiveInfo.setTargetNick(data.getString("targetNick"));
giftReceiveInfo.setTargetAvatar(data.getString("targetAvatar"));
giftReceiveInfo.setRoomAlbum(data.getBoolean("isRoomAlbum"));
JSONObject giftJson = null;
if (data.containsKey("gift")) {
giftJson = data.getJSONObject("gift");
@@ -92,6 +93,7 @@ public class GiftAttachment extends CustomAttachment {
object.put("targetNick", giftReceiveInfo.getTargetNick());
object.put("targetAvatar", giftReceiveInfo.getTargetAvatar());
object.put("giftInfo", giftReceiveInfo.getGift());
object.put("isRoomAlbum", giftReceiveInfo.isRoomAlbum());
if (giftReceiveInfo.getGiftValueVos() != null) {
object.put("giftValueVos", giftReceiveInfo.getGiftValueVos());
}

View File

@@ -27,7 +27,7 @@ data class User(
val phone: String,
val phoneAreaCode: String,
val platformRole: Int,
val uid: Int,
val uid: Long,
val updateTime: String,
val useStatus: Int
)

View File

@@ -227,6 +227,8 @@ public final class AvRoomDataManager {
@Getter
private boolean hasRoomAlbum;
private List<Integer> unlockedRoomAlbumPhotos = new ArrayList<>();
private AvRoomDataManager() {
mRoomManagerList = new ArrayList<>();
mRoomFixedMemberList = new ArrayList<>();
@@ -1324,6 +1326,18 @@ public final class AvRoomDataManager {
}
}
public void setUnlockedRoomAlbumPhotos(List<Integer> unlockedRoomAlbumPhotos) {
this.unlockedRoomAlbumPhotos = unlockedRoomAlbumPhotos;
}
public List<Integer> getUnlockedRoomAlbumPhotos() {
return unlockedRoomAlbumPhotos;
}
public void addUnlockedRoomAlbumPhoto(int photoId) {
unlockedRoomAlbumPhotos.add(photoId);
}
private static final class Helper {
private static final AvRoomDataManager INSTANCE = new AvRoomDataManager();
}

View File

@@ -775,13 +775,6 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
.compose(RxHelper.handleSchedulers());
}
@Override
public Single<String> unlockRoomPhoto(long roomUid, int photoId) {
return mRoomService.unlockRoomPhoto(roomUid, photoId)
.compose(RxHelper.handleStringData())
.compose(RxHelper.handleSchAndExce());
}
public Single<String> addIsomerism() {
return mRoomService.addIsomerism(AuthModel.get().getCurrentUid(), AvRoomDataManager.get().getRoomId())
.compose(RxHelper.singleMainResult());
@@ -1195,9 +1188,6 @@ public class RoomBaseModel extends BaseModel implements IRoomBaseModel {
@POST("/roomFirstChargeWindow/update")
Single<ServiceResult<String>> postFirstCharge(@Field("roomUid") long roomUid);
@FormUrlEncoded
@POST("roomAlbum/unlockPhoto")
Single<ServiceResult<String>> unlockRoomPhoto(@Field("roomUid") long roomUid, @Field("id") int photoId);
}
}

View File

@@ -179,5 +179,4 @@ public interface IRoomBaseModel extends IModel {
*/
Single<RoomInfo> closeScreen(long roomId, boolean isCloseScreen);
Single<String> unlockRoomPhoto(long roomUid, int photoId);
}