私聊改造:UI完善,私聊页代码精简
This commit is contained in:
@@ -616,7 +616,7 @@ public class VoiceMatchActivity extends BaseActivity implements View.OnClickList
|
||||
}
|
||||
if (error == null) {
|
||||
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;
|
||||
|
||||
import static com.mango.moshen.ui.im.recent.RecentContactsFragment.RECENT_TAG_STICKY;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -10,8 +12,9 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.mango.core.decoration.headwear.bean.HeadWearInfo;
|
||||
import com.mango.core.noble.NobleUtil;
|
||||
import com.mango.core.user.UserModel;
|
||||
import com.mango.moshen.R;
|
||||
import com.mango.moshen.UIHelper;
|
||||
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.utils.RegexUtil;
|
||||
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.utils.JavaUtil;
|
||||
|
||||
import java.util.List;
|
||||
import com.mango.xchat_android_library.widget.IOSSwitchView;
|
||||
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
|
||||
@@ -39,6 +46,9 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
private TextView tvAddBlackList;
|
||||
private TextView tvName;
|
||||
private ImageView ivAvatar;
|
||||
private ImageView ivHeadWear;
|
||||
private IOSSwitchView switchTop;
|
||||
private IOSSwitchView switchAddBlack;
|
||||
|
||||
public static void start(Context context, String contactId) {
|
||||
Intent intent = new Intent();
|
||||
@@ -52,26 +62,61 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_nim_add_black_list);
|
||||
|
||||
initWhiteTitleBar("聊天设置");
|
||||
|
||||
initView();
|
||||
account = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
||||
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);
|
||||
tvName = findViewById(R.id.tv_name);
|
||||
tvAddBlackList = findViewById(R.id.tv_add_black_list);
|
||||
ivAvatar = findViewById(R.id.iv_avatar);
|
||||
rlContent.setOnClickListener(this);
|
||||
tvAddBlackList.setOnClickListener(this);
|
||||
findViewById(R.id.tv_report).setOnClickListener(this);
|
||||
List<String> blackListAccount = NimFriendModel.get().getMyBlackListAccount();
|
||||
if (blackListAccount != null) changeText(blackListAccount.contains(account));
|
||||
initTarget();
|
||||
|
||||
switchTop = findViewById(R.id.switch_top);
|
||||
switchAddBlack = findViewById(R.id.switch_add_black);
|
||||
ivHeadWear = findViewById(R.id.iv_head_wear);
|
||||
}
|
||||
|
||||
void changeText(boolean contains) {
|
||||
tvAddBlackList.setText(contains ? "移除黑名单" : "加入黑名单");
|
||||
switchAddBlack.setOn(contains, false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -79,12 +124,23 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
*/
|
||||
@SuppressLint("CheckResult")
|
||||
private void initTarget() {
|
||||
UserModel.get().getUserInfo(Long.valueOf(account)).subscribe(userInfo -> {
|
||||
// 头像
|
||||
ImageLoadUtils.loadAvatar(AddBlackListActivity.this, userInfo.getAvatar(), ivAvatar, true);
|
||||
// 名字
|
||||
tvName.setText(RegexUtil.getPrintableString(userInfo.getNick()));
|
||||
});
|
||||
UserModel.get()
|
||||
.getUserInfo(Long.parseLong(account))
|
||||
.subscribe(userInfo -> {
|
||||
// 头像
|
||||
ImageLoadUtils.loadAvatar(AddBlackListActivity.this, userInfo.getAvatar(), ivAvatar, true);
|
||||
// 名字
|
||||
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,18 +149,7 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
if (v.getId() == R.id.rl_content) {
|
||||
if (!TextUtils.isEmpty(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);
|
||||
}
|
||||
}
|
||||
@@ -116,6 +161,11 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
public void onOk() {
|
||||
getMvpPresenter().removeFromBlackList(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
changeText(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -126,6 +176,11 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
public void onOk() {
|
||||
getMvpPresenter().addToBlackList(account);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
changeText(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -152,4 +207,6 @@ public class AddBlackListActivity extends BaseMvpActivity<IAddBlackListView, Add
|
||||
StatusBarUtil.transparencyBar(this);
|
||||
StatusBarUtil.StatusBarLightMode(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -1,31 +1,15 @@
|
||||
package com.mango.moshen.ui.im.avtivity;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
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.ui.im.fragment.MessageFragment;
|
||||
|
||||
import java.util.List;
|
||||
import com.netease.nim.uikit.business.session.constant.Extras;
|
||||
import com.netease.nim.uikit.common.fragment.TFragment;
|
||||
|
||||
/**
|
||||
* Created by zhoujianghua on 2015/9/10.
|
||||
@@ -36,22 +20,16 @@ public abstract class NewBaseMessageActivity extends BaseActivity {
|
||||
|
||||
protected String sessionId;
|
||||
protected MessageFragment messageFragment;
|
||||
private SessionCustomization customization;
|
||||
private Toolbar toolbar;
|
||||
|
||||
protected abstract MessageFragment fragment(Intent intent);
|
||||
|
||||
protected abstract int getContentViewId();
|
||||
|
||||
protected abstract void initToolBar();
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(getContentViewId());
|
||||
initToolBar();
|
||||
parseIntent();
|
||||
|
||||
messageFragment = (MessageFragment) switchContent(fragment(getIntent()));
|
||||
}
|
||||
|
||||
@@ -84,49 +62,10 @@ public abstract class NewBaseMessageActivity extends BaseActivity {
|
||||
if (messageFragment != null) {
|
||||
messageFragment.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
if (customization != null) {
|
||||
customization.onActivityResult(this, requestCode, resultCode, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseIntent() {
|
||||
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;
|
||||
}
|
||||
|
||||
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.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.mango.core.audio.event.VoiceShakeHeartEvent;
|
||||
import com.mango.core.auth.AuthModel;
|
||||
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.event.IsLikedEvent;
|
||||
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.bean.UserDetailInfo;
|
||||
import com.mango.core.user.bean.UserInfo;
|
||||
import com.mango.core.utils.StringExtensionKt;
|
||||
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.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.user.UserInfoActivity;
|
||||
import com.mango.moshen.ui.utils.ImageLoadUtils;
|
||||
import com.mango.xchat_android_library.utils.ListUtils;
|
||||
import com.mango.xchat_android_library.utils.JavaUtil;
|
||||
import com.mango.xchat_android_library.utils.SingleToastUtil;
|
||||
import com.netease.nim.uikit.StatusBarUtil;
|
||||
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.wrapper.NimToolBarOptions;
|
||||
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.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.Observer;
|
||||
@@ -63,9 +45,6 @@ import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
|
||||
/**
|
||||
* 点对点聊天界面
|
||||
* <p/>
|
||||
@@ -73,15 +52,9 @@ import io.reactivex.functions.Consumer;
|
||||
*/
|
||||
public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
|
||||
public static final String IS_BY_MATCH = "isByMatch";
|
||||
private static final String TAG = "NimP2PMessageActivity";
|
||||
private final OnlineStateChangeObserver onlineStateChangeObserver = accounts -> {
|
||||
// 更新 toolbar
|
||||
if (accounts.contains(sessionId)) {
|
||||
// 按照交互来展示
|
||||
displayOnlineState();
|
||||
}
|
||||
};
|
||||
TextView tvToolbarTitle;
|
||||
TextView tvAddBlackTip;
|
||||
private boolean isResume = false;
|
||||
/**
|
||||
* 命令消息接收观察者
|
||||
@@ -92,10 +65,12 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
}
|
||||
showCommandMessage(message);
|
||||
};
|
||||
private TextView ivAddBlackList;
|
||||
private View ivAddBlackList;
|
||||
private TextView tvTips;
|
||||
private View tipsLayout;
|
||||
private ImageView closeIcon;
|
||||
private View ivAttention;
|
||||
private View tvOnlineTip;
|
||||
@Nullable
|
||||
private UserInfo buddyUserInfo;
|
||||
private final ContactChangedObserver friendDataChangedObserver = new ContactChangedObserver() {
|
||||
@@ -119,74 +94,55 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
displayAntiFraudTips();
|
||||
}
|
||||
};
|
||||
private ImageView ivAttention;
|
||||
private UserInfoObserver uinfoObserver;
|
||||
|
||||
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.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_CUSTOMIZATION, NimUIKitImpl.commonP2PSessionCustomization);
|
||||
intent.setClass(context, NimP2PMessageActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||
context.startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getContentViewId() {
|
||||
return R.layout.activity_p2p_message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
tipsLayout = findViewById(R.id.rl_tips);
|
||||
closeIcon = findViewById(R.id.iv_close_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 -> {
|
||||
IMFriendModel.get().addCloseTipsAccount(sessionId);
|
||||
tipsLayout.setVisibility(View.GONE);
|
||||
});
|
||||
// 单聊特例话数据,包括个人信息,黑名单
|
||||
findViewById(R.id.iv_back).setOnClickListener(v -> finish());
|
||||
|
||||
addBlackList();
|
||||
requestBuddyInfo();
|
||||
displayOnlineState();
|
||||
registerObservers(true);
|
||||
registerOnlineStateChangeListener(true);
|
||||
EventBus.getDefault().register(this);
|
||||
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;
|
||||
buddyUserInfo = null;
|
||||
addBlackList();
|
||||
requestBuddyInfo();
|
||||
displayOnlineState();
|
||||
displayAntiFraudTips();
|
||||
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
||||
}
|
||||
}
|
||||
@@ -210,22 +166,18 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
}
|
||||
|
||||
private void addBlackList() {
|
||||
if (SystemUidUtil.isSystemUid(sessionId)) return;
|
||||
ivAddBlackList = findViewById(R.id.iv_add_black_list);
|
||||
if (SystemUidUtil.isSystemUid(sessionId)) {
|
||||
ivAddBlackList.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
ivAddBlackList.setVisibility(View.VISIBLE);
|
||||
ivAddBlackList.setOnClickListener((view) -> {
|
||||
// 跳转到加入黑名单
|
||||
String account = getIntent().getStringExtra(Extras.EXTRA_ACCOUNT);
|
||||
AddBlackListActivity.start(NimP2PMessageActivity.this, account);
|
||||
});
|
||||
|
||||
ivAddBlackList.setOnClickListener((view) -> AddBlackListActivity.start(this, sessionId));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
registerObservers(false);
|
||||
registerOnlineStateChangeListener(false);
|
||||
EventBus.getDefault().unregister(this);
|
||||
}
|
||||
|
||||
@@ -241,144 +193,48 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
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")
|
||||
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>() {
|
||||
@Override
|
||||
public void accept(UserInfo userInfo) throws Exception {
|
||||
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);
|
||||
UserModel.get().getUserInfo(uid)
|
||||
.subscribe(userInfo -> {
|
||||
tvToolbarTitle.setText(userInfo.getNick());
|
||||
buddyUserInfo = userInfo;
|
||||
displayAntiFraudTips();
|
||||
});
|
||||
|
||||
ivAttention = (ImageView) findViewById(R.id.iv_attention);
|
||||
if (AuthModel.get().getCurrentUid() != userInfo.getUid()) {
|
||||
PraiseModel.get().isPraised(AuthModel.get().getCurrentUid(), userInfo.getUid()).subscribe();
|
||||
}
|
||||
buddyUserInfo = userInfo;
|
||||
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);
|
||||
List<String> blackListAccount = NimFriendModel.get().getMyBlackListAccount();
|
||||
tvAddBlackTip.setVisibility(View.GONE);
|
||||
if (!ListUtils.isListEmpty(blackListAccount)) {
|
||||
boolean contains = blackListAccount.contains(sessionId);
|
||||
tvAddBlackTip.setVisibility(contains ? View.VISIBLE : View.GONE);
|
||||
if (NimFriendModel.get().isInMyBlackList(sessionId)) {
|
||||
tvAddBlackTip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
tvAddBlackTip.setVisibility(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) {
|
||||
if (register) {
|
||||
registerUserInfoObserver();
|
||||
} else {
|
||||
unregisterUserInfoObserver();
|
||||
}
|
||||
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() {
|
||||
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) {
|
||||
if (!isResume) {
|
||||
return;
|
||||
@@ -407,46 +263,19 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
arguments = new Bundle();
|
||||
}
|
||||
arguments.putSerializable(Extras.EXTRA_TYPE, SessionTypeEnum.P2P);
|
||||
String gameId = intent.getStringExtra("gameId");
|
||||
if (!TextUtils.isEmpty(gameId)) {
|
||||
arguments.putString("gameId", gameId);
|
||||
}
|
||||
MessageFragment fragment = new MessageFragment();
|
||||
fragment.setArguments(arguments);
|
||||
fragment.setContainerId(R.id.message_fragment_container);
|
||||
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)
|
||||
public void onIsLiked(IsLikedEvent event) {
|
||||
if (event.isLiked) {
|
||||
ivAttention.setVisibility(View.GONE);
|
||||
} else {
|
||||
ivAttention.setVisibility(View.VISIBLE);
|
||||
ivAttention.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PraiseModel.get().praise(Long.valueOf(sessionId), true).subscribe();
|
||||
}
|
||||
});
|
||||
ivAttention.setOnClickListener(v -> PraiseModel.get().praise(Long.valueOf(sessionId), true).subscribe());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,18 +289,10 @@ public class NimP2PMessageActivity extends NewBaseMessageActivity {
|
||||
toast(event.getError());
|
||||
return;
|
||||
}
|
||||
ivAttention.setVisibility(View.GONE);
|
||||
ivAttention.setOnClickListener(null);
|
||||
ivAttention.setVisibility(event.isPraise() ? View.GONE : View.VISIBLE);
|
||||
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
|
||||
protected boolean needSteepStateBar() {
|
||||
return true;
|
||||
|
@@ -2,6 +2,7 @@ package com.mango.moshen.ui.im.chat;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
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.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.bean.UserPhoto;
|
||||
import com.mango.core.utils.StarUtils;
|
||||
@@ -54,6 +57,7 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
||||
private TextView tvConstellation;
|
||||
private TextView tvDesc;
|
||||
private RecyclerView rvPhotos;
|
||||
private ImageView ivHeadWear;
|
||||
|
||||
public MsgViewHolderUserCard(BaseMultiItemFetchLoadAdapter adapter) {
|
||||
super(adapter);
|
||||
@@ -78,6 +82,11 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
||||
tvConstellation = findViewById(R.id.tv_constellation);
|
||||
tvDesc = findViewById(R.id.tv_desc);
|
||||
rvPhotos = findViewById(R.id.rv_photos);
|
||||
ivHeadWear = findViewById(R.id.iv_head_wear);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
if (photoAdapter == null) {
|
||||
photoAdapter = new BaseQuickAdapter<UserPhoto, BaseViewHolder>(R.layout.item_p2p_user_photo) {
|
||||
@Override
|
||||
@@ -98,7 +107,6 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void showUserPhoto(int position) {
|
||||
//创建一个集合拿来做用户所有照片信息
|
||||
ArrayList<UserPhoto> userPhotos = new ArrayList<>();
|
||||
@@ -135,6 +143,16 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
||||
tvConstellation.setVisibility(View.VISIBLE);
|
||||
}
|
||||
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
|
||||
@@ -169,16 +187,6 @@ public class MsgViewHolderUserCard extends MsgViewHolderBase {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void bindContentView() {
|
||||
|
||||
}
|
||||
|
||||
// 内容区域点击事件响应处理。
|
||||
protected void onItemClick() {
|
||||
|
||||
}
|
||||
|
||||
// 内容区域长按事件响应处理。该接口的优先级比adapter中有长按事件的处理监听高,当该接口返回为true时,adapter的长按事件监听不会被调用到。
|
||||
protected boolean onItemLongClick() {
|
||||
return true;
|
||||
|
@@ -450,28 +450,30 @@ public class RecentContactsFragment extends TFragment {
|
||||
@Override
|
||||
public void run() {
|
||||
// 查询最近联系人列表数据
|
||||
NIMClient.getService(MsgService.class).queryRecentContacts().setCallback(new RequestCallbackWrapper<List<RecentContact>>() {
|
||||
NIMClient.getService(MsgService.class)
|
||||
.queryRecentContacts()
|
||||
.setCallback(new RequestCallbackWrapper<List<RecentContact>>() {
|
||||
|
||||
@Override
|
||||
public void onResult(int code, List<RecentContact> recents, Throwable exception) {
|
||||
if (code != ResponseCode.RES_SUCCESS || recents == null) {
|
||||
return;
|
||||
}
|
||||
loadedRecents = recents;
|
||||
// 初次加载,更新离线的消息中是否有@我的消息
|
||||
for (RecentContact loadedRecent : loadedRecents) {
|
||||
if (loadedRecent.getSessionType() == SessionTypeEnum.Team) {
|
||||
updateOfflineContactAited(loadedRecent);
|
||||
@Override
|
||||
public void onResult(int code, List<RecentContact> recents, Throwable exception) {
|
||||
if (code != ResponseCode.RES_SUCCESS || recents == null) {
|
||||
return;
|
||||
}
|
||||
loadedRecents = recents;
|
||||
// 初次加载,更新离线的消息中是否有@我的消息
|
||||
for (RecentContact loadedRecent : loadedRecents) {
|
||||
if (loadedRecent.getSessionType() == SessionTypeEnum.Team) {
|
||||
updateOfflineContactAited(loadedRecent);
|
||||
}
|
||||
}
|
||||
// 此处如果是界面刚初始化,为了防止界面卡顿,可先在后台把需要显示的用户资料和群组资料在后台加载好,然后再刷新界面
|
||||
//
|
||||
msgLoaded = true;
|
||||
if (isAdded()) {
|
||||
onRecentContactsLoaded();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 此处如果是界面刚初始化,为了防止界面卡顿,可先在后台把需要显示的用户资料和群组资料在后台加载好,然后再刷新界面
|
||||
//
|
||||
msgLoaded = true;
|
||||
if (isAdded()) {
|
||||
onRecentContactsLoaded();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, delay ? 250 : 0);
|
||||
}
|
||||
|
@@ -265,12 +265,6 @@ public class JSInterface {
|
||||
mPosition = position;
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void challenge(long uid, String gameId) {
|
||||
StatisticManager.Instance().onEvent(StatisticsProtocol.gamelist_challenge, "挑战按钮");
|
||||
NimP2PMessageActivity.start(context, uid + "", gameId);
|
||||
}
|
||||
|
||||
@JavascriptInterface
|
||||
public void clipboardToPhone(String content) {
|
||||
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"
|
||||
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
|
||||
android:id="@+id/tv_name"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -75,17 +83,30 @@
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_add_top"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@color/bg_secondary_2a2a39"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:text="置顶聊天"
|
||||
android:textColor="@color/text_title_white"
|
||||
android:textSize="14sp" />
|
||||
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:textColor="@color/text_title_white"
|
||||
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
|
||||
android:layout_width="match_parent"
|
||||
@@ -94,16 +115,31 @@
|
||||
android:layout_marginEnd="12dp"
|
||||
android:background="@color/line_353548" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_add_black_list"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="44dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:background="@color/bg_secondary_2a2a39"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingStart="16dp"
|
||||
android:text="加入黑名单"
|
||||
android:textColor="@color/text_title_white"
|
||||
android:textSize="14sp" />
|
||||
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:textColor="@color/text_title_white"
|
||||
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
|
||||
android:layout_width="match_parent"
|
||||
|
@@ -1,137 +1,160 @@
|
||||
<?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:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg_normal_1c1b22"
|
||||
android:paddingTop="30dp">
|
||||
android:background="@color/white"
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="44dp">
|
||||
|
||||
<LinearLayout
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
android:layout_height="44dp">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
android:id="@+id/app_bar_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:theme="@style/AppTheme.AppBarOverlay"
|
||||
app:elevation="0dp">
|
||||
<ImageView
|
||||
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" />
|
||||
|
||||
<androidx.appcompat.widget.Toolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:background="@color/bg_normal_1c1b22"
|
||||
app:subtitleTextAppearance="@style/Toolbar.SubTitleText"
|
||||
app:titleTextAppearance="@style/Toolbar.TitleText">
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:maxWidth="214dp"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textAppearance="@style/Toolbar.TitleText"
|
||||
android:textColor="@color/text_title_white"
|
||||
android:visibility="gone"
|
||||
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" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_add_black_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="4dp"
|
||||
android:text="已经加入黑名单"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="12dp" />
|
||||
</LinearLayout>
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/iv_add_black_list"
|
||||
android:layout_width="?attr/actionBarSize"
|
||||
android:layout_height="?attr/actionBarSize"
|
||||
android:layout_gravity="right"
|
||||
android:gravity="center"
|
||||
android:src="@drawable/icon_add_black_list"
|
||||
android:text="举报"
|
||||
android:id="@+id/tv_toolbar_title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:ellipsize="end"
|
||||
android:includeFontPadding="false"
|
||||
android:maxWidth="120dp"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="16sp"
|
||||
tools:text="孙行者123孙行者123孙行者123孙行者123孙行者123孙行者123"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="3dp"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_add_black_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:text="已经加入黑名单"
|
||||
android:textColor="@color/text_normal_c6c6e9"
|
||||
android:textSize="@dimen/dp_13"
|
||||
android:textSize="10dp"
|
||||
android:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_online_tip"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:drawableStart="@drawable/ic_p2p_live"
|
||||
android:drawableEnd="@drawable/arrow_right"
|
||||
android:drawablePadding="3dp"
|
||||
android:gravity="center"
|
||||
android:text="直播中"
|
||||
android:textColor="#ffbabbcd"
|
||||
android:textSize="10sp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
</androidx.appcompat.widget.Toolbar>
|
||||
</LinearLayout>
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_tips"
|
||||
<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>
|
||||
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/rl_tips"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_30"
|
||||
android:orientation="horizontal">
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_FEE4E4" />
|
||||
|
||||
<View
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/color_FEE4E4" />
|
||||
<TextView
|
||||
android:id="@+id/tv_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="温馨提示:对方和您非好友关系,请注意隐私安全!"
|
||||
android:textColor="@color/color_ff5454"
|
||||
android:textSize="@dimen/dp_12"
|
||||
tools:ignore="SpUsage" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerInParent="true"
|
||||
android:text="温馨提示:对方和您非好友关系,请注意隐私安全!"
|
||||
android:textColor="@color/color_ff5454"
|
||||
android:textSize="@dimen/dp_12"
|
||||
tools:ignore="SpUsage" />
|
||||
<ImageView
|
||||
android:id="@+id/iv_close_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/dp_15"
|
||||
android:paddingTop="@dimen/dp_11"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:paddingBottom="@dimen/dp_11"
|
||||
android:src="@mipmap/common_ic_close_red" />
|
||||
</RelativeLayout>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_close_tips"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:paddingStart="@dimen/dp_15"
|
||||
android:paddingTop="@dimen/dp_11"
|
||||
android:paddingEnd="@dimen/dp_15"
|
||||
android:paddingBottom="@dimen/dp_11"
|
||||
android:src="@mipmap/common_ic_close_red" />
|
||||
</RelativeLayout>
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/message_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/bg_normal_1c1b22" />
|
||||
|
||||
<androidx.fragment.app.FragmentContainerView
|
||||
android:id="@+id/message_fragment_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
@@ -129,6 +129,17 @@
|
||||
app:layout_constraintStart_toStartOf="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
|
||||
android:id="@+id/tv_nick"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -137,7 +148,7 @@
|
||||
android:textColor="@color/color_333333"
|
||||
android:textSize="16dp"
|
||||
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_constraintVertical_chainStyle="packed"
|
||||
tools:text="这就是大哥呀呀" />
|
||||
|
@@ -558,7 +558,7 @@
|
||||
<!-- 主题色 -->
|
||||
<color name="app_248cfe">#5FCCE4</color>
|
||||
<!-- 页面背景色 -->
|
||||
<color name="bg_normal_1c1b22">#FFF3F5FA</color>
|
||||
<color name="bg_normal_1c1b22">#F4F4FA</color>
|
||||
<!-- 页面次级背景 列表item背景色-->
|
||||
<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.xchat_android_library.utils.SingleToastUtil;
|
||||
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.business.session.constant.Extras;
|
||||
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 java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* 点对点聊天界面
|
||||
@@ -48,51 +43,16 @@ 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);
|
||||
Observer<CustomNotification> commandObserver = message -> {
|
||||
if (!sessionId.equals(message.getSessionId()) || message.getSessionType() != SessionTypeEnum.P2P) {
|
||||
return;
|
||||
}
|
||||
showCommandMessage(message);
|
||||
};
|
||||
private View tipsLayout;
|
||||
private ImageView closeIcon;
|
||||
@@ -116,13 +76,8 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
// 单聊特例话数据,包括个人信息,黑名单
|
||||
//addBlackList();
|
||||
// setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
|
||||
requestBuddyInfo();
|
||||
displayOnlineState();
|
||||
registerObservers(true);
|
||||
registerOnlineStateChangeListener(true);
|
||||
IMNetEaseManager.get().getChatRoomEventObservable()
|
||||
.compose(bindToLifecycle())
|
||||
.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)) {
|
||||
this.sessionId = sessionId;
|
||||
requestBuddyInfo();
|
||||
displayOnlineState();
|
||||
displayAntiFraudTips();
|
||||
messageFragment = (MessageFragment) switchContent(fragment(intent));
|
||||
}
|
||||
@@ -173,7 +127,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
registerObservers(false);
|
||||
registerOnlineStateChangeListener(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -205,32 +158,14 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
unregisterUserInfoObserver();
|
||||
}
|
||||
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() {
|
||||
if (uinfoObserver == null) {
|
||||
uinfoObserver = new UserInfoObserver() {
|
||||
@Override
|
||||
public void onUserInfoChanged(List<String> accounts) {
|
||||
if (accounts.contains(sessionId)) {
|
||||
requestBuddyInfo();
|
||||
}
|
||||
uinfoObserver = accounts -> {
|
||||
if (accounts.contains(sessionId)) {
|
||||
requestBuddyInfo();
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -276,11 +211,6 @@ public class NimRoomP2PMessageActivity extends NewBaseMessageActivity {
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initToolBar() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean needSteepStateBar() {
|
||||
return false;
|
||||
|
@@ -885,22 +885,6 @@ public final class UserModel extends BaseModel implements IUserModel {
|
||||
@Field("shareCode") String shareCode,
|
||||
@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
|
||||
|
@@ -25,8 +25,8 @@ import com.mango.xchat_android_library.R;
|
||||
*/
|
||||
public class IOSSwitchView extends View {
|
||||
|
||||
private static final int foregroundColor = 0xFFEFEFEF;
|
||||
private static final int backgroundColor = 0xFFCCCCCC;
|
||||
private static final int foregroundColor = Color.parseColor("#C7DAEA");
|
||||
private static final int backgroundColor = Color.parseColor("#C7DAEA");
|
||||
|
||||
private int colorStep = backgroundColor;
|
||||
private int mTintColor;
|
||||
@@ -66,6 +66,8 @@ public class IOSSwitchView extends View {
|
||||
|
||||
//手势检测器
|
||||
private GestureDetector mGestureDetector;
|
||||
private boolean mIsNoStrokeColor = false;
|
||||
private boolean mIsKeepRate = true;
|
||||
|
||||
public IOSSwitchView(Context context) {
|
||||
this(context, null);
|
||||
@@ -75,6 +77,7 @@ public class IOSSwitchView extends View {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
|
||||
public IOSSwitchView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs);
|
||||
@@ -257,7 +260,6 @@ public class IOSSwitchView extends View {
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
@@ -469,9 +471,11 @@ public class IOSSwitchView extends View {
|
||||
public void setOn(boolean on) {
|
||||
setOn(on, false);
|
||||
}
|
||||
|
||||
public void setOn(boolean on, boolean isNeedListener) {
|
||||
setOn(on, false, isNeedListener);
|
||||
}
|
||||
|
||||
public void setOn(boolean on, boolean animate, boolean isNeedListener) {
|
||||
if (isOn == on) return;
|
||||
|
||||
@@ -540,20 +544,18 @@ public class IOSSwitchView extends View {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private boolean mIsNoStrokeColor = false;
|
||||
public void setNoStrokeColor(boolean isNoStrokeColor) {
|
||||
mIsNoStrokeColor = isNoStrokeColor;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
private boolean mIsKeepRate = true;
|
||||
public void setmIsKeepRate(boolean isKeepRate) {
|
||||
mIsKeepRate = isKeepRate;
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public int getSelectedColor() {
|
||||
return 0xFFFF894F;
|
||||
return Color.parseColor("#5FCCE4");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user