From 61349622971c93a7615305f81f51d3e5fa941f17 Mon Sep 17 00:00:00 2001 From: wzq Date: Tue, 17 Oct 2023 19:12:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=BF=E9=97=B4=E7=9B=B8=E5=86=8C=20?= =?UTF-8?q?=E5=8F=91=E9=80=81=E5=9B=BE=E7=89=87=E8=87=B3=E5=85=AC=E5=B1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../avroom/room_album/RoomAlbumFragment.kt | 6 +++- .../room_album/RoomAlbumFragmentViewModel.kt | 10 ++++++ .../erban/avroom/room_album/RoomAlbumModel.kt | 13 ++++++++ .../erban/avroom/widget/MessageView.java | 20 +++++++++++ .../layout_msg_view_holder_room_album.xml | 1 + .../manager/IMNetEaseManager.java | 3 ++ .../im/custom/bean/RoomAlbumAttachment.java | 7 ++++ .../im/custom/bean/RoomAlbumMsgInfo.kt | 9 +++++ .../im/custom/bean/RoomPhoto.kt | 16 +++++++++ .../xchat_android_core/im/custom/bean/User.kt | 33 +++++++++++++++++++ 10 files changed, 117 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumMsgInfo.kt create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomPhoto.kt create mode 100644 core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/User.kt diff --git a/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragment.kt b/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragment.kt index 715566b7a..cf00c94f9 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragment.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragment.kt @@ -74,7 +74,11 @@ class RoomAlbumFragment : BaseViewBindingFragment() { setOnItemChildClickListener { _, view, position -> if (view.id == R.id.v_action) { val buttonItems = listOf( - ButtonItem("發送到公屏", {}), + ButtonItem("發送到公屏") { + dialogManager.showOkCancelDialog("確認將該照片發送至公屏") { + viewModel.sendPhoto(data[position].id) + } + }, ButtonItem("刪除照片", {}), ButtonItem("查看大圖", {}) ) diff --git a/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragmentViewModel.kt b/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragmentViewModel.kt index 0ffc96f94..cc5737d5e 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragmentViewModel.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumFragmentViewModel.kt @@ -2,6 +2,7 @@ package com.yizhuan.erban.avroom.room_album import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData +import com.hjq.toast.ToastUtils import com.yizhuan.erban.avroom.bean.RoomAlbumPhotoInfo import com.yizhuan.erban.base.BaseViewModel import com.yizhuan.xchat_android_core.manager.AvRoomDataManager @@ -25,4 +26,13 @@ class RoomAlbumFragmentViewModel : BaseViewModel() { _myPhotosLiveData.value = value } } + + fun sendPhoto(photoId: Int) { + safeLaunch(block = { + RoomAlbumModel.sendPhoto(AvRoomDataManager.get().roomUid, photoId) + }, onComplete = { + ToastUtils.show("發送成功") + }) + + } } \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumModel.kt b/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumModel.kt index 9f14fc4ce..0336641af 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumModel.kt +++ b/app/src/main/java/com/yizhuan/erban/avroom/room_album/RoomAlbumModel.kt @@ -26,6 +26,12 @@ object RoomAlbumModel { } } + suspend fun sendPhoto(roomUid: Long, photoId: Int) : String? { + return launchRequest { + api.sendPhoto(roomUid, photoId) + } + } + private interface Api { @GET("roomAlbum/pagePhoto") @@ -44,5 +50,12 @@ object RoomAlbumModel { @Field("photoUrls") photoUrls: String, @Field("giftId") giftId: Int?, ): ServiceResult + + @FormUrlEncoded + @POST("roomAlbum/sendPhoto") + suspend fun sendPhoto( + @Field("roomUid") roomUid: Long, + @Field("id") photoId: Int, + ): ServiceResult } } \ No newline at end of file diff --git a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java index 4b817295b..432bcdf23 100644 --- a/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java +++ b/app/src/main/java/com/yizhuan/erban/avroom/widget/MessageView.java @@ -77,6 +77,7 @@ import com.yizhuan.erban.common.widget.OriginalDrawStatusClickSpan; import com.yizhuan.erban.treasure_box.widget.GoldBoxHelper; import com.yizhuan.erban.treasurefairy.HomeFairyActivity; import com.yizhuan.erban.ui.utils.ImageLoadUtils; +import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2; import com.yizhuan.erban.ui.widget.DividerItemDecoration; import com.yizhuan.erban.ui.widget.MyItemAnimator; import com.yizhuan.erban.ui.widget.RecyclerViewNoViewpagerScroll; @@ -122,6 +123,8 @@ import com.yizhuan.xchat_android_core.im.custom.bean.MultiGiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.MultiLuckyGiftAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageRoomMsgAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.RoomAlbumAttachment; +import com.yizhuan.xchat_android_core.im.custom.bean.RoomAlbumMsgInfo; import com.yizhuan.xchat_android_core.im.custom.bean.RoomBoxPrizeAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment; import com.yizhuan.xchat_android_core.im.custom.bean.RoomFollowOwnerAttachment2; @@ -1036,6 +1039,23 @@ 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); + + RoomAlbumAttachment attachment = (RoomAlbumAttachment) chatRoomMessage.getAttachment(); + RoomAlbumMsgInfo mRoomAlbumMsgInfo = attachment.getMRoomAlbumMsgInfo(); + if (mRoomAlbumMsgInfo == null) { + return; + } + + ImageLoadUtilsV2.loadImage(ivUserLevel, mRoomAlbumMsgInfo.getUserLevel().getExperUrl()); + ImageLoadUtilsV2.loadImage(ivUserCharm, mRoomAlbumMsgInfo.getUserLevel().getCharmUrl()); + ImageLoadUtilsV2.loadImage(ivPhoto, mRoomAlbumMsgInfo.getRoomPhoto().getPhotoUrl()); + ImageLoadUtilsV2.loadImage(ivGift, mRoomAlbumMsgInfo.getRoomPhoto().getGiftUrl()); + tvNick.setText(mRoomAlbumMsgInfo.getUser().getNick()); + tvValue.setText(String.valueOf(mRoomAlbumMsgInfo.getRoomPhoto().getTotalGoldPrice())); } diff --git a/app/src/main/res/layout/layout_msg_view_holder_room_album.xml b/app/src/main/res/layout/layout_msg_view_holder_room_album.xml index 1ee048e82..8ed4bee3d 100644 --- a/app/src/main/res/layout/layout_msg_view_holder_room_album.xml +++ b/app/src/main/res/layout/layout_msg_view_holder_room_album.xml @@ -43,6 +43,7 @@ android:layout_width="@dimen/dp_140" android:layout_height="@dimen/dp_140" android:layout_marginTop="@dimen/dp_4" + android:scaleType="centerCrop" android:src="@drawable/default_cover" app:layout_constraintStart_toStartOf="@id/iv_user_level" app:layout_constraintTop_toBottomOf="@id/iv_user_level" diff --git a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java index 961ef620f..02e68b4f0 100644 --- a/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java +++ b/core/src/diff_src_erban/java/com/yizhuan/xchat_android_core/manager/IMNetEaseManager.java @@ -1371,6 +1371,9 @@ public final class IMNetEaseManager { case CUSTOM_MSG_NOTIFY_H5: noticeH5(msg); break; + case CUSTOM_MSG_ROOM_ALBUM: + addMessages(msg); + break; default: break; } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java index ca4cf929f..299dcec4c 100644 --- a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumAttachment.java @@ -1,15 +1,22 @@ package com.yizhuan.xchat_android_core.im.custom.bean; import com.alibaba.fastjson.JSONObject; +import com.google.gson.Gson; + +import lombok.Getter; public class RoomAlbumAttachment extends CustomAttachment { + @Getter + private RoomAlbumMsgInfo mRoomAlbumMsgInfo; + public RoomAlbumAttachment() { super(CUSTOM_MSG_ROOM_ALBUM, CUSTOM_MSG_ROOM_ALBUM_SUB); } @Override protected void parseData(JSONObject data) { + mRoomAlbumMsgInfo = new Gson().fromJson(data.toJSONString(), RoomAlbumMsgInfo.class); } } diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumMsgInfo.kt b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumMsgInfo.kt new file mode 100644 index 000000000..9656cf7b1 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomAlbumMsgInfo.kt @@ -0,0 +1,9 @@ +package com.yizhuan.xchat_android_core.im.custom.bean + +import com.yizhuan.xchat_android_core.level.UserLevelVo + +data class RoomAlbumMsgInfo( + val roomPhoto: RoomPhoto, + val user: User, + val userLevel: UserLevelVo +) \ No newline at end of file diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomPhoto.kt b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomPhoto.kt new file mode 100644 index 000000000..f93d7a863 --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/RoomPhoto.kt @@ -0,0 +1,16 @@ +package com.yizhuan.xchat_android_core.im.custom.bean + +data class RoomPhoto( + val createTime: String, + val giftId: Int, + val giftName: String, + val giftNum: Int, + val giftUrl: String, + val id: Int, + val photoUrl: String, + val roomUid: Int, + val status: Int, + val totalGoldPrice: Int, + val type: Int, + val uid: Int +) \ No newline at end of file diff --git a/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/User.kt b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/User.kt new file mode 100644 index 000000000..f18a0cebc --- /dev/null +++ b/core/src/main/java/com/yizhuan/xchat_android_core/im/custom/bean/User.kt @@ -0,0 +1,33 @@ +package com.yizhuan.xchat_android_core.im.custom.bean + +data class User( + val avatar: String, + val birth: String, + val certifyModifyTimes: Int, + val channel: String, + val channelType: Int, + val createTime: String, + val currentApp: String, + val defUser: Int, + val deviceId: String, + val erbanNo: Int, + val fansNum: Int, + val followNum: Int, + val gender: Int, + val hasPrettyErbanNo: Boolean, + val lastLoginIp: String, + val lastLoginRegion: String, + val lastLoginTime: String, + val newDevice: Boolean, + val nick: String, + val nobleId: Int, + val os: String, + val osversion: String, + val parentMode: Boolean, + val phone: String, + val phoneAreaCode: String, + val platformRole: Int, + val uid: Int, + val updateTime: String, + val useStatus: Int +) \ No newline at end of file