私聊页面添加直播飞机票
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
package com.yunbao.common.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class RecommendLiveRoomModel extends BaseModel {
|
||||
|
||||
/**
|
||||
* liveuid : 97714
|
||||
* user_nicename : rongyun004
|
||||
* avatar : https://downs.yaoulive.com/20220329113227_c661f791c5fc878c2ef357ee022f9fbc?imageView2/2/w/600/h/600
|
||||
* title :
|
||||
*/
|
||||
|
||||
@SerializedName("liveuid")
|
||||
private String liveuid;
|
||||
@SerializedName("user_nicename")
|
||||
private String userNicename;
|
||||
@SerializedName("avatar")
|
||||
private String avatar;
|
||||
@SerializedName("title")
|
||||
private String title;
|
||||
|
||||
public String getLiveuid() {
|
||||
return liveuid;
|
||||
}
|
||||
|
||||
public RecommendLiveRoomModel setLiveuid(String liveuid) {
|
||||
this.liveuid = liveuid;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getUserNicename() {
|
||||
return userNicename;
|
||||
}
|
||||
|
||||
public RecommendLiveRoomModel setUserNicename(String userNicename) {
|
||||
this.userNicename = userNicename;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getAvatar() {
|
||||
return avatar;
|
||||
}
|
||||
|
||||
public RecommendLiveRoomModel setAvatar(String avatar) {
|
||||
this.avatar = avatar;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public RecommendLiveRoomModel setTitle(String title) {
|
||||
this.title = title;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yunbao.common.manager.imrongcloud;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Parcel;
|
||||
|
||||
import io.rong.imlib.MessageTag;
|
||||
import io.rong.imlib.model.MessageContent;
|
||||
|
||||
@SuppressLint("ParcelCreator")
|
||||
@MessageTag(value = "InstructorSendReward", flag = MessageTag.ISCOUNTED)
|
||||
public class InstructorSendReward extends MessageContent {
|
||||
public InstructorSendReward(byte[] data) {
|
||||
super(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.yunbao.common.manager.imrongcloud;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.Spannable;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.rong.imkit.conversation.messgelist.provider.BaseMessageItemProvider;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.adapter.IViewProviderListener;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
import io.rong.imlib.model.MessageContent;
|
||||
|
||||
/**
|
||||
* 自定义消息模板
|
||||
*/
|
||||
public class InstructorSendRewardProvider extends BaseMessageItemProvider<InstructorSendReward> {
|
||||
/**
|
||||
* 创建 ViewHolder
|
||||
*
|
||||
* @param viewGroup 父 ViewGroup
|
||||
* @param viewType 视图类型
|
||||
* @return ViewHolder
|
||||
*/
|
||||
@Override
|
||||
protected ViewHolder onCreateMessageContentViewHolder(ViewGroup viewGroup, int viewType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置消息视图里各 view 的值
|
||||
*
|
||||
* @param holder ViewHolder
|
||||
* @param parentHolder 父布局的 ViewHolder
|
||||
* @param instructorSendReward 此展示模板对应的消息
|
||||
* @param uiMessage {@link UiMessage}
|
||||
* @param position 消息位置
|
||||
* @param list 列表
|
||||
* @param listener ViewModel 的点击事件监听器。如果某个子 view 的点击事件需要 ViewModel 处理,可通过此监听器回调。
|
||||
*/
|
||||
@Override
|
||||
protected void bindMessageContentViewHolder(ViewHolder holder, ViewHolder parentHolder, InstructorSendReward instructorSendReward, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @param holder ViewHolder
|
||||
* @param instructorSendReward 自定义消息
|
||||
* @param uiMessage {@link UiMessage}
|
||||
* @param position 位置
|
||||
* @param list 列表数据
|
||||
* @param listener ViewModel 的点击事件监听器。如果某个子 view 的点击事件需要 ViewModel 处理,可通过此监听器回调。
|
||||
* @return 点击事件是否被消费
|
||||
*/
|
||||
@Override
|
||||
protected boolean onItemClick(ViewHolder holder, InstructorSendReward instructorSendReward, UiMessage uiMessage, int position, List<UiMessage> list, IViewProviderListener<UiMessage> listener) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据消息内容,判断是否为本模板需要展示的消息类型
|
||||
*
|
||||
* @param messageContent 消息内容
|
||||
* @return 本模板是否处理。
|
||||
*/
|
||||
@Override
|
||||
protected boolean isMessageViewType(MessageContent messageContent) {
|
||||
return messageContent instanceof InstructorSendReward;
|
||||
}
|
||||
|
||||
/**
|
||||
* 在会话列表页某条会话最后一条消息为该类型消息时,会话里需要展示的内容。
|
||||
* 比如: 图片消息在会话里需要展示为"图片",那返回对应的字符串资源即可。
|
||||
*
|
||||
* @param context 上下文
|
||||
* @param instructorSendReward 消息内容
|
||||
* @return 会话里需要展示的字符串资源
|
||||
*/
|
||||
@Override
|
||||
public Spannable getSummarySpannable(Context context, InstructorSendReward instructorSendReward) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.yunbao.common.manager.imrongcloud;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import io.rong.common.ParcelUtils;
|
||||
import io.rong.imlib.MessageTag;
|
||||
import io.rong.imlib.model.MessageContent;
|
||||
|
||||
@MessageTag(value = "RecommendLiveRoom", flag = MessageTag.ISCOUNTED)
|
||||
public class RecommendLiveRoom extends MessageContent implements Parcelable {
|
||||
// 自定义消息变量,可以有多个
|
||||
private String content;
|
||||
|
||||
public RecommendLiveRoom setContent(String content) {
|
||||
this.content = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public RecommendLiveRoom(byte[] data) {
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
String jsonStr = null;
|
||||
try {
|
||||
jsonStr = new String(data, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
if (jsonStr == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
JSONObject jsonObj = new JSONObject(jsonStr);
|
||||
// 消息携带用户信息时, 自定义消息需添加下面代码
|
||||
if (jsonObj.has("user")) {
|
||||
setUserInfo(parseJsonToUserInfo(jsonObj.getJSONObject("user")));
|
||||
}
|
||||
// 用于群组聊天, 消息携带 @ 人信息时, 自定义消息需添加下面代码
|
||||
if (jsonObj.has("mentionedInfo")) {
|
||||
setMentionedInfo(parseJsonToMentionInfo(jsonObj.getJSONObject("mentionedInfo")));
|
||||
}
|
||||
// 将所有自定义变量从收到的 json 解析并赋值
|
||||
if (jsonObj.has("content")) {
|
||||
content = jsonObj.optString("content");
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 将本地消息对象序列化为消息数据。
|
||||
*
|
||||
* @return 消息数据。
|
||||
*/
|
||||
@Override
|
||||
public byte[] encode() {
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
try {
|
||||
// 消息携带用户信息时, 自定义消息需添加下面代码
|
||||
if (getJSONUserInfo() != null) {
|
||||
jsonObj.putOpt("user", getJSONUserInfo());
|
||||
}
|
||||
// 用于群组聊天, 消息携带 @ 人信息时, 自定义消息需添加下面代码
|
||||
if (getJsonMentionInfo() != null) {
|
||||
jsonObj.putOpt("mentionedInfo", getJsonMentionInfo());
|
||||
}
|
||||
// 将所有自定义消息的内容,都序列化至 json 对象中
|
||||
jsonObj.put("content", this.content);
|
||||
} catch (JSONException e) {
|
||||
}
|
||||
|
||||
try {
|
||||
return jsonObj.toString().getBytes("UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
ParcelUtils.writeToParcel(dest, getExtra());
|
||||
ParcelUtils.writeToParcel(dest, content);
|
||||
}
|
||||
public static final Creator<RecommendLiveRoom> CREATOR = new Creator<RecommendLiveRoom>() {
|
||||
@Override
|
||||
public RecommendLiveRoom createFromParcel(Parcel source) {
|
||||
return new RecommendLiveRoom(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public RecommendLiveRoom[] newArray(int size) {
|
||||
return new RecommendLiveRoom[size];
|
||||
}
|
||||
};
|
||||
public RecommendLiveRoom(Parcel in) {
|
||||
setExtra(ParcelUtils.readFromParcel(in));
|
||||
setContent(ParcelUtils.readFromParcel(in));
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,8 @@ import com.yunbao.common.manager.IMLoginManager;
|
||||
|
||||
import org.greenrobot.eventbus.EventBus;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.rong.imkit.GlideKitImageEngine;
|
||||
import io.rong.imkit.IMCenter;
|
||||
import io.rong.imkit.RongIM;
|
||||
@@ -23,6 +25,7 @@ import io.rong.imkit.config.RongConfigCenter;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.Message;
|
||||
import io.rong.imlib.model.MessageContent;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.isReady;
|
||||
|
||||
@@ -46,8 +49,11 @@ public class RongcloudIMManager {
|
||||
public static void initRongIM(Application application) {
|
||||
//第三个参数代表是否开启推送
|
||||
RongIM.init(application, RONG_IM_KEY, true);
|
||||
|
||||
|
||||
Log.e(CLASSNAME, "initRongIM:");
|
||||
initPhotoGlide();
|
||||
|
||||
}
|
||||
|
||||
private static RongIMClient.OnReceiveMessageWrapperListener mListener;
|
||||
|
||||
Reference in New Issue
Block a user