11111
This commit is contained in:
parent
aac51d423c
commit
88278df77d
@ -1,7 +1,10 @@
|
|||||||
package com.yunbao.common.dialog;
|
package com.yunbao.common.dialog;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
|
import android.content.ClipData;
|
||||||
|
import android.content.ClipboardManager;
|
||||||
import android.graphics.drawable.BitmapDrawable;
|
import android.graphics.drawable.BitmapDrawable;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.Gravity;
|
import android.view.Gravity;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@ -10,8 +13,18 @@ import android.widget.LinearLayout;
|
|||||||
import android.widget.PopupWindow;
|
import android.widget.PopupWindow;
|
||||||
|
|
||||||
import com.yunbao.common.R;
|
import com.yunbao.common.R;
|
||||||
|
import com.yunbao.common.bean.IMLoginModel;
|
||||||
|
import com.yunbao.common.manager.IMLoginManager;
|
||||||
|
import com.yunbao.common.utils.ToastUtil;
|
||||||
|
|
||||||
|
import io.rong.imkit.IMCenter;
|
||||||
|
import io.rong.imlib.RongIMClient;
|
||||||
import io.rong.imlib.model.Message;
|
import io.rong.imlib.model.Message;
|
||||||
|
import io.rong.message.RecallNotificationMessage;
|
||||||
|
import io.rong.message.TextMessage;
|
||||||
|
|
||||||
|
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||||
|
import static com.yunbao.common.utils.WordUtil.getString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 消息長按彈窗
|
* 消息長按彈窗
|
||||||
@ -20,7 +33,7 @@ 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, withdrawLinear, quoteLinear;
|
||||||
private Message message;
|
private Message message;
|
||||||
|
|
||||||
public MessageLongClickPopuwindow(Activity context) {
|
public MessageLongClickPopuwindow(Activity context) {
|
||||||
@ -31,6 +44,24 @@ public class MessageLongClickPopuwindow implements View.OnClickListener {
|
|||||||
|
|
||||||
public MessageLongClickPopuwindow setMessage(Message message) {
|
public MessageLongClickPopuwindow setMessage(Message message) {
|
||||||
this.message = message;
|
this.message = message;
|
||||||
|
long sentTime = message.getSentTime();
|
||||||
|
Log.e("MessageLongClick ", "sentTime:" + sentTime);
|
||||||
|
Log.e("MessageLongClick ", "currentTimeMillis:" + System.currentTimeMillis());
|
||||||
|
Log.e("MessageLongClick ", "秒:" + ((System.currentTimeMillis() - sentTime) / 1000));
|
||||||
|
//超过俩分钟无法撤回
|
||||||
|
if (((System.currentTimeMillis() - sentTime) / 1000) > 120) {
|
||||||
|
withdrawLinear.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
//只可以撤回自己的消息
|
||||||
|
IMLoginModel model = IMLoginManager.get(mContext).getUserInfo();
|
||||||
|
if (!message.getSenderUserId().equals(String.valueOf(model.getId()))) {
|
||||||
|
withdrawLinear.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
//非文字信息无法复制
|
||||||
|
if (!message.getObjectName().equals("RC:TxtMsg")) {
|
||||||
|
copyLinear.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,10 +86,13 @@ public class MessageLongClickPopuwindow implements View.OnClickListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initView() {
|
private void initView() {
|
||||||
popupView.findViewById(R.id.copy_linear).setOnClickListener(this);
|
copyLinear = popupView.findViewById(R.id.copy_linear);
|
||||||
popupView.findViewById(R.id.withdraw_linear).setOnClickListener(this);
|
copyLinear.setOnClickListener(this);
|
||||||
popupView.findViewById(R.id.quote_linear).setOnClickListener(this);
|
withdrawLinear = popupView.findViewById(R.id.withdraw_linear);
|
||||||
long sentTime = message.getSentTime();
|
withdrawLinear.setOnClickListener(this);
|
||||||
|
quoteLinear = popupView.findViewById(R.id.quote_linear);
|
||||||
|
quoteLinear.setOnClickListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -66,11 +100,44 @@ public class MessageLongClickPopuwindow implements View.OnClickListener {
|
|||||||
int id = v.getId();
|
int id = v.getId();
|
||||||
//复制
|
//复制
|
||||||
if (id == R.id.copy_linear) {
|
if (id == R.id.copy_linear) {
|
||||||
|
copyMethod();
|
||||||
|
popupWindow.dismiss();
|
||||||
} else if (id == R.id.withdraw_linear) {//撤回
|
} else if (id == R.id.withdraw_linear) {//撤回
|
||||||
|
withdrawMethod();
|
||||||
|
popupWindow.dismiss();
|
||||||
} else if (id == R.id.quote_linear) {//引用
|
} else if (id == R.id.quote_linear) {//引用
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyMethod() {
|
||||||
|
//文字消息支持复制
|
||||||
|
if (message.getContent() instanceof TextMessage) {
|
||||||
|
String content = ((TextMessage) message.getContent()).getContent();
|
||||||
|
ClipboardManager cm = (ClipboardManager) mContext.getSystemService(CLIPBOARD_SERVICE);
|
||||||
|
ClipData clipData = ClipData.newPlainText("text", content);
|
||||||
|
cm.setPrimaryClip(clipData);
|
||||||
|
ToastUtil.show(getString(R.string.copy_success));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 撤回消息
|
||||||
|
*/
|
||||||
|
private void withdrawMethod() {
|
||||||
|
IMCenter.getInstance().recallMessage(message, "撤回成功", new RongIMClient.ResultCallback<RecallNotificationMessage>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(RecallNotificationMessage recallNotificationMessage) {
|
||||||
|
ToastUtil.show(getString(R.string.withdraw_success));
|
||||||
|
//删除草稿信息
|
||||||
|
IMCenter.getInstance().clearTextMessageDraft(message.getConversationType(), message.getTargetId(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||||
|
ToastUtil.show(errorCode.msg);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -850,4 +850,5 @@
|
|||||||
<string name="exclusive_instructor1">聯系您的專屬指導員</string>
|
<string name="exclusive_instructor1">聯系您的專屬指導員</string>
|
||||||
<string name="exclusive_instructor2">給您匹配更多風格的主播唷!</string>
|
<string name="exclusive_instructor2">給您匹配更多風格的主播唷!</string>
|
||||||
<string name="hurry_contact">趕快聯系他/她吧!</string>
|
<string name="hurry_contact">趕快聯系他/她吧!</string>
|
||||||
|
<string name="withdraw_success">撤回成功</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -40,8 +40,13 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import io.rong.imkit.IMCenter;
|
||||||
|
import io.rong.imkit.model.ResultCallback;
|
||||||
import io.rong.imkit.userinfo.RongUserInfoManager;
|
import io.rong.imkit.userinfo.RongUserInfoManager;
|
||||||
|
import io.rong.imlib.RongIMClient;
|
||||||
|
import io.rong.imlib.model.Conversation;
|
||||||
import io.rong.imlib.model.UserInfo;
|
import io.rong.imlib.model.UserInfo;
|
||||||
|
import okhttp3.internal.http2.ErrorCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 聊天会话界面
|
* 聊天会话界面
|
||||||
@ -109,7 +114,7 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
titleView.setText("系統消息");
|
titleView.setText("系統消息");
|
||||||
inputPanel.setVisibility(View.GONE);
|
inputPanel.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
getDraft();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,6 +188,23 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取草稿箱信息系
|
||||||
|
*/
|
||||||
|
private void getDraft() {
|
||||||
|
RongIMClient.getInstance().getTextMessageDraft(Conversation.ConversationType.PRIVATE, targetId, new RongIMClient.ResultCallback<String>() {
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String s) {
|
||||||
|
inputPanel.setPresetInformation(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(RongIMClient.ErrorCode errorCode) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
@ -205,6 +227,12 @@ public class PDLiveConversationActivity extends AbsActivity implements View.OnCl
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
|
//获取输入框信息存进输入框
|
||||||
|
String content = inputPanel.getPresetInformation();
|
||||||
|
if (!TextUtils.isEmpty(content)){
|
||||||
|
IMCenter.getInstance().saveTextMessageDraft(Conversation.ConversationType.PRIVATE, targetId, content, null);
|
||||||
|
}
|
||||||
|
|
||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,6 +54,13 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取输入框信息
|
||||||
|
*/
|
||||||
|
public String getPresetInformation() {
|
||||||
|
return editBtn.getText().toString().trim();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 必传字段
|
* 必传字段
|
||||||
*
|
*
|
||||||
@ -157,7 +164,7 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(Message message) {
|
public void onSuccess(Message message) {
|
||||||
|
IMCenter.getInstance().clearTextMessageDraft(Conversation.ConversationType.PRIVATE, targetId, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -185,7 +192,6 @@ public class InputPanelViewHolder extends LinearLayout implements View.OnClickLi
|
|||||||
inputPanelSendBtn.setBackground(getResources().getDrawable(R.mipmap.btn_sand1));
|
inputPanelSendBtn.setBackground(getResources().getDrawable(R.mipmap.btn_sand1));
|
||||||
} else {
|
} else {
|
||||||
isSend = false;
|
isSend = false;
|
||||||
IMCenter.getInstance().saveTextMessageDraft(types, targetId, editBtn.getText().toString(), null);
|
|
||||||
inputPanelSendBtn.setBackground(getResources().getDrawable(R.mipmap.btn_sand));
|
inputPanelSendBtn.setBackground(getResources().getDrawable(R.mipmap.btn_sand));
|
||||||
}
|
}
|
||||||
int offset;
|
int offset;
|
||||||
|
Loading…
Reference in New Issue
Block a user