[Modify]消息添加滑动到对应位置和移除非好友提示
This commit is contained in:
@@ -65,6 +65,8 @@ import com.netease.nimlib.sdk.robot.model.RobotMsgType;
|
||||
import com.netease.nimlib.sdk.team.constant.TeamMemberType;
|
||||
import com.netease.nimlib.sdk.team.model.TeamMember;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.xchat_android_core.module_hall.im.HallAttachment;
|
||||
import com.yizhuan.xchat_android_core.module_hall.im.HallImMsgInfo;
|
||||
import com.yizhuan.xchat_android_core.room.event.MessageSizeEvent;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
|
||||
@@ -111,6 +113,8 @@ public class MessageListPanelEx {
|
||||
private boolean recordOnly;
|
||||
// 从服务器拉取消息记录
|
||||
private boolean remote;
|
||||
// recordId,记录当前消息id
|
||||
private String recordId;
|
||||
// 语音转文字
|
||||
private VoiceTrans voiceTrans;
|
||||
// 待转发消息
|
||||
@@ -119,7 +123,6 @@ public class MessageListPanelEx {
|
||||
private OnItemClickListener listener = new OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(IRecyclerView adapter, View view, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,6 +237,16 @@ public class MessageListPanelEx {
|
||||
init(anchor);
|
||||
}
|
||||
|
||||
public MessageListPanelEx(Container container, View rootView, IMMessage anchor, boolean recordOnly, boolean remote, String recordId) {
|
||||
this.container = container;
|
||||
this.rootView = rootView;
|
||||
this.recordOnly = recordOnly;
|
||||
this.remote = remote;
|
||||
this.recordId = recordId;
|
||||
|
||||
init(anchor);
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
setEarPhoneMode(UserPreferences.isEarPhoneModeEnable(), false);
|
||||
}
|
||||
@@ -309,13 +322,6 @@ public class MessageListPanelEx {
|
||||
initFetchLoadListener(anchor);
|
||||
messageListView.setAdapter(adapter);
|
||||
messageListView.addOnItemTouchListener(listener);
|
||||
|
||||
messageListView.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
messageListView.smoothScrollToPosition(0);
|
||||
}
|
||||
},3000);
|
||||
}
|
||||
|
||||
public boolean isSessionMode() {
|
||||
@@ -511,6 +517,27 @@ public class MessageListPanelEx {
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getApplyItemIndex(String recordId) {
|
||||
for (int i = 0; i < items.size(); i++) {
|
||||
IMMessage message = items.get(i);
|
||||
if (message.getMsgType() == MsgTypeEnum.custom && message.getAttachment() != null) {
|
||||
if (message.getAttachment() instanceof HallAttachment) {
|
||||
HallAttachment attachment = (HallAttachment) message.getAttachment();
|
||||
HallImMsgInfo info = attachment.getHallImMsgInfo();
|
||||
if (info != null) {
|
||||
Uri uri = Uri.parse(info.getUrl());
|
||||
String record = uri.getQueryParameter("recordId");
|
||||
if (recordId.equals(record)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setChattingBackground(String uriString, int color) {
|
||||
if (uriString != null) {
|
||||
Uri uri = Uri.parse(uriString);
|
||||
@@ -906,11 +933,26 @@ public class MessageListPanelEx {
|
||||
if (firstLoad) {
|
||||
doScrollToBottom();
|
||||
sendReceipt(); // 发送已读回执
|
||||
if (!TextUtils.isEmpty(recordId)) {
|
||||
doScrollToPosition();
|
||||
}
|
||||
}
|
||||
|
||||
firstLoad = false;
|
||||
}
|
||||
|
||||
private void doScrollToPosition() {
|
||||
uiHandler.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int index = getApplyItemIndex(recordId);
|
||||
if (index >= 0 && index < items.size()) {
|
||||
messageListView.scrollToPosition(index);
|
||||
}
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
private void onAnchorContextMessageLoaded(final List<IMMessage> messages) {
|
||||
if (messages == null) {
|
||||
return;
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.yizhuan.erban.ui.im.avtivity;
|
||||
|
||||
import static com.netease.nim.uikit.business.session.constant.Extras.EXTRA_RECORDID;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -140,6 +142,12 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
public static void startRecord(Context context, String contactId, String recordId) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra(EXTRA_RECORDID, recordId);
|
||||
startReal(context, contactId, intent);
|
||||
}
|
||||
|
||||
public static void start(Context context, String contactId, String gameId) {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("gameId", gameId);
|
||||
@@ -198,9 +206,6 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
if (buddyUserInfo != null && buddyUserInfo.isBanAccount()) {
|
||||
tipsLayout.setVisibility(View.VISIBLE);
|
||||
tvTips.setText(ResUtil.getString(R.string.im_avtivity_nimp2pmessageactivity_01));
|
||||
} else if (shouldDisplayAntiFraudTips()) {
|
||||
tipsLayout.setVisibility(View.VISIBLE);
|
||||
tvTips.setText(ResUtil.getString(R.string.im_avtivity_nimp2pmessageactivity_02));
|
||||
} else {
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
@@ -412,6 +417,10 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
if (!TextUtils.isEmpty(gameId)) {
|
||||
arguments.putString("gameId", gameId);
|
||||
}
|
||||
String recordId = intent.getStringExtra(EXTRA_RECORDID);
|
||||
if (!TextUtils.isEmpty(recordId)) {
|
||||
arguments.putString(EXTRA_RECORDID, recordId);
|
||||
}
|
||||
MessageFragment fragment = new MessageFragment();
|
||||
fragment.setArguments(arguments);
|
||||
fragment.setContainerId(R.id.message_fragment_container);
|
||||
|
@@ -104,6 +104,8 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
protected InputPanel inputPanel;
|
||||
protected MessageListPanelEx messageListPanel;
|
||||
protected AitManager aitManager;
|
||||
protected String recordId = "";
|
||||
|
||||
/**
|
||||
* 消息接收观察者
|
||||
*/
|
||||
@@ -219,6 +221,7 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
}
|
||||
|
||||
private void parseIntent() {
|
||||
recordId = getArguments() != null ? getArguments().getString(Extras.EXTRA_RECORDID) : "";
|
||||
sessionId = getArguments().getString(Extras.EXTRA_ACCOUNT);
|
||||
ChatterBoxHelper.reset();
|
||||
ChatterBoxHelper.sessionId = sessionId;
|
||||
@@ -229,7 +232,11 @@ public class MessageFragment extends TFragment implements ModuleProxy, MessageLi
|
||||
Container container = new Container(getActivity(), sessionId, sessionType, this);
|
||||
|
||||
if (messageListPanel == null) {
|
||||
messageListPanel = new MessageListPanelEx(container, rootView, anchor, false, false);
|
||||
if (!TextUtils.isEmpty(recordId)) {
|
||||
messageListPanel = new MessageListPanelEx(container, rootView, anchor, false, false, recordId);
|
||||
} else {
|
||||
messageListPanel = new MessageListPanelEx(container, rootView, anchor, false, false);
|
||||
}
|
||||
} else {
|
||||
messageListPanel.reload(container, anchor);
|
||||
}
|
||||
|
@@ -124,7 +124,7 @@ public class SearchDetailFragment extends BaseMvpFragment<ISearchView, SearchPre
|
||||
if (item.getHallBtnStatus() == 5) {
|
||||
toast(getString(R.string.invite_has_been_send));
|
||||
} else if (item.getHallBtnStatus() == 6) {
|
||||
NimP2PMessageActivity.start(mContext, String.valueOf(item.getHallMessageUid()));
|
||||
NimP2PMessageActivity.startRecord(mContext, String.valueOf(item.getHallMessageUid()), String.valueOf(item.getHallRecordId()));
|
||||
} else if (item.getHallBtnStatus() == 4) {
|
||||
showSureDialog(item.getUid() + "", item.getAvatar(), item.getNick(), position);
|
||||
}
|
||||
|
@@ -154,15 +154,16 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
private void displayAntiFraudTips() {
|
||||
tipsLayout = findViewById(R.id.rl_tips);
|
||||
closeIcon = findViewById(R.id.iv_close_tips);
|
||||
if (shouldDisplayAntiFraudTips()) {
|
||||
tipsLayout.setVisibility(View.VISIBLE);
|
||||
closeIcon.setOnClickListener(view -> {
|
||||
IMFriendModel.get().addCloseTipsAccount(sessionId);
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
});
|
||||
} else {
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
}
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
// if (shouldDisplayAntiFraudTips()) {
|
||||
// tipsLayout.setVisibility(View.VISIBLE);
|
||||
// closeIcon.setOnClickListener(view -> {
|
||||
// IMFriendModel.get().addCloseTipsAccount(sessionId);
|
||||
// tipsLayout.setVisibility(View.GONE);
|
||||
// });
|
||||
// } else {
|
||||
// tipsLayout.setVisibility(View.GONE);
|
||||
// }
|
||||
findViewById(R.id.root_view).setOnClickListener(view -> {
|
||||
EventBus.getDefault().post(new ClickRootViewEvent());
|
||||
finish();
|
||||
|
@@ -28,6 +28,7 @@ public interface Extras {
|
||||
String EXTRA_ACCOUNT = "account";
|
||||
String EXTRA_TYPE = "type";
|
||||
String EXTRA_ANCHOR = "anchor";
|
||||
String EXTRA_RECORDID = "recordId";
|
||||
|
||||
String EXTRA_CUSTOMIZATION = "customization";
|
||||
String EXTRA_IS_IN_TEAM = "isInTeam";
|
||||
|
Reference in New Issue
Block a user