From 5c42767ea35b846792d4c218a400b113f5d8fa61 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Wed, 27 Jul 2022 13:48:58 +0800 Subject: [PATCH] 11111 --- .../dialog/MessageLongClickPopuwindow.java | 50 +++++++++++++++++- .../manager/imrongcloud/MessageIMManager.java | 21 +++++--- .../res/layout/view_message_long_click.xml | 3 +- .../mipmap-xxhdpi/icon_message_withdraw.png | Bin 0 -> 748 bytes .../ConversationIMListManager.java | 9 ++-- 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 common/src/main/res/mipmap-xxhdpi/icon_message_withdraw.png diff --git a/common/src/main/java/com/yunbao/common/dialog/MessageLongClickPopuwindow.java b/common/src/main/java/com/yunbao/common/dialog/MessageLongClickPopuwindow.java index 1562414a3..1361f1b6c 100644 --- a/common/src/main/java/com/yunbao/common/dialog/MessageLongClickPopuwindow.java +++ b/common/src/main/java/com/yunbao/common/dialog/MessageLongClickPopuwindow.java @@ -1,21 +1,27 @@ package com.yunbao.common.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.widget.LinearLayout; import android.widget.PopupWindow; import com.yunbao.common.R; +import io.rong.imlib.model.Message; + /** * 消息長按彈窗 */ -public class MessageLongClickPopuwindow { +public class MessageLongClickPopuwindow implements View.OnClickListener { private Activity mContext; private View popupView; private PopupWindow popupWindow; private LinearLayout copyLinear; + private Message message; public MessageLongClickPopuwindow(Activity context) { this.mContext = context; @@ -23,6 +29,48 @@ public class MessageLongClickPopuwindow { initView(); } + public MessageLongClickPopuwindow setMessage(Message message) { + this.message = message; + return this; + } + + /** + * 展示弹窗 + * + * @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); + } + private void initView() { + popupView.findViewById(R.id.copy_linear).setOnClickListener(this); + popupView.findViewById(R.id.withdraw_linear).setOnClickListener(this); + popupView.findViewById(R.id.quote_linear).setOnClickListener(this); + long sentTime = message.getSentTime(); + } + + @Override + public void onClick(View v) { + int id = v.getId(); + //复制 + if (id == R.id.copy_linear) { + + } else if (id == R.id.withdraw_linear) {//撤回 + + } else if (id == R.id.quote_linear) {//引用 + } + } } diff --git a/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java b/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java index 378c4d185..51e411c57 100644 --- a/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java +++ b/common/src/main/java/com/yunbao/common/manager/imrongcloud/MessageIMManager.java @@ -1,5 +1,6 @@ package com.yunbao.common.manager.imrongcloud; +import android.app.Activity; import android.content.Context; import android.os.Handler; import android.text.TextUtils; @@ -9,6 +10,7 @@ import com.alibaba.fastjson.JSON; import com.google.gson.Gson; import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.ImUserInfoModel; +import com.yunbao.common.dialog.MessageLongClickPopuwindow; import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; @@ -209,13 +211,16 @@ public class MessageIMManager { private ConversationClickListener listener = new ConversationClickListener() { @Override public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String targetId) { - IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class); - long userId = IMLoginManager.get(context).getUserInfo().getId(); - if (!TextUtils.equals(model.getIsAdmin(), "1") && userId != model.getId()) { - RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 0); - } else if (userId == model.getId()) { - RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 2); + if (!TextUtils.isEmpty(userInfo.getExtra())){ + IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class); + long userId = IMLoginManager.get(context).getUserInfo().getId(); + if (!TextUtils.equals(model.getIsAdmin(), "1") && userId != model.getId()) { + RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 0); + } else if (userId == model.getId()) { + RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 2); + } } + return true; } @@ -234,7 +239,9 @@ public class MessageIMManager { */ @Override public boolean onMessageLongClick(Context context, View view, Message message) { - ToastUtil.show(message.getContent().toString()); + new MessageLongClickPopuwindow((Activity) context) + .setMessage(message) + .show(view); return true; } diff --git a/common/src/main/res/layout/view_message_long_click.xml b/common/src/main/res/layout/view_message_long_click.xml index 32f2e9f1a..7b2caea00 100644 --- a/common/src/main/res/layout/view_message_long_click.xml +++ b/common/src/main/res/layout/view_message_long_click.xml @@ -47,7 +47,7 @@ Px%rb$FWRA@u(n!k??Q545N-$bJz2oe$@3co7Fis+DNEGrU(j%+C^rA@2?ok)m8 zvs7fQAl8p|3!R|QC^aGqvHk!#a^x=a^5)IGGkNo7UcB4hbI*J~=bpLe-nk=&ys1dP znXLiFfvq)i&Pw`J)qhU_Gdlv@1vXZ7o;dC;a7fb6MEef2B7o<>(JD?WjCm&Mc!hBk z0eD1KR&km*<}q+0V|z!^`NXk*&58i5th18#)4-najx7zHl6191FwOD8PSuH zW>O&<1(0;b%vJ+0fqfa#7AMF0-gffdRE*PE~ED)om&!YX7_-z!vrwx=Yb5sWx!8qxouD> zXoU_*f;4^$)rZ^cBF&wgYc~wS%ey3z81RqMFigW?O)pz_B9x zey5N>EB8<|JmNaGrkQAmGjsD9S_yMe{F{ou+FG}*e zw64~ci|!cAyrhY;0RF3if4}$5R+H^Ba6!_GQUGpjW}ZTRi?X31g0Frwm9*IF`GtS0 eG$gvzV}Apj!el`ADz}LM0000