This commit is contained in:
18401019693 2022-07-22 18:51:07 +08:00
parent 701f1c6dc1
commit a97dcbbb5b
15 changed files with 270 additions and 72 deletions

View File

@ -0,0 +1,9 @@
package com.yunbao.common.event;
import com.yunbao.common.bean.BaseModel;
/**
* 融云连接状态监听通知
*/
public class RongIMConnectionStatusEvent extends BaseModel {
}

View File

@ -14,6 +14,7 @@ import com.yunbao.common.Constants;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.bean.BaseModel;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.event.RongIMConnectionStatusEvent;
import com.yunbao.common.manager.IMLoginManager;
import org.greenrobot.eventbus.EventBus;
@ -173,7 +174,7 @@ public class RongcloudIMManager {
break;
//用户账号在其它设备登录此设备被踢下线
case KICKED_OFFLINE_BY_OTHER_CLIENT:
// EventBus.getDefault().post(new BaseModel());
EventBus.getDefault().post(new RongIMConnectionStatusEvent());
break;
//连接暂时挂起多是由于网络问题导致SDK 会在合适时机进行自动重连
case SUSPEND:

View File

@ -9,9 +9,9 @@ ext {
]
manifestPlaceholders = [
//
serverHost : "https://napi.yaoulive.com",
// serverHost : "https://napi.yaoulive.com",
//
// serverHost : "https://ceshi.yaoulive.com",
serverHost : "https://ceshi.yaoulive.com",
//
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -50,10 +50,13 @@ public class EditNameRemarksActivity extends AbsActivity implements View.OnClick
mEditText.setFilters(new InputFilter[]{
new InputFilter.LengthFilter(10)
});
String content = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
findViewById(R.id.btn_save).setOnClickListener(this);
mEditText.setText(content);
mEditText.setSelection(content.length());
String content = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
if (!TextUtils.isEmpty(content)){
mEditText.setText(content);
mEditText.setSelection(content.length());
}
}
@ -93,7 +96,7 @@ public class EditNameRemarksActivity extends AbsActivity implements View.OnClick
if (code == 0 && info.length > 0) {
JSONObject obj = JSON.parseObject(info[0]);
SearchUserBean userBean = JSON.toJavaObject(obj, SearchUserBean.class);
String userNiceName = userBean.getUserNiceName() + "(" + remark + ")";
String userNiceName = remark;
UserInfo userInfo = new UserInfo(userId, userNiceName, Uri.parse(userBean.getAvatar()));
//使用空白字段存储自己服务器用户的所有的信息
userInfo.setExtra(GsonUtils.toJson(userBean));

View File

@ -35,7 +35,6 @@ import org.greenrobot.eventbus.ThreadMode;
import java.util.ArrayList;
import io.rong.imkit.conversation.ConversationFragment;
import io.rong.imkit.userinfo.RongUserInfoManager;
import io.rong.imlib.model.UserInfo;
@ -66,7 +65,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
super.main();
EventBus.getDefault().register(this);
mContext = this;
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
// getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_PAN);
initView();
initData();
}
@ -100,33 +99,37 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
* 初始化布局
*/
private void initView() {
// 添加会话界面
conversationFragment = new PDLiveConversationFragment();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.container, conversationFragment);
transaction.commit();
inputPanel = findViewById(R.id.input_panel);
titleView = findViewById(R.id.titleView);
imgMore = findViewById(R.id.img_more);
imBack = findViewById(R.id.btn_back);
findViewById(R.id.root_layout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
});
imgMore.setOnClickListener(this);
imBack.setOnClickListener(this);
try {
// 添加会话界面
conversationFragment = new PDLiveConversationFragment();
FragmentManager manager = getSupportFragmentManager();
FragmentTransaction transaction = manager.beginTransaction();
transaction.replace(R.id.container, conversationFragment);
transaction.commit();
inputPanel = findViewById(R.id.input_panel);
titleView = findViewById(R.id.titleView);
imgMore = findViewById(R.id.img_more);
imBack = findViewById(R.id.btn_back);
findViewById(R.id.root_layout).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager imm = (InputMethodManager)
getSystemService(Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
}
});
imgMore.setOnClickListener(this);
imBack.setOnClickListener(this);
inputPanel.addMediaMessageCallback(new InputPanelViewHolder.MediaMessageCallback() {
@Override
public void choosePic(int intoIndex) {
jumpPic(intoIndex);
}
});
inputPanel.addMediaMessageCallback(new InputPanelViewHolder.MediaMessageCallback() {
@Override
public void choosePic(int intoIndex) {
jumpPic(intoIndex);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}

View File

@ -28,12 +28,15 @@ public class PDLiveMessageListAdapter extends MessageListAdapter {
Message.SentStatus sentStatus = mDataList.get(position).getMessage().getSentStatus();
ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt);
ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new);
if (readReceipt.getVisibility() == View.VISIBLE) {
readReceipt.setVisibility(View.GONE);
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read);
} else {
if (messageDirection.equals(Message.MessageDirection.SEND)&&sentStatus.equals(Message.SentStatus.SENT))
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread);
if (readReceipt!=null&&readReceiptNew!=null){
if (readReceipt.getVisibility() == View.VISIBLE) {
readReceipt.setVisibility(View.GONE);
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read);
} else {
if (messageDirection.equals(Message.MessageDirection.SEND)&&sentStatus.equals(Message.SentStatus.SENT))
readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread);
}
}
}
}

View File

@ -163,7 +163,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
@Override
public void onError(Message message, RongIMClient.ErrorCode errorCode) {
ToastUtil.show(errorCode.msg);
}
});
} else {

View File

@ -50,10 +50,12 @@ import com.yunbao.common.bean.UpdataListBean;
import com.yunbao.common.bean.UserBean;
import com.yunbao.common.custom.TabButtonGroup;
import com.yunbao.common.event.MessageIMEvent;
import com.yunbao.common.event.RongIMConnectionStatusEvent;
import com.yunbao.common.event.UpdateTablePointMe;
import com.yunbao.common.http.CommonHttpConsts;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
@ -81,6 +83,7 @@ import com.yunbao.live.views.ChatListViewHolder;
import com.yunbao.main.R;
import com.yunbao.main.dialog.MainStartDialogFragment;
import com.yunbao.main.dialog.SigninDialog;
import com.yunbao.main.event.MainHomeCommunityToChatEvent;
import com.yunbao.main.event.PDLiveConversationListEvent;
import com.yunbao.main.http.MainHttpConsts;
import com.yunbao.main.http.MainHttpUtil;
@ -361,19 +364,19 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
RongcloudIMManager.addRongcloudIMOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {
@Override
public boolean onReceived(io.rong.imlib.model.Message message, int i, boolean b, boolean b1) {
Log.e("wewe",message.getConversationType() +"112121");
//融云直播间聊天
Message msg = Message.obtain();
msg.what = Constants.SOCKET_WHAT_BROADCAST;
if (!"".equals(message.getContent()) && message.getContent() != null) {
TextMessage content = (TextMessage) message.getContent();
if(content.getContent().contains("_method_")) {
msg.obj = content.getContent();
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
Log.e("wewe", message.getConversationType() + "112121");
//融云直播间聊天
Message msg = Message.obtain();
msg.what = Constants.SOCKET_WHAT_BROADCAST;
if (!"".equals(message.getContent()) && message.getContent() != null) {
TextMessage content = (TextMessage) message.getContent();
if (content.getContent().contains("_method_")) {
msg.obj = content.getContent();
if (SocketRyClient.mSocketHandler != null) {
SocketRyClient.mSocketHandler.sendMessage(msg);
}
}
}
return false;
}
});
@ -1096,9 +1099,21 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
* @param model
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void userSignOut(BaseModel model) {
// IMLoginManager.get(mContext).logout();
// CommonAppConfig.getInstance().clearLoginInfo();
// LoginActivity.forward();
public void userSignOut(RongIMConnectionStatusEvent model) {
IMLoginManager.get(mContext).logout();
CommonAppConfig.getInstance().clearLoginInfo();
LoginActivity.forward();
}
/**
* 用户被踢下线
*
* @param model
*/
@Subscribe(threadMode = ThreadMode.MAIN)
public void onMainHomeCommunityToChatEvent(MainHomeCommunityToChatEvent model) {
ConversationIMListManager.get(mContext).jumpConversation(mContext, model.getTargetId());
}
}

View File

@ -0,0 +1,89 @@
package com.yunbao.main.dialog;
import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.TextView;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.main.R;
import io.rong.imkit.IMCenter;
import io.rong.imlib.RongIMClient;
import io.rong.imlib.model.Conversation;
public class ConversationPopuwWindow implements View.OnClickListener {
private Activity mContext;
private String userId;
private View popupView;
private TextView tvBlack;
private PopupWindow popupWindow;
public ConversationPopuwWindow(Activity context) {
this.mContext = context;
popupView = LayoutInflater.from(mContext).inflate(R.layout.popwindow_chat_list, null);
initView();
}
public ConversationPopuwWindow setIsAdmin(String userId) {
this.userId = userId;
return this;
}
/**
* 初始化组件
*/
private void initView() {
tvBlack = popupView.findViewById(com.yunbao.live.R.id.tv_black);
tvBlack.setOnClickListener(this);
tvBlack.setText("删除");
}
/**
* 展示弹窗
*
* @param view 显示在什么组件的下面
* @return
*/
public void show(View view) {
popupWindow = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);
int[] location = new int[2];
view.getLocationOnScreen(location);
popupWindow.setBackgroundDrawable(new BitmapDrawable());
popupView.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
int popupWidth = popupView.getMeasuredWidth();
int popupHeight = popupView.getMeasuredHeight();
popupWindow.showAtLocation(view, Gravity.NO_GRAVITY, (location[0]+view.getWidth()/2)-popupWidth/2,
location[1]-popupHeight);
}
@Override
public void onClick(View v) {
int id = v.getId();
//拉黑
if (id == com.yunbao.live.R.id.tv_black) {
Conversation.ConversationType conversationType = Conversation.ConversationType.PRIVATE;
IMCenter.getInstance().removeConversation(conversationType, userId, new RongIMClient.ResultCallback<Boolean>() {
@Override
public void onSuccess(Boolean aBoolean) {
ToastUtil.show("删除成功");
}
@Override
public void onError(RongIMClient.ErrorCode errorCode) {
ToastUtil.show(errorCode.msg);
}
});
popupWindow.dismiss();
}
}
}

View File

@ -0,0 +1,19 @@
package com.yunbao.main.event;
import com.yunbao.common.bean.BaseModel;
/**
* web跳转聊天页面
*/
public class MainHomeCommunityToChatEvent extends BaseModel {
private String targetId = "";
public String getTargetId() {
return targetId;
}
public MainHomeCommunityToChatEvent setTargetId(String targetId) {
this.targetId = targetId;
return this;
}
}

View File

@ -6,6 +6,8 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Toast;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -13,19 +15,24 @@ import com.blankj.utilcode.util.GsonUtils;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.InstructorRemarkManager;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.activity.PDLIiveChatActivity;
import com.yunbao.live.activity.PDLiveConversationActivity;
import com.yunbao.live.bean.SearchUserBean;
import com.yunbao.main.activity.PDLiveConversationListActivity;
import com.yunbao.main.dialog.ConversationPopuwWindow;
import com.yunbao.main.utils.PDLiveCustomConversationProvider;
import com.yunbao.main.utils.PDLiveMessageProcessor;
import io.rong.imkit.RongIM;
import io.rong.imkit.config.ConversationListBehaviorListener;
import io.rong.imkit.config.RongConfigCenter;
import io.rong.imkit.conversationlist.model.BaseUiConversation;
import io.rong.imkit.conversationlist.provider.PrivateConversationProvider;
import io.rong.imkit.userinfo.RongUserInfoManager;
import io.rong.imkit.utils.RouteUtils;
import io.rong.imkit.widget.adapter.ProviderManager;
import io.rong.imlib.model.Conversation;
import io.rong.imlib.model.UserInfo;
/**
@ -47,6 +54,8 @@ public class ConversationIMListManager {
ProviderManager<BaseUiConversation> providerManager = RongConfigCenter.conversationListConfig().getProviderManager();
//用自定义模板替换 SDK 原有模板
providerManager.replaceProvider(PrivateConversationProvider.class, new PDLiveCustomConversationProvider());
//会话列表监听事件
RongIM.setConversationListBehaviorListener(listener);
}
/**
@ -98,10 +107,12 @@ public class ConversationIMListManager {
* @param targetId 用户id
*/
public void jumpConversation(Activity context, String targetId) {
Intent intent = new Intent(context, PDLiveConversationActivity.class);
intent.putExtra(RouteUtils.TARGET_ID, targetId);
context.startActivity(intent);
// RouteUtils.registerActivity(RouteUtils.RongActivityType.ConversationActivity, PDLiveConversationActivity.class);
// Intent intent = new Intent(context, PDLiveConversationActivity.class);
// intent.putExtra(RouteUtils.TARGET_ID, targetId);
// context.startActivity(intent);
Conversation.ConversationType type = Conversation.ConversationType.PRIVATE;
RouteUtils.routeToConversationActivity(context, type, targetId, null);
}
@ -119,7 +130,7 @@ public class ConversationIMListManager {
String userNiceName = "";
String remark = InstructorRemarkManager.get(mContext).getInstructorRemark().get(userId);
if (!TextUtils.isEmpty(remark)) {
userNiceName = userBean.getUserNiceName() + "(" + remark + ")";
userNiceName = remark;
} else {
userNiceName = userBean.getUserNiceName();
}
@ -137,5 +148,29 @@ public class ConversationIMListManager {
}
private ConversationListBehaviorListener listener = new ConversationListBehaviorListener() {
@Override
public boolean onConversationPortraitClick(Context context, Conversation.ConversationType conversationType, String s) {
return false;
}
@Override
public boolean onConversationPortraitLongClick(Context context, Conversation.ConversationType conversationType, String s) {
return false;
}
@Override
public boolean onConversationLongClick(Context context, View view, BaseUiConversation baseUiConversation) {
new ConversationPopuwWindow((Activity) context)
.setIsAdmin(baseUiConversation.mCore.getTargetId())
.show(view);
return true;
}
@Override
public boolean onConversationClick(Context context, View view, BaseUiConversation baseUiConversation) {
return false;
}
};
}

View File

@ -45,9 +45,9 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider {
Message.ReceivedStatus receivedStatus = list.get(position).mCore.getReceivedStatus();
ImageView readReceipt = holder.itemView.findViewById(com.yunbao.live.R.id.rc_read_receipt_new);
if (receivedStatus.isRead()) {
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_read);
}else {
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_unread);
}else {
readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_message_read);
}
}
}

View File

@ -9,7 +9,9 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import androidx.annotation.RequiresApi;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@ -49,11 +51,15 @@ import com.yunbao.main.R;
import com.yunbao.main.activity.FansActivity;
import com.yunbao.main.activity.MainActivity;
import com.yunbao.main.dialog.EncourageDialog;
import com.yunbao.main.event.MainHomeCommunityToChatEvent;
import com.yunbao.main.manager.imrongcloud.ConversationIMListManager;
import com.yunbao.main.utils.BottomBarUtil;
import com.yunbao.video.activity.VideoPlayActivity;
import com.yunbao.video.bean.VideoBean;
import com.yunbao.video.utils.VideoStorge;
import org.greenrobot.eventbus.EventBus;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@ -209,12 +215,6 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
}
public void loadNewUrl() {
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// mWebView.reload();
// }
// },100);
}
//js调用原生
@ -294,8 +294,10 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
@JavascriptInterface
public void androidClickSayHiBack(String uid, String name, String img) {
SystemMessageActivity.forward(mContext, "-1", uid, name, img);
EventBus.getDefault().post(new MainHomeCommunityToChatEvent().setTargetId(uid));
}
@JavascriptInterface
public void androidMethodLookToLive(String liveId) {
//看直播
@ -321,6 +323,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
}
private LiveRoomCheckLivePresenter mCheckLivePresenter;
private void gotoLive(final String live_id) {
LiveHttpUtil.getLiveInfo(live_id, new HttpCallback() {
@Override
@ -343,7 +346,7 @@ public class MainHomeCommunityViewHolder extends AbsMainHomeChildViewHolder impl
}
mCheckLivePresenter.checkLive(liveBean);
} else {
RouteUtil.forwardUserHome(mContext, live_id,0);
RouteUtil.forwardUserHome(mContext, live_id, 0);
}
}
});

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/tv_black"
android:layout_width="150dp"
android:layout_height="70dp"
android:background="@mipmap/chat_back"
android:gravity="center"
android:text="@string/delete"
android:textColor="@color/white"
android:textSize="17sp" />
</LinearLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB