私聊改造:UI完善,私聊页代码精简
This commit is contained in:
@@ -616,7 +616,7 @@ public class VoiceMatchActivity extends BaseActivity implements View.OnClickList
|
|||||||
}
|
}
|
||||||
if (error == null) {
|
if (error == null) {
|
||||||
if (isRight) {
|
if (isRight) {
|
||||||
NimP2PMessageActivity.start(context, String.valueOf(info.getUid()), true);
|
NimP2PMessageActivity.start(context, String.valueOf(info.getUid()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
package com.mango.moshen.ui.im.avtivity;
|
package com.mango.moshen.ui.im.avtivity;
|
||||||
|
|
||||||
|
import static com.mango.moshen.ui.im.recent.RecentContactsFragment.RECENT_TAG_STICKY;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -10,8 +12,9 @@ import android.widget.ImageView;
|
|||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import com.netease.nim.uikit.StatusBarUtil;
|
import com.mango.core.decoration.headwear.bean.HeadWearInfo;
|
||||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
import com.mango.core.noble.NobleUtil;
|
||||||
|
import com.mango.core.user.UserModel;
|
||||||
import com.mango.moshen.R;
|
import com.mango.moshen.R;
|
||||||
import com.mango.moshen.UIHelper;
|
import com.mango.moshen.UIHelper;
|
||||||
import com.mango.moshen.base.BaseMvpActivity;
|
import com.mango.moshen.base.BaseMvpActivity;
|
||||||
@@ -20,11 +23,15 @@ import com.mango.moshen.ui.user.UserInfoActivity;
|
|||||||
import com.mango.moshen.ui.utils.ImageLoadUtils;
|
import com.mango.moshen.ui.utils.ImageLoadUtils;
|
||||||
import com.mango.moshen.utils.RegexUtil;
|
import com.mango.moshen.utils.RegexUtil;
|
||||||
import com.mango.xchat_android_constants.XChatConstants;
|
import com.mango.xchat_android_constants.XChatConstants;
|
||||||
import com.mango.core.user.UserModel;
|
|
||||||
import com.mango.xchat_android_library.base.factory.CreatePresenter;
|
import com.mango.xchat_android_library.base.factory.CreatePresenter;
|
||||||
import com.mango.xchat_android_library.utils.JavaUtil;
|
import com.mango.xchat_android_library.utils.JavaUtil;
|
||||||
|
import com.mango.xchat_android_library.widget.IOSSwitchView;
|
||||||
import java.util.List;
|
import com.netease.nim.uikit.StatusBarUtil;
|
||||||
|
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||||
|
import com.netease.nimlib.sdk.NIMClient;
|
||||||
|
import com.netease.nimlib.sdk.msg.MsgService;
|
||||||
|
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||||
|
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Administrator
|
* @author Administrator
|
||||||
@@ -39,6 +46,9 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
private TextView tvAddBlackList;
|
private TextView tvAddBlackList;
|
||||||
private TextView tvName;
|
private TextView tvName;
|
||||||
private ImageView ivAvatar;
|
private ImageView ivAvatar;
|
||||||
|
private ImageView ivHeadWear;
|
||||||
|
private IOSSwitchView switchTop;
|
||||||
|
private IOSSwitchView switchAddBlack;
|
||||||
|
|
||||||
public static void start(Context context, String contactId) {
|
public static void start(Context context, String contactId) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
@@ -52,26 +62,61 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(R.layout.activity_nim_add_black_list);
|
setContentView(R.layout.activity_nim_add_black_list);
|
||||||
|
|
||||||
initWhiteTitleBar("聊天设置");
|
initWhiteTitleBar("聊天设置");
|
||||||
|
initView();
|
||||||
account = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
account = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
||||||
if (TextUtils.isEmpty(account)) account = "0";
|
if (TextUtils.isEmpty(account)) account = "0";
|
||||||
|
rlContent.setOnClickListener(this);
|
||||||
|
tvAddBlackList.setOnClickListener(this);
|
||||||
|
findViewById(R.id.tv_report).setOnClickListener(this);
|
||||||
|
changeText(NimFriendModel.get().isInMyBlackList(account));
|
||||||
|
initTarget();
|
||||||
|
switchAddBlack.setOnSwitchStateChangeListener(isOn -> {
|
||||||
|
if (isOn) {
|
||||||
|
ensureAddToBlackList();
|
||||||
|
} else {
|
||||||
|
ensureRemoveFromBlackList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
RecentContact recentContact = NIMClient.getService(MsgService.class)
|
||||||
|
.queryRecentContact(account, SessionTypeEnum.P2P);
|
||||||
|
if (recentContact != null) {
|
||||||
|
switchTop.setOn(recentContact.getTag() == RECENT_TAG_STICKY, false);
|
||||||
|
switchTop.setOnSwitchStateChangeListener(isOn -> {
|
||||||
|
if (isOn) {
|
||||||
|
addTag(recentContact, RECENT_TAG_STICKY);
|
||||||
|
} else {
|
||||||
|
removeTag(recentContact, RECENT_TAG_STICKY);
|
||||||
|
}
|
||||||
|
NIMClient.getService(MsgService.class).updateRecentAndNotify(recentContact);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTag(RecentContact recent, long tag) {
|
||||||
|
tag = recent.getTag() | tag;
|
||||||
|
recent.setTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeTag(RecentContact recent, long tag) {
|
||||||
|
tag = recent.getTag() & ~tag;
|
||||||
|
recent.setTag(tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initView() {
|
||||||
rlContent = findViewById(R.id.rl_content);
|
rlContent = findViewById(R.id.rl_content);
|
||||||
tvName = findViewById(R.id.tv_name);
|
tvName = findViewById(R.id.tv_name);
|
||||||
tvAddBlackList = findViewById(R.id.tv_add_black_list);
|
tvAddBlackList = findViewById(R.id.tv_add_black_list);
|
||||||
ivAvatar = findViewById(R.id.iv_avatar);
|
ivAvatar = findViewById(R.id.iv_avatar);
|
||||||
rlContent.setOnClickListener(this);
|
switchTop = findViewById(R.id.switch_top);
|
||||||
tvAddBlackList.setOnClickListener(this);
|
switchAddBlack = findViewById(R.id.switch_add_black);
|
||||||
findViewById(R.id.tv_report).setOnClickListener(this);
|
ivHeadWear = findViewById(R.id.iv_head_wear);
|
||||||
List<String> blackListAccount = NimFriendModel.get().getMyBlackListAccount();
|
|
||||||
if (blackListAccount != null) changeText(blackListAccount.contains(account));
|
|
||||||
initTarget();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeText(boolean contains) {
|
void changeText(boolean contains) {
|
||||||
tvAddBlackList.setText(contains ? "移除黑名单" : "加入黑名单");
|
switchAddBlack.setOn(contains, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,11 +124,22 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
*/
|
*/
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
private void initTarget() {
|
private void initTarget() {
|
||||||
UserModel.get().getUserInfo(Long.valueOf(account)).subscribe(userInfo -> {
|
UserModel.get()
|
||||||
|
.getUserInfo(Long.parseLong(account))
|
||||||
|
.subscribe(userInfo -> {
|
||||||
// 头像
|
// 头像
|
||||||
ImageLoadUtils.loadAvatar(AddBlackListActivity.this, userInfo.getAvatar(), ivAvatar, true);
|
ImageLoadUtils.loadAvatar(AddBlackListActivity.this, userInfo.getAvatar(), ivAvatar, true);
|
||||||
// 名字
|
// 名字
|
||||||
tvName.setText(RegexUtil.getPrintableString(userInfo.getNick()));
|
tvName.setText(RegexUtil.getPrintableString(userInfo.getNick()));
|
||||||
|
HeadWearInfo headWearInfo = userInfo.getUserHeadwear();
|
||||||
|
if (headWearInfo != null && !TextUtils.isEmpty(headWearInfo.getPic())) {
|
||||||
|
NobleUtil.loadHeadWear(
|
||||||
|
headWearInfo.getEffect() != null ? headWearInfo.getEffect() : headWearInfo.getPic(),
|
||||||
|
ivHeadWear
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ivHeadWear.setImageResource(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -93,17 +149,6 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
if (v.getId() == R.id.rl_content) {
|
if (v.getId() == R.id.rl_content) {
|
||||||
if (!TextUtils.isEmpty(account))
|
if (!TextUtils.isEmpty(account))
|
||||||
UserInfoActivity.Companion.start(this, Long.parseLong(account));
|
UserInfoActivity.Companion.start(this, Long.parseLong(account));
|
||||||
} else if (v.getId() == R.id.tv_add_black_list) {
|
|
||||||
try {
|
|
||||||
boolean contains = NimFriendModel.get().getMyBlackListAccount().contains(account);
|
|
||||||
if (!contains){
|
|
||||||
ensureAddToBlackList();
|
|
||||||
} else{
|
|
||||||
ensureRemoveFromBlackList();
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else if (v.getId() == R.id.tv_report) {
|
} else if (v.getId() == R.id.tv_report) {
|
||||||
UIHelper.showReportPage(context, JavaUtil.str2long(account), XChatConstants.REPORT_TYPE_CHAT);
|
UIHelper.showReportPage(context, JavaUtil.str2long(account), XChatConstants.REPORT_TYPE_CHAT);
|
||||||
}
|
}
|
||||||
@@ -116,6 +161,11 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
public void onOk() {
|
public void onOk() {
|
||||||
getMvpPresenter().removeFromBlackList(account);
|
getMvpPresenter().removeFromBlackList(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancel() {
|
||||||
|
changeText(true);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,6 +176,11 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
public void onOk() {
|
public void onOk() {
|
||||||
getMvpPresenter().addToBlackList(account);
|
getMvpPresenter().addToBlackList(account);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCancel() {
|
||||||
|
changeText(false);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -152,4 +207,6 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
|||||||
StatusBarUtil.transparencyBar(this);
|
StatusBarUtil.transparencyBar(this);
|
||||||
StatusBarUtil.StatusBarLightMode(this);
|
StatusBarUtil.StatusBarLightMode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -1,31 +1,15 @@
|
|||||||
package com.mango.moshen.ui.im.avtivity;
|
package com.mango.moshen.ui.im.avtivity;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
|
||||||
import androidx.fragment.app.FragmentManager;
|
import androidx.fragment.app.FragmentManager;
|
||||||
import androidx.fragment.app.FragmentTransaction;
|
import androidx.fragment.app.FragmentTransaction;
|
||||||
import androidx.appcompat.widget.Toolbar;
|
|
||||||
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.LayoutInflater;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
|
|
||||||
import com.netease.nim.uikit.R;
|
|
||||||
import com.netease.nim.uikit.api.model.session.SessionCustomization;
|
|
||||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
|
||||||
import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
|
||||||
import com.netease.nim.uikit.common.fragment.TFragment;
|
|
||||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
|
||||||
import com.mango.moshen.base.BaseActivity;
|
import com.mango.moshen.base.BaseActivity;
|
||||||
import com.mango.moshen.ui.im.fragment.MessageFragment;
|
import com.mango.moshen.ui.im.fragment.MessageFragment;
|
||||||
|
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||||
import java.util.List;
|
import com.netease.nim.uikit.common.fragment.TFragment;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by zhoujianghua on 2015/9/10.
|
* Created by zhoujianghua on 2015/9/10.
|
||||||
@@ -36,22 +20,16 @@ public abstract class NewBaseMessageActivity extends BaseActivity {
|
|||||||
|
|
||||||
protected String sessionId;
|
protected String sessionId;
|
||||||
protected MessageFragment messageFragment;
|
protected MessageFragment messageFragment;
|
||||||
private SessionCustomization customization;
|
|
||||||
private Toolbar toolbar;
|
|
||||||
|
|
||||||
protected abstract MessageFragment fragment(Intent intent);
|
protected abstract MessageFragment fragment(Intent intent);
|
||||||
|
|
||||||
protected abstract int getContentViewId();
|
protected abstract int getContentViewId();
|
||||||
|
|
||||||
protected abstract void initToolBar();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
setContentView(getContentViewId());
|
setContentView(getContentViewId());
|
||||||
initToolBar();
|
|
||||||
parseIntent();
|
parseIntent();
|
||||||
|
|
||||||
messageFragment = (MessageFragment) switchContent(fragment(getIntent()));
|
messageFragment = (MessageFragment) switchContent(fragment(getIntent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,49 +62,10 @@ public abstract class NewBaseMessageActivity extends BaseActivity {
|
|||||||
if (messageFragment != null) {
|
if (messageFragment != null) {
|
||||||
messageFragment.onActivityResult(requestCode, resultCode, data);
|
messageFragment.onActivityResult(requestCode, resultCode, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customization != null) {
|
|
||||||
customization.onActivityResult(this, requestCode, resultCode, data);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void parseIntent() {
|
private void parseIntent() {
|
||||||
sessionId = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
sessionId = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
||||||
customization = (SessionCustomization) getIntent().getSerializableExtra(Extras.EXTRA_CUSTOMIZATION);
|
|
||||||
|
|
||||||
if (customization != null) {
|
|
||||||
addRightCustomViewOnActionBar(this, customization.buttons);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 添加action bar的右侧按钮及响应事件
|
|
||||||
private void addRightCustomViewOnActionBar(Activity activity, List<SessionCustomization.OptionsButton> buttons) {
|
|
||||||
if (buttons == null || buttons.size() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Toolbar toolbar = getToolBar();
|
|
||||||
if (toolbar == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
LinearLayout view = (LinearLayout) LayoutInflater.from(activity).inflate(R.layout.nim_action_bar_custom_view, null);
|
|
||||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
|
||||||
for (final SessionCustomization.OptionsButton button : buttons) {
|
|
||||||
ImageView imageView = new ImageView(activity);
|
|
||||||
imageView.setImageResource(button.iconId);
|
|
||||||
imageView.setBackgroundResource(R.drawable.nim_nim_action_bar_button_selector);
|
|
||||||
imageView.setPadding(ScreenUtil.dip2px(10), 0, ScreenUtil.dip2px(10), 0);
|
|
||||||
imageView.setOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
button.onClick(NewBaseMessageActivity.this, v, sessionId);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
view.addView(imageView, params);
|
|
||||||
}
|
|
||||||
|
|
||||||
toolbar.addView(view, new Toolbar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT, Gravity.RIGHT | Gravity.CENTER));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -156,46 +95,4 @@ public abstract class NewBaseMessageActivity extends BaseActivity {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToolBar(int toolBarId, ToolBarOptions options) {
|
|
||||||
toolbar = (Toolbar) findViewById(toolBarId);
|
|
||||||
if (options.titleId != 0) {
|
|
||||||
toolbar.setTitle(options.titleId);
|
|
||||||
}
|
|
||||||
if (!TextUtils.isEmpty(options.titleString)) {
|
|
||||||
toolbar.setTitle(options.titleString);
|
|
||||||
}
|
|
||||||
if (options.logoId != 0) {
|
|
||||||
toolbar.setLogo(options.logoId);
|
|
||||||
}
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
|
|
||||||
if (options.isNeedNavigate) {
|
|
||||||
toolbar.setNavigationIcon(options.navigateId);
|
|
||||||
toolbar.setContentInsetStartWithNavigation(0);
|
|
||||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
onBackPressed();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setToolBar(int toolbarId, int titleId, int logoId) {
|
|
||||||
toolbar = (Toolbar) findViewById(toolbarId);
|
|
||||||
toolbar.setTitle(titleId);
|
|
||||||
toolbar.setLogo(logoId);
|
|
||||||
setSupportActionBar(toolbar);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Toolbar getToolBar() {
|
|
||||||
return toolbar;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSubTitle(String subTitle) {
|
|
||||||
if (toolbar != null) {
|
|
||||||
toolbar.setSubtitle(subTitle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -3,53 +3,35 @@ package com.mango.moshen.ui.im.avtivity;
|
|||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.Drawable;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.SpannableStringBuilder;
|
|
||||||
import android.text.Spanned;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.mango.core.audio.event.VoiceShakeHeartEvent;
|
|
||||||
import com.mango.core.auth.AuthModel;
|
import com.mango.core.auth.AuthModel;
|
||||||
import com.mango.core.im.friend.IMFriendModel;
|
import com.mango.core.im.friend.IMFriendModel;
|
||||||
import com.mango.core.mentoring_relationship.event.MentoringSuccessEvent;
|
|
||||||
import com.mango.core.noble.NobleUtil;
|
|
||||||
import com.mango.core.praise.PraiseModel;
|
import com.mango.core.praise.PraiseModel;
|
||||||
import com.mango.core.praise.event.IsLikedEvent;
|
import com.mango.core.praise.event.IsLikedEvent;
|
||||||
import com.mango.core.praise.event.PraiseEvent;
|
import com.mango.core.praise.event.PraiseEvent;
|
||||||
|
import com.mango.core.room.model.AvRoomModel;
|
||||||
import com.mango.core.user.UserModel;
|
import com.mango.core.user.UserModel;
|
||||||
import com.mango.core.user.bean.UserDetailInfo;
|
|
||||||
import com.mango.core.user.bean.UserInfo;
|
import com.mango.core.user.bean.UserInfo;
|
||||||
import com.mango.core.utils.StringExtensionKt;
|
|
||||||
import com.mango.core.utils.SystemUidUtil;
|
import com.mango.core.utils.SystemUidUtil;
|
||||||
import com.mango.core.utils.net.BeanObserver;
|
import com.mango.core.utils.net.RxHelper;
|
||||||
import com.mango.moshen.R;
|
import com.mango.moshen.R;
|
||||||
import com.mango.moshen.avroom.activity.AVRoomActivity;
|
import com.mango.moshen.avroom.activity.AVRoomActivity;
|
||||||
import com.mango.moshen.common.widget.CustomImageSpan;
|
|
||||||
import com.mango.moshen.mentoring_relationship.dialog.BuildMentoringRelationshipSuccessDialog;
|
|
||||||
import com.mango.moshen.ui.im.audio.ShakeHeartDialogFragment;
|
|
||||||
import com.mango.moshen.ui.im.fragment.MessageFragment;
|
import com.mango.moshen.ui.im.fragment.MessageFragment;
|
||||||
import com.mango.moshen.ui.user.UserInfoActivity;
|
import com.mango.xchat_android_library.utils.JavaUtil;
|
||||||
import com.mango.moshen.ui.utils.ImageLoadUtils;
|
|
||||||
import com.mango.xchat_android_library.utils.ListUtils;
|
|
||||||
import com.mango.xchat_android_library.utils.SingleToastUtil;
|
import com.mango.xchat_android_library.utils.SingleToastUtil;
|
||||||
import com.netease.nim.uikit.StatusBarUtil;
|
import com.netease.nim.uikit.StatusBarUtil;
|
||||||
import com.netease.nim.uikit.api.NimUIKit;
|
import com.netease.nim.uikit.api.NimUIKit;
|
||||||
import com.netease.nim.uikit.api.model.contact.ContactChangedObserver;
|
import com.netease.nim.uikit.api.model.contact.ContactChangedObserver;
|
||||||
import com.netease.nim.uikit.api.model.main.OnlineStateChangeObserver;
|
|
||||||
import com.netease.nim.uikit.api.model.user.UserInfoObserver;
|
|
||||||
import com.netease.nim.uikit.api.wrapper.NimToolBarOptions;
|
|
||||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||||
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
|
||||||
import com.netease.nim.uikit.common.activity.ToolBarOptions;
|
|
||||||
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
import com.netease.nim.uikit.impl.NimUIKitImpl;
|
||||||
import com.netease.nimlib.sdk.NIMClient;
|
import com.netease.nimlib.sdk.NIMClient;
|
||||||
import com.netease.nimlib.sdk.Observer;
|
import com.netease.nimlib.sdk.Observer;
|
||||||
@@ -63,9 +45,6 @@ import org.greenrobot.eventbus.ThreadMode;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import io.reactivex.functions.Consumer;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点对点聊天界面
|
* 点对点聊天界面
|
||||||
* <p/>
|
* <p/>
|
||||||
@@ -73,15 +52,9 @@ import io.reactivex.functions.Consumer;
|
|||||||
*/
|
*/
|
||||||
public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||||
|
|
||||||
public static final String IS_BY_MATCH = "isByMatch";
|
|
||||||
private static final String TAG = "NimP2PMessageActivity";
|
private static final String TAG = "NimP2PMessageActivity";
|
||||||
private final OnlineStateChangeObserver onlineStateChangeObserver = accounts -> {
|
TextView tvToolbarTitle;
|
||||||
// 更新 toolbar
|
TextView tvAddBlackTip;
|
||||||
if (accounts.contains(sessionId)) {
|
|
||||||
// 按照交互来展示
|
|
||||||
displayOnlineState();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
private boolean isResume = false;
|
private boolean isResume = false;
|
||||||
/**
|
/**
|
||||||
* 命令消息接收观察者
|
* 命令消息接收观察者
|
||||||
@@ -92,10 +65,12 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
}
|
}
|
||||||
showCommandMessage(message);
|
showCommandMessage(message);
|
||||||
};
|
};
|
||||||
private TextView ivAddBlackList;
|
private View ivAddBlackList;
|
||||||
private TextView tvTips;
|
private TextView tvTips;
|
||||||
private View tipsLayout;
|
private View tipsLayout;
|
||||||
private ImageView closeIcon;
|
private ImageView closeIcon;
|
||||||
|
private View ivAttention;
|
||||||
|
private View tvOnlineTip;
|
||||||
@Nullable
|
@Nullable
|
||||||
private UserInfo buddyUserInfo;
|
private UserInfo buddyUserInfo;
|
||||||
private final ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
private final ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
||||||
@@ -119,74 +94,55 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
displayAntiFraudTips();
|
displayAntiFraudTips();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
private ImageView ivAttention;
|
|
||||||
private UserInfoObserver uinfoObserver;
|
|
||||||
|
|
||||||
public static void start(Context context, String contactId) {
|
public static void start(Context context, String contactId) {
|
||||||
startReal(context, contactId, new Intent());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void start(Context context, String contactId, boolean isFromVoiceMatch) {
|
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.putExtra(Extras.EXTRA_ACCOUNT, contactId);
|
|
||||||
intent.putExtra(Extras.EXTRA_CUSTOMIZATION, NimUIKitImpl.commonP2PSessionCustomization);
|
|
||||||
intent.putExtra("isFromVoiceMatch", isFromVoiceMatch);
|
|
||||||
intent.setClass(context, NimP2PMessageActivity.class);
|
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
|
|
||||||
context.startActivity(intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void start(Context context, String contactId, String gameId) {
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra("gameId", gameId);
|
|
||||||
startReal(context, contactId, intent);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void startReal(Context context, String contactId, Intent intent) {
|
|
||||||
if (intent == null)
|
|
||||||
intent = new Intent();
|
|
||||||
|
|
||||||
intent.putExtra(Extras.EXTRA_ACCOUNT, contactId);
|
intent.putExtra(Extras.EXTRA_ACCOUNT, contactId);
|
||||||
intent.putExtra(Extras.EXTRA_CUSTOMIZATION, NimUIKitImpl.commonP2PSessionCustomization);
|
intent.putExtra(Extras.EXTRA_CUSTOMIZATION, NimUIKitImpl.commonP2PSessionCustomization);
|
||||||
intent.setClass(context, NimP2PMessageActivity.class);
|
intent.setClass(context, NimP2PMessageActivity.class);
|
||||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getContentViewId() {
|
||||||
|
return R.layout.activity_p2p_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
tipsLayout = findViewById(R.id.rl_tips);
|
tipsLayout = findViewById(R.id.rl_tips);
|
||||||
closeIcon = findViewById(R.id.iv_close_tips);
|
closeIcon = findViewById(R.id.iv_close_tips);
|
||||||
tvTips = findViewById(R.id.tv_tips);
|
tvTips = findViewById(R.id.tv_tips);
|
||||||
|
ivAttention = findViewById(R.id.iv_attention);
|
||||||
|
tvToolbarTitle = findViewById(R.id.tv_toolbar_title);
|
||||||
|
ivAddBlackList = findViewById(R.id.iv_add_black_list);
|
||||||
|
tvAddBlackTip = findViewById(R.id.tv_add_black_tip);
|
||||||
|
tvOnlineTip = findViewById(R.id.tv_online_tip);
|
||||||
closeIcon.setOnClickListener(view -> {
|
closeIcon.setOnClickListener(view -> {
|
||||||
IMFriendModel.get().addCloseTipsAccount(sessionId);
|
IMFriendModel.get().addCloseTipsAccount(sessionId);
|
||||||
tipsLayout.setVisibility(View.GONE);
|
tipsLayout.setVisibility(View.GONE);
|
||||||
});
|
});
|
||||||
// 单聊特例话数据,包括个人信息,黑名单
|
findViewById(R.id.iv_back).setOnClickListener(v -> finish());
|
||||||
|
|
||||||
addBlackList();
|
addBlackList();
|
||||||
requestBuddyInfo();
|
requestBuddyInfo();
|
||||||
displayOnlineState();
|
|
||||||
registerObservers(true);
|
registerObservers(true);
|
||||||
registerOnlineStateChangeListener(true);
|
|
||||||
EventBus.getDefault().register(this);
|
EventBus.getDefault().register(this);
|
||||||
displayAntiFraudTips();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onNewIntent(Intent intent) {
|
protected void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
|
|
||||||
String sessionId = intent.getStringExtra(Extras.EXTRA_ACCOUNT);
|
String sessionId = intent.getStringExtra(Extras.EXTRA_ACCOUNT);
|
||||||
//如果sessionId与之前的sessionId不是同一个,刷新数据
|
//如果sessionId与之前的sessionId不是同一个,刷新数据
|
||||||
if (!TextUtils.isEmpty(this.sessionId) && !this.sessionId.equals(sessionId)) {
|
if (!TextUtils.isEmpty(this.sessionId) && !this.sessionId.equals(sessionId)) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
buddyUserInfo = null;
|
buddyUserInfo = null;
|
||||||
|
addBlackList();
|
||||||
requestBuddyInfo();
|
requestBuddyInfo();
|
||||||
displayOnlineState();
|
|
||||||
displayAntiFraudTips();
|
|
||||||
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,22 +166,18 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void addBlackList() {
|
private void addBlackList() {
|
||||||
if (SystemUidUtil.isSystemUid(sessionId)) return;
|
if (SystemUidUtil.isSystemUid(sessionId)) {
|
||||||
ivAddBlackList = findViewById(R.id.iv_add_black_list);
|
ivAddBlackList.setVisibility(View.GONE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
ivAddBlackList.setVisibility(View.VISIBLE);
|
ivAddBlackList.setVisibility(View.VISIBLE);
|
||||||
ivAddBlackList.setOnClickListener((view) -> {
|
ivAddBlackList.setOnClickListener((view) -> AddBlackListActivity.start(this, sessionId));
|
||||||
// 跳转到加入黑名单
|
|
||||||
String account = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
|
||||||
AddBlackListActivity.start(NimP2PMessageActivity.this, account);
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
registerObservers(false);
|
registerObservers(false);
|
||||||
registerOnlineStateChangeListener(false);
|
|
||||||
EventBus.getDefault().unregister(this);
|
EventBus.getDefault().unregister(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,144 +193,48 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
isResume = false;
|
isResume = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getNickFromSession() {
|
|
||||||
String userTitleName = UserInfoHelper.getUserTitleName(sessionId, SessionTypeEnum.P2P);
|
|
||||||
TextView tvToolbarTitle = getToolBar().findViewById(R.id.tv_toolbar_title);
|
|
||||||
if (tvToolbarTitle != null) {
|
|
||||||
tvToolbarTitle.setText(userTitleName);
|
|
||||||
tvToolbarTitle.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("CheckResult")
|
@SuppressLint("CheckResult")
|
||||||
private void requestBuddyInfo() {
|
private void requestBuddyInfo() {
|
||||||
getNickFromSession();
|
long uid = JavaUtil.str2long(sessionId);
|
||||||
|
PraiseModel.get().isPraised(AuthModel.get().getCurrentUid(), uid).subscribe();
|
||||||
// 如果有个人信息可以获取
|
// 如果有个人信息可以获取
|
||||||
UserModel.get().getUserInfo(Long.valueOf(sessionId)).subscribe(new Consumer<UserInfo>() {
|
UserModel.get().getUserInfo(uid)
|
||||||
@Override
|
.subscribe(userInfo -> {
|
||||||
public void accept(UserInfo userInfo) throws Exception {
|
tvToolbarTitle.setText(userInfo.getNick());
|
||||||
String badge = "";
|
|
||||||
if (userInfo.getNobleInfo() != null) {
|
|
||||||
badge = NobleUtil.getLocalResourcePath(userInfo.getNobleInfo().getBadge());
|
|
||||||
}
|
|
||||||
Drawable drawable = Drawable.createFromPath(badge);
|
|
||||||
// 显示自己的textView并且居中
|
|
||||||
TextView tvToolbarTitle = getToolBar().findViewById(R.id.tv_toolbar_title);
|
|
||||||
// 不知道为什么要从云信获取titleName;
|
|
||||||
String userTitleName = (drawable == null ? "" : " ") + userInfo.getNick();
|
|
||||||
SpannableStringBuilder builder = new SpannableStringBuilder(userTitleName);
|
|
||||||
if (drawable != null) {
|
|
||||||
int dimension = (int) getResources().getDimension(R.dimen.badge_tab_category_height);
|
|
||||||
drawable.setBounds(0, 0, dimension, dimension);
|
|
||||||
CustomImageSpan imageSpan = new CustomImageSpan(drawable);
|
|
||||||
builder.setSpan(imageSpan, 0, 1, Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
|
|
||||||
}
|
|
||||||
tvToolbarTitle.setText(builder);
|
|
||||||
tvToolbarTitle.setVisibility(View.VISIBLE);
|
|
||||||
|
|
||||||
ivAttention = (ImageView) findViewById(R.id.iv_attention);
|
|
||||||
if (AuthModel.get().getCurrentUid() != userInfo.getUid()) {
|
|
||||||
PraiseModel.get().isPraised(AuthModel.get().getCurrentUid(), userInfo.getUid()).subscribe();
|
|
||||||
}
|
|
||||||
buddyUserInfo = userInfo;
|
buddyUserInfo = userInfo;
|
||||||
displayAntiFraudTips();
|
displayAntiFraudTips();
|
||||||
|
});
|
||||||
|
|
||||||
|
AvRoomModel.get()
|
||||||
|
.getUserRoom(uid)
|
||||||
|
.compose(RxHelper.singleMainResult())
|
||||||
|
.compose(RxHelper.handleSchAndExce())
|
||||||
|
.subscribe((roomInfo, throwable) -> {
|
||||||
|
if (throwable == null) {
|
||||||
|
if (roomInfo != null && roomInfo.getUid() > 0) {
|
||||||
|
tvOnlineTip.setVisibility(View.VISIBLE);
|
||||||
|
tvOnlineTip.setOnClickListener(v -> AVRoomActivity.start(context, roomInfo.getUid()));
|
||||||
|
} else {
|
||||||
|
tvOnlineTip.setVisibility(View.GONE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
tvOnlineTip.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
setTitle("");
|
|
||||||
// 显示是否 已经加入黑名单
|
// 显示是否 已经加入黑名单
|
||||||
TextView tvAddBlackTip = getToolBar().findViewById(com.mango.moshen.R.id.tv_add_black_tip);
|
if (NimFriendModel.get().isInMyBlackList(sessionId)) {
|
||||||
List<String> blackListAccount = NimFriendModel.get().getMyBlackListAccount();
|
tvAddBlackTip.setVisibility(View.VISIBLE);
|
||||||
|
} else {
|
||||||
tvAddBlackTip.setVisibility(View.GONE);
|
tvAddBlackTip.setVisibility(View.GONE);
|
||||||
if (!ListUtils.isListEmpty(blackListAccount)) {
|
|
||||||
boolean contains = blackListAccount.contains(sessionId);
|
|
||||||
tvAddBlackTip.setVisibility(contains ? View.VISIBLE : View.GONE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
if (!SystemUidUtil.isSystemUid(sessionId)) {
|
|
||||||
View clUserDetails = findViewById(R.id.cl_user_details);
|
|
||||||
UserModel.get().getUserInfoDetail(Long.parseLong(sessionId))
|
|
||||||
.compose(bindToLifecycle())
|
|
||||||
.subscribe(new BeanObserver<UserDetailInfo>() {
|
|
||||||
@Override
|
|
||||||
public void onErrorMsg(String error) {
|
|
||||||
clUserDetails.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressLint("SetTextI18n")
|
|
||||||
@Override
|
|
||||||
public void onSuccess(@NonNull UserDetailInfo info) {
|
|
||||||
UserDetailInfo.DataBean userInfo = info.getData();
|
|
||||||
if (userInfo == null || userInfo.getRoomUid() <= 0) {
|
|
||||||
clUserDetails.setVisibility(View.GONE);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
clUserDetails.setVisibility(View.VISIBLE);
|
|
||||||
ImageView ivAvatar = findViewById(R.id.iv_avatar);
|
|
||||||
TextView tvNick = findViewById(R.id.tv_nick);
|
|
||||||
TextView tvContent = findViewById(R.id.tv_content);
|
|
||||||
tvNick.setText(userInfo.getNick());
|
|
||||||
ImageLoadUtils.loadAvatar(userInfo.getAvatar(), ivAvatar);
|
|
||||||
tvContent.setText("正在\"" + StringExtensionKt.subAndReplaceDot(userInfo.getRoomTitle(), 5) + "\"热聊中");
|
|
||||||
ivAvatar.setOnClickListener(v -> UserInfoActivity.Companion.start(context, userInfo.getUid()));
|
|
||||||
clUserDetails.setOnClickListener(v -> AVRoomActivity.startForFromType(
|
|
||||||
context,
|
|
||||||
userInfo.getRoomUid(),
|
|
||||||
AVRoomActivity.FROM_TYPE_USER,
|
|
||||||
userInfo.getNick(),
|
|
||||||
String.valueOf(userInfo.getUid())));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerObservers(boolean register) {
|
private void registerObservers(boolean register) {
|
||||||
if (register) {
|
|
||||||
registerUserInfoObserver();
|
|
||||||
} else {
|
|
||||||
unregisterUserInfoObserver();
|
|
||||||
}
|
|
||||||
NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(commandObserver, register);
|
NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(commandObserver, register);
|
||||||
NimUIKit.getContactChangedObservable().registerObserver(friendDataChangedObserver, register);
|
NimUIKit.getContactChangedObservable().registerObserver(friendDataChangedObserver, register);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerOnlineStateChangeListener(boolean register) {
|
|
||||||
if (!NimUIKitImpl.enableOnlineState()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NimUIKitImpl.getOnlineStateChangeObservable().registerOnlineStateChangeListeners(onlineStateChangeObserver, register);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayOnlineState() {
|
|
||||||
if (!NimUIKitImpl.enableOnlineState()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String detailContent = NimUIKitImpl.getOnlineStateContentProvider().getDetailDisplay(sessionId);
|
|
||||||
setSubTitle(detailContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerUserInfoObserver() {
|
|
||||||
if (uinfoObserver == null) {
|
|
||||||
uinfoObserver = new UserInfoObserver() {
|
|
||||||
@Override
|
|
||||||
public void onUserInfoChanged(List<String> accounts) {
|
|
||||||
if (accounts.contains(sessionId)) {
|
|
||||||
requestBuddyInfo();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
NimUIKit.getUserInfoObservable().registerObserver(uinfoObserver, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void unregisterUserInfoObserver() {
|
|
||||||
if (uinfoObserver != null) {
|
|
||||||
NimUIKit.getUserInfoObservable().registerObserver(uinfoObserver, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void showCommandMessage(CustomNotification message) {
|
protected void showCommandMessage(CustomNotification message) {
|
||||||
if (!isResume) {
|
if (!isResume) {
|
||||||
return;
|
return;
|
||||||
@@ -407,46 +263,19 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
arguments = new Bundle();
|
arguments = new Bundle();
|
||||||
}
|
}
|
||||||
arguments.putSerializable(Extras.EXTRA_TYPE, SessionTypeEnum.P2P);
|
arguments.putSerializable(Extras.EXTRA_TYPE, SessionTypeEnum.P2P);
|
||||||
String gameId = intent.getStringExtra("gameId");
|
|
||||||
if (!TextUtils.isEmpty(gameId)) {
|
|
||||||
arguments.putString("gameId", gameId);
|
|
||||||
}
|
|
||||||
MessageFragment fragment = new MessageFragment();
|
MessageFragment fragment = new MessageFragment();
|
||||||
fragment.setArguments(arguments);
|
fragment.setArguments(arguments);
|
||||||
fragment.setContainerId(R.id.message_fragment_container);
|
fragment.setContainerId(R.id.message_fragment_container);
|
||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected int getContentViewId() {
|
|
||||||
return R.layout.activity_p2p_message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initToolBar() {
|
|
||||||
ToolBarOptions options = new NimToolBarOptions();
|
|
||||||
setToolBar(R.id.toolbar, options);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
public void onMentoringSuccessEvent(MentoringSuccessEvent event) {
|
|
||||||
BuildMentoringRelationshipSuccessDialog dialog = new BuildMentoringRelationshipSuccessDialog();
|
|
||||||
dialog.show(getSupportFragmentManager());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||||
public void onIsLiked(IsLikedEvent event) {
|
public void onIsLiked(IsLikedEvent event) {
|
||||||
if (event.isLiked) {
|
if (event.isLiked) {
|
||||||
ivAttention.setVisibility(View.GONE);
|
ivAttention.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
ivAttention.setVisibility(View.VISIBLE);
|
ivAttention.setVisibility(View.VISIBLE);
|
||||||
ivAttention.setOnClickListener(new View.OnClickListener() {
|
ivAttention.setOnClickListener(v -> PraiseModel.get().praise(Long.valueOf(sessionId), true).subscribe());
|
||||||
@Override
|
|
||||||
public void onClick(View v) {
|
|
||||||
PraiseModel.get().praise(Long.valueOf(sessionId), true).subscribe();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -460,18 +289,10 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
toast(event.getError());
|
toast(event.getError());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ivAttention.setVisibility(View.GONE);
|
ivAttention.setVisibility(event.isPraise() ? View.GONE : View.VISIBLE);
|
||||||
ivAttention.setOnClickListener(null);
|
|
||||||
toast(event.isPraise() ? R.string.attention_success : R.string.cancel_fan_success);
|
toast(event.isPraise() ? R.string.attention_success : R.string.cancel_fan_success);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
|
||||||
public void onVoiceShakeHeart(VoiceShakeHeartEvent event) {
|
|
||||||
// 显示动画
|
|
||||||
ShakeHeartDialogFragment shakeHeartDialogFragment = ShakeHeartDialogFragment.newInstance(event.showTextHint);
|
|
||||||
shakeHeartDialogFragment.show(getSupportFragmentManager(), "shake_heart");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean needSteepStateBar() {
|
protected boolean needSteepStateBar() {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -2,6 +2,7 @@ package com.mango.moshen.ui.im.chat;
|
|||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -13,6 +14,8 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
import com.chad.library.adapter.base.BaseViewHolder;
|
||||||
|
import com.mango.core.decoration.headwear.bean.HeadWearInfo;
|
||||||
|
import com.mango.core.noble.NobleUtil;
|
||||||
import com.mango.core.user.UserModel;
|
import com.mango.core.user.UserModel;
|
||||||
import com.mango.core.user.bean.UserPhoto;
|
import com.mango.core.user.bean.UserPhoto;
|
||||||
import com.mango.core.utils.StarUtils;
|
import com.mango.core.utils.StarUtils;
|
||||||
@@ -54,6 +57,7 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
|||||||
private TextView tvConstellation;
|
private TextView tvConstellation;
|
||||||
private TextView tvDesc;
|
private TextView tvDesc;
|
||||||
private RecyclerView rvPhotos;
|
private RecyclerView rvPhotos;
|
||||||
|
private ImageView ivHeadWear;
|
||||||
|
|
||||||
public MsgViewHolderUserCard(BaseMultiItemFetchLoadAdapter adapter) {
|
public MsgViewHolderUserCard(BaseMultiItemFetchLoadAdapter adapter) {
|
||||||
super(adapter);
|
super(adapter);
|
||||||
@@ -78,6 +82,11 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
|||||||
tvConstellation = findViewById(R.id.tv_constellation);
|
tvConstellation = findViewById(R.id.tv_constellation);
|
||||||
tvDesc = findViewById(R.id.tv_desc);
|
tvDesc = findViewById(R.id.tv_desc);
|
||||||
rvPhotos = findViewById(R.id.rv_photos);
|
rvPhotos = findViewById(R.id.rv_photos);
|
||||||
|
ivHeadWear = findViewById(R.id.iv_head_wear);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindContentView() {
|
||||||
if (photoAdapter == null) {
|
if (photoAdapter == null) {
|
||||||
photoAdapter = new BaseQuickAdapter<UserPhoto, BaseViewHolder>(R.layout.item_p2p_user_photo) {
|
photoAdapter = new BaseQuickAdapter<UserPhoto, BaseViewHolder>(R.layout.item_p2p_user_photo) {
|
||||||
@Override
|
@Override
|
||||||
@@ -98,7 +107,6 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void showUserPhoto(int position) {
|
private void showUserPhoto(int position) {
|
||||||
//创建一个集合拿来做用户所有照片信息
|
//创建一个集合拿来做用户所有照片信息
|
||||||
ArrayList<UserPhoto> userPhotos = new ArrayList<>();
|
ArrayList<UserPhoto> userPhotos = new ArrayList<>();
|
||||||
@@ -135,6 +143,16 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
|||||||
tvConstellation.setVisibility(View.VISIBLE);
|
tvConstellation.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
photoAdapter.setNewData(userInfo.getPrivatePhoto());
|
photoAdapter.setNewData(userInfo.getPrivatePhoto());
|
||||||
|
|
||||||
|
HeadWearInfo headWearInfo = userInfo.getUserHeadwear();
|
||||||
|
if (headWearInfo != null && !TextUtils.isEmpty(headWearInfo.getPic())) {
|
||||||
|
NobleUtil.loadHeadWear(
|
||||||
|
headWearInfo.getEffect() != null ? headWearInfo.getEffect() : headWearInfo.getPic(),
|
||||||
|
ivHeadWear
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ivHeadWear.setImageResource(0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
SkillModel.Companion
|
SkillModel.Companion
|
||||||
@@ -169,16 +187,6 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void bindContentView() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 内容区域点击事件响应处理。
|
|
||||||
protected void onItemClick() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// 内容区域长按事件响应处理。该接口的优先级比adapter中有长按事件的处理监听高,当该接口返回为true时,adapter的长按事件监听不会被调用到。
|
// 内容区域长按事件响应处理。该接口的优先级比adapter中有长按事件的处理监听高,当该接口返回为true时,adapter的长按事件监听不会被调用到。
|
||||||
protected boolean onItemLongClick() {
|
protected boolean onItemLongClick() {
|
||||||
return true;
|
return true;
|
||||||
|
@@ -450,7 +450,9 @@ public class RecentContactsFragment extends TFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// 查询最近联系人列表数据
|
// 查询最近联系人列表数据
|
||||||
NIMClient.getService(MsgService.class).queryRecentContacts().setCallback(new RequestCallbackWrapper<List<RecentContact>>() {
|
NIMClient.getService(MsgService.class)
|
||||||
|
.queryRecentContacts()
|
||||||
|
.setCallback(new RequestCallbackWrapper<List<RecentContact>>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResult(int code, List<RecentContact> recents, Throwable exception) {
|
public void onResult(int code, List<RecentContact> recents, Throwable exception) {
|
||||||
|
@@ -265,12 +265,6 @@ public class JSInterface {
|
|||||||
mPosition = position;
|
mPosition = position;
|
||||||
}
|
}
|
||||||
|
|
||||||
@JavascriptInterface
|
|
||||||
public void challenge(long uid, String gameId) {
|
|
||||||
StatisticManager.Instance().onEvent(StatisticsProtocol.gamelist_challenge, "挑战按钮");
|
|
||||||
NimP2PMessageActivity.start(context, uid + "", gameId);
|
|
||||||
}
|
|
||||||
|
|
||||||
@JavascriptInterface
|
@JavascriptInterface
|
||||||
public void clipboardToPhone(String content) {
|
public void clipboardToPhone(String content) {
|
||||||
ClipboardManager myClipboard;
|
ClipboardManager myClipboard;
|
||||||
|
BIN
app/src/main/res/drawable-xhdpi/ic_p2p_live.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_p2p_live.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 190 B |
BIN
app/src/main/res/drawable-xhdpi/icon_add_black_list.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/icon_add_black_list.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 349 B |
Binary file not shown.
Before Width: | Height: | Size: 636 B |
@@ -41,6 +41,14 @@
|
|||||||
android:layout_marginStart="10dp"
|
android:layout_marginStart="10dp"
|
||||||
tools:background="@drawable/default_avatar" />
|
tools:background="@drawable/default_avatar" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_head_wear"
|
||||||
|
android:layout_width="56dp"
|
||||||
|
android:layout_height="56dp"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:layout_marginStart="4dp" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_name"
|
android:id="@+id/tv_name"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -75,18 +83,31 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tv_add_top"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="44dp"
|
android:layout_height="44dp"
|
||||||
android:layout_marginTop="10dp"
|
android:layout_marginTop="10dp"
|
||||||
android:background="@color/bg_secondary_2a2a39"
|
android:background="@color/bg_secondary_2a2a39"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_add_top"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:text="置顶聊天"
|
android:text="置顶聊天"
|
||||||
android:textColor="@color/text_title_white"
|
android:textColor="@color/text_title_white"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<com.mango.xchat_android_library.widget.IOSSwitchView
|
||||||
|
android:id="@+id/switch_top"
|
||||||
|
android:layout_width="42dp"
|
||||||
|
android:layout_height="22dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
@@ -94,17 +115,32 @@
|
|||||||
android:layout_marginEnd="12dp"
|
android:layout_marginEnd="12dp"
|
||||||
android:background="@color/line_353548" />
|
android:background="@color/line_353548" />
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/tv_add_black_list"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="44dp"
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
android:background="@color/bg_secondary_2a2a39"
|
android:background="@color/bg_secondary_2a2a39"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:paddingStart="16dp"
|
android:paddingStart="16dp"
|
||||||
|
android:paddingEnd="16dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_add_black_list"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
android:text="加入黑名单"
|
android:text="加入黑名单"
|
||||||
android:textColor="@color/text_title_white"
|
android:textColor="@color/text_title_white"
|
||||||
android:textSize="14sp" />
|
android:textSize="14sp" />
|
||||||
|
|
||||||
|
<com.mango.xchat_android_library.widget.IOSSwitchView
|
||||||
|
android:id="@+id/switch_add_black"
|
||||||
|
android:layout_width="42dp"
|
||||||
|
android:layout_height="22dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
<View
|
<View
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="1px"
|
android:layout_height="1px"
|
||||||
|
@@ -1,36 +1,32 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:background="@color/bg_normal_1c1b22"
|
android:background="@color/white"
|
||||||
android:paddingTop="30dp">
|
android:orientation="vertical"
|
||||||
|
android:paddingTop="44dp">
|
||||||
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:orientation="vertical">
|
|
||||||
|
|
||||||
<com.google.android.material.appbar.AppBarLayout
|
<FrameLayout
|
||||||
android:id="@+id/app_bar_layout"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:theme="@style/AppTheme.AppBarOverlay"
|
|
||||||
app:elevation="0dp">
|
|
||||||
|
|
||||||
<androidx.appcompat.widget.Toolbar
|
|
||||||
android:id="@+id/toolbar"
|
android:id="@+id/toolbar"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="44dp">
|
||||||
android:background="@color/bg_normal_1c1b22"
|
|
||||||
app:subtitleTextAppearance="@style/Toolbar.SubTitleText"
|
<ImageView
|
||||||
app:titleTextAppearance="@style/Toolbar.TitleText">
|
android:id="@+id/iv_back"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_marginStart="10dp"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/arrow_left" />
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
|
android:gravity="center"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical">
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
@@ -45,54 +41,82 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_vertical"
|
android:layout_gravity="center_vertical"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
android:maxWidth="214dp"
|
android:includeFontPadding="false"
|
||||||
|
android:maxWidth="120dp"
|
||||||
android:maxLines="1"
|
android:maxLines="1"
|
||||||
android:singleLine="true"
|
android:singleLine="true"
|
||||||
android:textAppearance="@style/Toolbar.TitleText"
|
android:textColor="@color/black"
|
||||||
android:textColor="@color/text_title_white"
|
android:textSize="16sp"
|
||||||
android:visibility="gone"
|
tools:text="孙行者123孙行者123孙行者123孙行者123孙行者123孙行者123"
|
||||||
tools:text="孙行者123"
|
|
||||||
tools:visibility="visible" />
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/iv_attention"
|
|
||||||
android:layout_width="19dp"
|
|
||||||
android:layout_height="16dp"
|
|
||||||
android:layout_gravity="center_vertical"
|
|
||||||
android:layout_marginLeft="3dp"
|
|
||||||
android:src="@drawable/ic_chat_navigation_attention"
|
|
||||||
android:visibility="gone"
|
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="3dp"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_add_black_tip"
|
android:id="@+id/tv_add_black_tip"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="center_horizontal"
|
android:layout_gravity="center_horizontal"
|
||||||
android:layout_marginTop="4dp"
|
|
||||||
android:text="已经加入黑名单"
|
android:text="已经加入黑名单"
|
||||||
android:textColor="@color/text_normal_c6c6e9"
|
android:textColor="@color/text_normal_c6c6e9"
|
||||||
android:textSize="12dp" />
|
android:textSize="10dp"
|
||||||
</LinearLayout>
|
android:visibility="visible" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/iv_add_black_list"
|
android:id="@+id/tv_online_tip"
|
||||||
android:layout_width="?attr/actionBarSize"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="?attr/actionBarSize"
|
android:layout_height="wrap_content"
|
||||||
android:layout_gravity="right"
|
android:layout_marginStart="5dp"
|
||||||
|
android:drawableStart="@drawable/ic_p2p_live"
|
||||||
|
android:drawableEnd="@drawable/arrow_right"
|
||||||
|
android:drawablePadding="3dp"
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
android:src="@drawable/icon_add_black_list"
|
android:text="直播中"
|
||||||
android:text="举报"
|
android:textColor="#ffbabbcd"
|
||||||
android:textColor="@color/text_normal_c6c6e9"
|
android:textSize="10sp"
|
||||||
android:textSize="@dimen/dp_13"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible" />
|
tools:visibility="visible" />
|
||||||
|
|
||||||
</androidx.appcompat.widget.Toolbar>
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/iv_attention"
|
||||||
|
android:layout_width="48dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_gravity="center_vertical|end"
|
||||||
|
android:layout_marginLeft="3dp"
|
||||||
|
android:layout_marginEnd="64dp"
|
||||||
|
android:background="@drawable/common_btn_bg"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="关注"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:textSize="10sp"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_add_black_list"
|
||||||
|
android:layout_width="44dp"
|
||||||
|
android:layout_height="44dp"
|
||||||
|
android:layout_gravity="end"
|
||||||
|
android:layout_marginEnd="10dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:scaleType="center"
|
||||||
|
android:src="@drawable/icon_add_black_list"
|
||||||
|
android:visibility="gone"
|
||||||
|
tools:visibility="visible" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
</com.google.android.material.appbar.AppBarLayout>
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_tips"
|
android:id="@+id/rl_tips"
|
||||||
@@ -130,8 +154,7 @@
|
|||||||
<androidx.fragment.app.FragmentContainerView
|
<androidx.fragment.app.FragmentContainerView
|
||||||
android:id="@+id/message_fragment_container"
|
android:id="@+id/message_fragment_container"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/bg_normal_1c1b22" />
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
|
@@ -129,6 +129,17 @@
|
|||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toTopOf="parent" />
|
app:layout_constraintTop_toTopOf="parent" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_head_wear"
|
||||||
|
android:layout_width="73dp"
|
||||||
|
android:layout_height="73dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@id/iv_avatar"
|
||||||
|
app:layout_constraintEnd_toEndOf="@id/iv_avatar"
|
||||||
|
app:layout_constraintStart_toStartOf="@id/iv_avatar"
|
||||||
|
app:layout_constraintTop_toTopOf="@id/iv_avatar" />
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/tv_nick"
|
android:id="@+id/tv_nick"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
@@ -137,7 +148,7 @@
|
|||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/color_333333"
|
||||||
android:textSize="16dp"
|
android:textSize="16dp"
|
||||||
app:layout_constraintBottom_toTopOf="@id/tv_desc"
|
app:layout_constraintBottom_toTopOf="@id/tv_desc"
|
||||||
app:layout_constraintStart_toEndOf="@id/iv_avatar"
|
app:layout_constraintStart_toEndOf="@id/iv_head_wear"
|
||||||
app:layout_constraintTop_toTopOf="@id/iv_avatar"
|
app:layout_constraintTop_toTopOf="@id/iv_avatar"
|
||||||
app:layout_constraintVertical_chainStyle="packed"
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
tools:text="这就是大哥呀呀" />
|
tools:text="这就是大哥呀呀" />
|
||||||
|
@@ -558,7 +558,7 @@
|
|||||||
<!-- 主题色 -->
|
<!-- 主题色 -->
|
||||||
<color name="app_248cfe">#5FCCE4</color>
|
<color name="app_248cfe">#5FCCE4</color>
|
||||||
<!-- 页面背景色 -->
|
<!-- 页面背景色 -->
|
||||||
<color name="bg_normal_1c1b22">#FFF3F5FA</color>
|
<color name="bg_normal_1c1b22">#F4F4FA</color>
|
||||||
<!-- 页面次级背景 列表item背景色-->
|
<!-- 页面次级背景 列表item背景色-->
|
||||||
<color name="bg_secondary_2a2a39">#FFFFFF</color>
|
<color name="bg_secondary_2a2a39">#FFFFFF</color>
|
||||||
<!-- 页面三级背景色,一般用于输入框-->
|
<!-- 页面三级背景色,一般用于输入框-->
|
||||||
|
@@ -23,8 +23,6 @@ import com.mango.moshen.ui.im.avtivity.NewBaseMessageActivity;
|
|||||||
import com.mango.moshen.ui.im.fragment.MessageFragment;
|
import com.mango.moshen.ui.im.fragment.MessageFragment;
|
||||||
import com.mango.xchat_android_library.utils.SingleToastUtil;
|
import com.mango.xchat_android_library.utils.SingleToastUtil;
|
||||||
import com.netease.nim.uikit.api.NimUIKit;
|
import com.netease.nim.uikit.api.NimUIKit;
|
||||||
import com.netease.nim.uikit.api.model.contact.ContactChangedObserver;
|
|
||||||
import com.netease.nim.uikit.api.model.main.OnlineStateChangeObserver;
|
|
||||||
import com.netease.nim.uikit.api.model.user.UserInfoObserver;
|
import com.netease.nim.uikit.api.model.user.UserInfoObserver;
|
||||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||||
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
import com.netease.nim.uikit.business.uinfo.UserInfoHelper;
|
||||||
@@ -37,9 +35,6 @@ import com.netease.nimlib.sdk.msg.model.CustomNotification;
|
|||||||
|
|
||||||
import org.greenrobot.eventbus.EventBus;
|
import org.greenrobot.eventbus.EventBus;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 点对点聊天界面
|
* 点对点聊天界面
|
||||||
@@ -48,51 +43,16 @@ import java.util.Set;
|
|||||||
*/
|
*/
|
||||||
public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
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;
|
private boolean isResume = false;
|
||||||
/**
|
/**
|
||||||
* 命令消息接收观察者
|
* 命令消息接收观察者
|
||||||
*/
|
*/
|
||||||
Observer<CustomNotification> commandObserver = new Observer<CustomNotification>() {
|
Observer<CustomNotification> commandObserver = message -> {
|
||||||
@Override
|
|
||||||
public void onEvent(CustomNotification message) {
|
|
||||||
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
showCommandMessage(message);
|
showCommandMessage(message);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
private View tipsLayout;
|
private View tipsLayout;
|
||||||
private ImageView closeIcon;
|
private ImageView closeIcon;
|
||||||
@@ -116,13 +76,8 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
// 单聊特例话数据,包括个人信息,黑名单
|
|
||||||
//addBlackList();
|
|
||||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
|
||||||
requestBuddyInfo();
|
requestBuddyInfo();
|
||||||
displayOnlineState();
|
|
||||||
registerObservers(true);
|
registerObservers(true);
|
||||||
registerOnlineStateChangeListener(true);
|
|
||||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||||
.compose(bindToLifecycle())
|
.compose(bindToLifecycle())
|
||||||
.filter(roomEvent -> roomEvent.getEvent() == RoomEvent.KICK_OUT_ROOM)
|
.filter(roomEvent -> roomEvent.getEvent() == RoomEvent.KICK_OUT_ROOM)
|
||||||
@@ -139,7 +94,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
if (!TextUtils.isEmpty(this.sessionId) && !this.sessionId.equals(sessionId)) {
|
if (!TextUtils.isEmpty(this.sessionId) && !this.sessionId.equals(sessionId)) {
|
||||||
this.sessionId = sessionId;
|
this.sessionId = sessionId;
|
||||||
requestBuddyInfo();
|
requestBuddyInfo();
|
||||||
displayOnlineState();
|
|
||||||
displayAntiFraudTips();
|
displayAntiFraudTips();
|
||||||
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
||||||
}
|
}
|
||||||
@@ -173,7 +127,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
registerObservers(false);
|
registerObservers(false);
|
||||||
registerOnlineStateChangeListener(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -205,33 +158,15 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
unregisterUserInfoObserver();
|
unregisterUserInfoObserver();
|
||||||
}
|
}
|
||||||
NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(commandObserver, register);
|
NIMClient.getService(MsgServiceObserve.class).observeCustomNotification(commandObserver, register);
|
||||||
NimUIKit.getContactChangedObservable().registerObserver(friendDataChangedObserver, register);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerOnlineStateChangeListener(boolean register) {
|
|
||||||
if (!NimUIKitImpl.enableOnlineState()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
NimUIKitImpl.getOnlineStateChangeObservable().registerOnlineStateChangeListeners(onlineStateChangeObserver, register);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayOnlineState() {
|
|
||||||
if (!NimUIKitImpl.enableOnlineState()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
String detailContent = NimUIKitImpl.getOnlineStateContentProvider().getDetailDisplay(sessionId);
|
|
||||||
setSubTitle(detailContent);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void registerUserInfoObserver() {
|
private void registerUserInfoObserver() {
|
||||||
if (uinfoObserver == null) {
|
if (uinfoObserver == null) {
|
||||||
uinfoObserver = new UserInfoObserver() {
|
uinfoObserver = accounts -> {
|
||||||
@Override
|
|
||||||
public void onUserInfoChanged(List<String> accounts) {
|
|
||||||
if (accounts.contains(sessionId)) {
|
if (accounts.contains(sessionId)) {
|
||||||
requestBuddyInfo();
|
requestBuddyInfo();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
NimUIKit.getUserInfoObservable().registerObserver(uinfoObserver, true);
|
NimUIKit.getUserInfoObservable().registerObserver(uinfoObserver, true);
|
||||||
@@ -276,11 +211,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
|||||||
return fragment;
|
return fragment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void initToolBar() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean needSteepStateBar() {
|
protected boolean needSteepStateBar() {
|
||||||
return false;
|
return false;
|
||||||
|
@@ -885,22 +885,6 @@ public final class UserModel extends BaseModel implements IUserModel {
|
|||||||
@Field("shareCode") String shareCode,
|
@Field("shareCode") String shareCode,
|
||||||
@Field("inviteCode") String inviteCode);
|
@Field("inviteCode") String inviteCode);
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ticket
|
|
||||||
* @param uid
|
|
||||||
* @param nick
|
|
||||||
* @param avatar
|
|
||||||
* @param gender
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@FormUrlEncoded
|
|
||||||
@POST("user/v2/update")
|
|
||||||
Single<ServiceResult<UserInfo>> updateUserInfo(@Field("ticket") String ticket,
|
|
||||||
@Field("uid") long uid,
|
|
||||||
@Field("nick") String nick,
|
|
||||||
@Field("avatar") String avatar,
|
|
||||||
@Field("gender") int gender);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param ticket
|
* @param ticket
|
||||||
|
@@ -25,8 +25,8 @@ import com.mango.xchat_android_library.R;
|
|||||||
*/
|
*/
|
||||||
public class IOSSwitchView extends View {
|
public class IOSSwitchView extends View {
|
||||||
|
|
||||||
private static final int foregroundColor = 0xFFEFEFEF;
|
private static final int foregroundColor = Color.parseColor("#C7DAEA");
|
||||||
private static final int backgroundColor = 0xFFCCCCCC;
|
private static final int backgroundColor = Color.parseColor("#C7DAEA");
|
||||||
|
|
||||||
private int colorStep = backgroundColor;
|
private int colorStep = backgroundColor;
|
||||||
private int mTintColor;
|
private int mTintColor;
|
||||||
@@ -66,6 +66,8 @@ public class IOSSwitchView extends View {
|
|||||||
|
|
||||||
//手势检测器
|
//手势检测器
|
||||||
private GestureDetector mGestureDetector;
|
private GestureDetector mGestureDetector;
|
||||||
|
private boolean mIsNoStrokeColor = false;
|
||||||
|
private boolean mIsKeepRate = true;
|
||||||
|
|
||||||
public IOSSwitchView(Context context) {
|
public IOSSwitchView(Context context) {
|
||||||
this(context, null);
|
this(context, null);
|
||||||
@@ -75,6 +77,7 @@ public class IOSSwitchView extends View {
|
|||||||
this(context, attrs, 0);
|
this(context, attrs, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public IOSSwitchView(Context context, AttributeSet attrs, int defStyleAttr) {
|
public IOSSwitchView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||||
super(context, attrs, defStyleAttr);
|
super(context, attrs, defStyleAttr);
|
||||||
init(context, attrs);
|
init(context, attrs);
|
||||||
@@ -257,7 +260,6 @@ public class IOSSwitchView extends View {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||||
@@ -469,9 +471,11 @@ public class IOSSwitchView extends View {
|
|||||||
public void setOn(boolean on) {
|
public void setOn(boolean on) {
|
||||||
setOn(on, false);
|
setOn(on, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOn(boolean on, boolean isNeedListener) {
|
public void setOn(boolean on, boolean isNeedListener) {
|
||||||
setOn(on, false, isNeedListener);
|
setOn(on, false, isNeedListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOn(boolean on, boolean animate, boolean isNeedListener) {
|
public void setOn(boolean on, boolean animate, boolean isNeedListener) {
|
||||||
if (isOn == on) return;
|
if (isOn == on) return;
|
||||||
|
|
||||||
@@ -540,20 +544,18 @@ public class IOSSwitchView extends View {
|
|||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mIsNoStrokeColor = false;
|
|
||||||
public void setNoStrokeColor(boolean isNoStrokeColor) {
|
public void setNoStrokeColor(boolean isNoStrokeColor) {
|
||||||
mIsNoStrokeColor = isNoStrokeColor;
|
mIsNoStrokeColor = isNoStrokeColor;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean mIsKeepRate = true;
|
|
||||||
public void setmIsKeepRate(boolean isKeepRate) {
|
public void setmIsKeepRate(boolean isKeepRate) {
|
||||||
mIsKeepRate = isKeepRate;
|
mIsKeepRate = isKeepRate;
|
||||||
invalidate();
|
invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSelectedColor() {
|
public int getSelectedColor() {
|
||||||
return 0xFFFF894F;
|
return Color.parseColor("#5FCCE4");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Reference in New Issue
Block a user