房间相册 发送图片至公屏

This commit is contained in:
wzq
2023-10-17 19:12:42 +08:00
parent ce5cc20ac4
commit 6134962297
10 changed files with 117 additions and 1 deletions

View File

@@ -74,7 +74,11 @@ class RoomAlbumFragment : BaseViewBindingFragment<FragmentRoomAlbumBinding>() {
setOnItemChildClickListener { _, view, position ->
if (view.id == R.id.v_action) {
val buttonItems = listOf(
ButtonItem("發送到公屏", {}),
ButtonItem("發送到公屏") {
dialogManager.showOkCancelDialog("確認將該照片發送至公屏") {
viewModel.sendPhoto(data[position].id)
}
},
ButtonItem("刪除照片", {}),
ButtonItem("查看大圖", {})
)

View File

@@ -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("發送成功")
})
}
}

View File

@@ -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<String>
@FormUrlEncoded
@POST("roomAlbum/sendPhoto")
suspend fun sendPhoto(
@Field("roomUid") roomUid: Long,
@Field("id") photoId: Int,
): ServiceResult<String>
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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