bugfix:1.福袋飘屏点击去围观闪退 2.重复打开私聊页没有刷新私聊用户
This commit is contained in:
@@ -5,6 +5,7 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
@@ -52,9 +53,55 @@ import java.util.Set;
|
||||
*/
|
||||
public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
|
||||
ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
||||
@Override
|
||||
public void onAddedOrUpdatedFriends(List<String> accounts) {
|
||||
setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeletedFriends(List<String> accounts) {
|
||||
setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddUserToBlackList(List<String> account) {
|
||||
// whetherBlack();
|
||||
// setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveUserFromBlackList(List<String> account) {
|
||||
//whetherBlack();
|
||||
// setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
};
|
||||
OnlineStateChangeObserver onlineStateChangeObserver = new OnlineStateChangeObserver() {
|
||||
@Override
|
||||
public void onlineStateChange(Set<String> accounts) {
|
||||
// 更新 toolbar
|
||||
if (accounts.contains(sessionId)) {
|
||||
// 按照交互来展示
|
||||
displayOnlineState();
|
||||
}
|
||||
}
|
||||
};
|
||||
private boolean isResume = false;
|
||||
/**
|
||||
* 命令消息接收观察者
|
||||
*/
|
||||
Observer<CustomNotification> commandObserver = new Observer<CustomNotification>() {
|
||||
@Override
|
||||
public void onEvent(CustomNotification message) {
|
||||
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
||||
return;
|
||||
}
|
||||
showCommandMessage(message);
|
||||
}
|
||||
};
|
||||
private View tipsLayout;
|
||||
private ImageView closeIcon;
|
||||
private UserInfoObserver uinfoObserver;
|
||||
|
||||
public static void start(Context context, String contactId) {
|
||||
Intent intent = new Intent();
|
||||
@@ -88,6 +135,21 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
displayAntiFraudTips();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
|
||||
String sessionId = intent.getStringExtra(Extras.EXTRA_ACCOUNT);
|
||||
//如果sessionId与之前的sessionId不是同一个,刷新数据
|
||||
if (!TextUtils.isEmpty(this.sessionId) && !this.sessionId.equals(sessionId)) {
|
||||
this.sessionId = sessionId;
|
||||
requestBuddyInfo();
|
||||
displayOnlineState();
|
||||
displayAntiFraudTips();
|
||||
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
||||
}
|
||||
}
|
||||
|
||||
private void displayAntiFraudTips() {
|
||||
tipsLayout = findViewById(R.id.rl_tips);
|
||||
closeIcon = findViewById(R.id.iv_close_tips);
|
||||
@@ -151,43 +213,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
NimUIKit.getContactChangedObservable().registerObserver(friendDataChangedObserver, register);
|
||||
}
|
||||
|
||||
ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
||||
@Override
|
||||
public void onAddedOrUpdatedFriends(List<String> accounts) {
|
||||
setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDeletedFriends(List<String> accounts) {
|
||||
setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAddUserToBlackList(List<String> account) {
|
||||
// whetherBlack();
|
||||
// setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRemoveUserFromBlackList(List<String> account) {
|
||||
//whetherBlack();
|
||||
// setTitle(UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P));
|
||||
}
|
||||
};
|
||||
|
||||
private UserInfoObserver uinfoObserver;
|
||||
|
||||
OnlineStateChangeObserver onlineStateChangeObserver = new OnlineStateChangeObserver() {
|
||||
@Override
|
||||
public void onlineStateChange(Set<String> accounts) {
|
||||
// 更新 toolbar
|
||||
if (accounts.contains(sessionId)) {
|
||||
// 按照交互来展示
|
||||
displayOnlineState();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void registerOnlineStateChangeListener(boolean register) {
|
||||
if (!NimUIKitImpl.enableOnlineState()) {
|
||||
return;
|
||||
@@ -223,19 +248,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 命令消息接收观察者
|
||||
*/
|
||||
Observer<CustomNotification> commandObserver = new Observer<CustomNotification>() {
|
||||
@Override
|
||||
public void onEvent(CustomNotification message) {
|
||||
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
||||
return;
|
||||
}
|
||||
showCommandMessage(message);
|
||||
}
|
||||
};
|
||||
|
||||
protected void showCommandMessage(CustomNotification message) {
|
||||
if (!isResume) {
|
||||
return;
|
||||
@@ -259,8 +271,8 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageFragment fragment() {
|
||||
Bundle arguments = getIntent().getExtras();
|
||||
protected MessageFragment fragment(Intent intent) {
|
||||
Bundle arguments = intent.getExtras();
|
||||
if (arguments == null) {
|
||||
arguments = new Bundle();
|
||||
}
|
||||
|
Reference in New Issue
Block a user