This commit is contained in:
18401019693 2022-07-27 13:48:58 +08:00
parent 838ae0815b
commit 5c42767ea3
5 changed files with 71 additions and 12 deletions

View File

@ -1,21 +1,27 @@
package com.yunbao.common.dialog; package com.yunbao.common.dialog;
import android.app.Activity; import android.app.Activity;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout; import android.widget.LinearLayout;
import android.widget.PopupWindow; import android.widget.PopupWindow;
import com.yunbao.common.R; import com.yunbao.common.R;
import io.rong.imlib.model.Message;
/** /**
* 消息長按彈窗 * 消息長按彈窗
*/ */
public class MessageLongClickPopuwindow { public class MessageLongClickPopuwindow implements View.OnClickListener {
private Activity mContext; private Activity mContext;
private View popupView; private View popupView;
private PopupWindow popupWindow; private PopupWindow popupWindow;
private LinearLayout copyLinear; private LinearLayout copyLinear;
private Message message;
public MessageLongClickPopuwindow(Activity context) { public MessageLongClickPopuwindow(Activity context) {
this.mContext = context; this.mContext = context;
@ -23,6 +29,48 @@ public class MessageLongClickPopuwindow {
initView(); 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() { 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) {//引用
}
} }
} }

View File

@ -1,5 +1,6 @@
package com.yunbao.common.manager.imrongcloud; package com.yunbao.common.manager.imrongcloud;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.os.Handler; import android.os.Handler;
import android.text.TextUtils; import android.text.TextUtils;
@ -9,6 +10,7 @@ import com.alibaba.fastjson.JSON;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.yunbao.common.bean.IMLoginModel; import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.ImUserInfoModel; import com.yunbao.common.bean.ImUserInfoModel;
import com.yunbao.common.dialog.MessageLongClickPopuwindow;
import com.yunbao.common.event.MessageIMEvent; import com.yunbao.common.event.MessageIMEvent;
import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
@ -209,13 +211,16 @@ public class MessageIMManager {
private ConversationClickListener listener = new ConversationClickListener() { private ConversationClickListener listener = new ConversationClickListener() {
@Override @Override
public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String targetId) { public boolean onUserPortraitClick(Context context, Conversation.ConversationType conversationType, UserInfo userInfo, String targetId) {
IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class); if (!TextUtils.isEmpty(userInfo.getExtra())){
long userId = IMLoginManager.get(context).getUserInfo().getId(); IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class);
if (!TextUtils.equals(model.getIsAdmin(), "1") && userId != model.getId()) { long userId = IMLoginManager.get(context).getUserInfo().getId();
RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 0); if (!TextUtils.equals(model.getIsAdmin(), "1") && userId != model.getId()) {
} else if (userId == model.getId()) { RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 0);
RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 2); } else if (userId == model.getId()) {
RouteUtil.forwardUserHome(mContext, userInfo.getUserId(), 2);
}
} }
return true; return true;
} }
@ -234,7 +239,9 @@ public class MessageIMManager {
*/ */
@Override @Override
public boolean onMessageLongClick(Context context, View view, Message message) { public boolean onMessageLongClick(Context context, View view, Message message) {
ToastUtil.show(message.getContent().toString()); new MessageLongClickPopuwindow((Activity) context)
.setMessage(message)
.show(view);
return true; return true;
} }

View File

@ -47,7 +47,7 @@
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:drawableTop="@mipmap/icon_message_copy" android:drawableTop="@mipmap/icon_message_withdraw"
android:drawablePadding="5dp" android:drawablePadding="5dp"
android:text="@string/withdraw" android:text="@string/withdraw"
android:textColor="@color/white" android:textColor="@color/white"
@ -56,6 +56,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/quote_linear"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_weight="1" android:layout_weight="1"
android:layout_height="wrap_content" android:layout_height="wrap_content"

Binary file not shown.

After

Width:  |  Height:  |  Size: 748 B

View File

@ -164,11 +164,14 @@ public class ConversationIMListManager {
public boolean onConversationPortraitClick(Context context, Conversation.ConversationType conversationType, String targetId) { public boolean onConversationPortraitClick(Context context, Conversation.ConversationType conversationType, String targetId) {
//非指导员都可以点击 //非指导员都可以点击
UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId); UserInfo userInfo = RongUserInfoManager.getInstance().getUserInfo(targetId);
IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class); if (userInfo!=null&&!TextUtils.isEmpty(userInfo.getExtra())){
if (!TextUtils.equals(model.getIsAdmin(), "1")) { IMLoginModel model = new Gson().fromJson(userInfo.getExtra(), IMLoginModel.class);
RouteUtil.forwardUserHome(mContext, targetId, 0); if (!TextUtils.equals(model.getIsAdmin(), "1")) {
RouteUtil.forwardUserHome(mContext, targetId, 0);
}
} }
return true; return true;
} }