1158 lines
47 KiB
Java
1158 lines
47 KiB
Java
package com.yizhuan.erban;
|
||
|
||
import android.animation.ObjectAnimator;
|
||
import android.annotation.SuppressLint;
|
||
import android.app.Activity;
|
||
import android.content.Context;
|
||
import android.content.Intent;
|
||
import android.graphics.Color;
|
||
import android.os.Bundle;
|
||
import android.os.Handler;
|
||
import android.text.TextUtils;
|
||
import android.util.Log;
|
||
import android.util.SparseArray;
|
||
import android.view.KeyEvent;
|
||
import android.view.View;
|
||
import android.view.animation.LinearInterpolator;
|
||
import android.widget.LinearLayout;
|
||
import android.widget.TextView;
|
||
|
||
import androidx.annotation.NonNull;
|
||
import androidx.annotation.Nullable;
|
||
import androidx.fragment.app.Fragment;
|
||
import androidx.fragment.app.FragmentTransaction;
|
||
import androidx.lifecycle.ViewModelProvider;
|
||
|
||
import com.idlefish.flutterboost.FlutterBoost;
|
||
import com.netease.nim.uikit.StatusBarUtil;
|
||
import com.netease.nim.uikit.api.NimUIKit;
|
||
import com.netease.nim.uikit.api.model.contact.ContactEventListener;
|
||
import com.netease.nim.uikit.api.model.session.SessionCustomization;
|
||
import com.netease.nim.uikit.api.model.session.SessionEventListener;
|
||
import com.netease.nim.uikit.business.session.actions.BaseAction;
|
||
import com.netease.nim.uikit.business.session.actions.ImageAction;
|
||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||
import com.netease.nim.uikit.common.util.string.StringUtil;
|
||
import com.netease.nim.uikit.impl.cache.NimUserInfoCache;
|
||
import com.netease.nimlib.sdk.NIMClient;
|
||
import com.netease.nimlib.sdk.RequestCallbackWrapper;
|
||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomKickOutEvent;
|
||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||
import com.netease.nimlib.sdk.team.TeamService;
|
||
import com.netease.nimlib.sdk.team.constant.TeamMessageNotifyTypeEnum;
|
||
import com.netease.nimlib.sdk.team.model.Team;
|
||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||
import com.orhanobut.logger.Logger;
|
||
import com.tencent.bugly.crashreport.CrashReport;
|
||
import com.trello.rxlifecycle3.android.ActivityEvent;
|
||
import com.yizhuan.erban.application.ActivityStackManager;
|
||
import com.yizhuan.erban.avroom.activity.AVRoomActivity;
|
||
import com.yizhuan.erban.avroom.ktv.KtvMusicManager;
|
||
import com.yizhuan.erban.base.BaseMvpActivity;
|
||
import com.yizhuan.erban.common.widget.CircleImageView;
|
||
import com.yizhuan.erban.common.widget.DragLayout;
|
||
import com.yizhuan.erban.community.dynamic.view.DynamicDetailActivity;
|
||
import com.yizhuan.erban.community.holder.DynamicSysHolder;
|
||
import com.yizhuan.erban.community.im.WorldDynamicShareViewHolder;
|
||
import com.yizhuan.erban.community.publish.view.PublishActivity;
|
||
import com.yizhuan.erban.community.square.SquareFragment;
|
||
import com.yizhuan.erban.family.view.activity.FamilyHomeActivity;
|
||
import com.yizhuan.erban.home.HomeViewModel;
|
||
import com.yizhuan.erban.home.dialog.ProtocolUpdateDialog;
|
||
import com.yizhuan.erban.flutter.RouterConstants;
|
||
import com.yizhuan.erban.home.fragment.ContactsListFragment;
|
||
import com.yizhuan.erban.home.fragment.GameFragment;
|
||
import com.yizhuan.erban.home.fragment.HomeFragment;
|
||
import com.yizhuan.erban.home.fragment.MeFragment;
|
||
import com.yizhuan.erban.home.presenter.MainPresenter;
|
||
import com.yizhuan.erban.home.view.IMainView;
|
||
import com.yizhuan.erban.luckymoney.viewholder.LuckyMoneyMsgViewHolder;
|
||
import com.yizhuan.erban.luckymoney.viewholder.LuckyMoneyTipsViewHolder;
|
||
import com.yizhuan.erban.main.helper.NoticationsUiHelper;
|
||
import com.yizhuan.erban.miniworld.activity.MiniWorldGuestPageActivity;
|
||
import com.yizhuan.erban.module.Extras;
|
||
import com.yizhuan.erban.module_hall.HallDataManager;
|
||
import com.yizhuan.erban.module_hall.secretcode.PwdCodeMgr;
|
||
import com.yizhuan.erban.public_chat_hall.msg.viewholder.MsgViewHolderAitMe;
|
||
import com.yizhuan.erban.quick_pass.QuickPassLoginAct;
|
||
import com.yizhuan.erban.radish.signin.SignDialogTimeManager;
|
||
import com.yizhuan.erban.service.DaemonService;
|
||
import com.yizhuan.erban.share.viewholder.InAppSharingMsgViewHolder;
|
||
import com.yizhuan.erban.ui.im.actions.GiftAction;
|
||
import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLevel;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLottery;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderMatch;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderOnline;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPackage;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderRedPacket;
|
||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderText;
|
||
import com.yizhuan.erban.ui.im.chat.SignInNoticeMsgViewHolder;
|
||
import com.yizhuan.erban.ui.im.chat.SysMsgV2ViewHolder;
|
||
import com.yizhuan.erban.ui.im.chat.SysMsgViewHolder;
|
||
import com.yizhuan.erban.ui.login.BindPhoneActivity;
|
||
import com.yizhuan.erban.ui.login.fragment.AddUserInfoFragment;
|
||
import com.yizhuan.erban.ui.patriarch.help.LimitEnterRoomHelper;
|
||
import com.yizhuan.erban.ui.patriarch.help.PmDialogShowMrg;
|
||
import com.yizhuan.erban.ui.user.UserInfoActivity;
|
||
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||
import com.yizhuan.erban.ui.utils.ImageLoadUtilsV2;
|
||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
|
||
import com.yizhuan.erban.ui.widget.LevelUpDialog;
|
||
import com.yizhuan.erban.ui.widget.LivingIconView;
|
||
import com.yizhuan.erban.ui.widget.MainTabLayout;
|
||
import com.yizhuan.erban.ui.widget.RecallDialog;
|
||
import com.yizhuan.erban.utils.CleanLeakUtils;
|
||
import com.yizhuan.erban.utils.PushMessageHandler;
|
||
import com.yizhuan.xchat_android_core.Constants;
|
||
import com.yizhuan.xchat_android_core.UriProvider;
|
||
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||
import com.yizhuan.xchat_android_core.auth.event.KickOutEvent;
|
||
import com.yizhuan.xchat_android_core.auth.event.LoginEvent;
|
||
import com.yizhuan.xchat_android_core.auth.event.LogoutEvent;
|
||
import com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel;
|
||
import com.yizhuan.xchat_android_core.community.attachment.DynamicSysAttachment;
|
||
import com.yizhuan.xchat_android_core.community.event.SquareTaskEvent;
|
||
import com.yizhuan.xchat_android_core.community.event.UnReadCountEvent;
|
||
import com.yizhuan.xchat_android_core.home.bean.MainTabType;
|
||
import com.yizhuan.xchat_android_core.home.event.VisitorUnreadCountEvent;
|
||
import com.yizhuan.xchat_android_core.community.im.WorldDynamicAttachment;
|
||
import com.yizhuan.xchat_android_core.home.model.GameHomeModel;
|
||
import com.yizhuan.xchat_android_core.home.model.HomeModel;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.AssistantAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingMiniWorldAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingRoomAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingTeamAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.LevelUpAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.LotteryAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.LuckyMoneyAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.LuckyMoneyTipsAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.MatchAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.NewbieHelloAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.NobleAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.NoticeAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.OpenRoomNotiAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.OpenSignInAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPackageAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.RedPacketAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.SysMsgAttachment;
|
||
import com.yizhuan.xchat_android_core.im.custom.bean.SysMsgV2Attachment;
|
||
import com.yizhuan.xchat_android_core.initial.InitialModel;
|
||
import com.yizhuan.xchat_android_core.level.event.CharmLevelUpEvent;
|
||
import com.yizhuan.xchat_android_core.level.event.LevelUpEvent;
|
||
import com.yizhuan.xchat_android_core.linked.LinkedModel;
|
||
import com.yizhuan.xchat_android_core.linked.bean.LinkedInfo;
|
||
import com.yizhuan.xchat_android_core.manager.AudioEngineManager;
|
||
import com.yizhuan.xchat_android_core.manager.AvRoomDataManager;
|
||
import com.yizhuan.xchat_android_core.manager.IMBroadcastManager;
|
||
import com.yizhuan.xchat_android_core.manager.IMMessageManager;
|
||
import com.yizhuan.xchat_android_core.manager.RoomEvent;
|
||
import com.yizhuan.xchat_android_core.miniworld.bean.OpenAudioPartyAttachment;
|
||
import com.yizhuan.xchat_android_core.patriarch.event.CloseMinRoomEvent;
|
||
import com.yizhuan.xchat_android_core.patriarch.event.ImPushMsgPmLimitTimeEvent;
|
||
import com.yizhuan.xchat_android_core.patriarch.event.PmDismissAllLimitDialogEvent;
|
||
import com.yizhuan.xchat_android_core.pay.bean.ShowCommonWebEvent;
|
||
import com.yizhuan.xchat_android_core.public_chat_hall.attachment.AitMeAttachment;
|
||
import com.yizhuan.xchat_android_core.recall.bean.CheckLostUserInfo;
|
||
import com.yizhuan.xchat_android_core.recall.event.CheckLostUserEvent;
|
||
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
|
||
import com.yizhuan.xchat_android_core.statistic.StatisticManager;
|
||
import com.yizhuan.xchat_android_core.statistic.protocol.StatisticsProtocol;
|
||
import com.yizhuan.xchat_android_core.user.UserModel;
|
||
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
|
||
import com.yizhuan.xchat_android_core.user.event.LoadLoginUserInfoEvent;
|
||
import com.yizhuan.xchat_android_core.user.event.LoginUserInfoUpdateEvent;
|
||
import com.yizhuan.xchat_android_core.user.event.NeedBindPhoneEvent;
|
||
import com.yizhuan.xchat_android_core.user.event.NeedCompleteInfoEvent;
|
||
import com.yizhuan.xchat_android_core.utils.SharedPreferenceUtils;
|
||
import com.yizhuan.xchat_android_core.utils.StringUtils;
|
||
import com.yizhuan.xchat_android_library.base.factory.CreatePresenter;
|
||
import com.yizhuan.xchat_android_library.threadmgr.ThreadPoolManager;
|
||
import com.yizhuan.xchat_android_library.utils.JavaUtil;
|
||
import com.yizhuan.xchat_android_library.utils.codec.DESUtils;
|
||
|
||
import org.greenrobot.eventbus.EventBus;
|
||
import org.greenrobot.eventbus.Subscribe;
|
||
import org.greenrobot.eventbus.ThreadMode;
|
||
import org.jetbrains.annotations.NotNull;
|
||
|
||
import java.lang.ref.WeakReference;
|
||
import java.util.ArrayList;
|
||
import java.util.List;
|
||
|
||
import io.flutter.embedding.android.FlutterFragment;
|
||
|
||
import static com.yizhuan.xchat_android_core.channel_page.model.ChannelPageModel.KEY_FLAG_VALID_CHANNEL_PAGE;
|
||
|
||
/**
|
||
* @author Administrator
|
||
*/
|
||
@CreatePresenter(MainPresenter.class)
|
||
public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
|
||
implements MainTabLayout.OnTabClickListener, IMainView, View.OnClickListener {
|
||
|
||
public static final String MSG_TAB = "msgTab";
|
||
public static final String GAME_TAB = "gameTab";
|
||
private static final String TAG = "MainActivity";
|
||
private static final String EXTRA_APP_QUIT = "APP_QUIT";
|
||
private final SparseArray<Fragment> fragmentArray = new SparseArray<>();
|
||
private DragLayout avatarLayout;
|
||
private TextView tvName;//最小化窗口名称
|
||
private TextView tvId;//最小化窗口ID
|
||
private CircleImageView avatarImage;
|
||
private LinearLayout llDragInfo;
|
||
private LivingIconView userLivingView;
|
||
private View viewClose;
|
||
private MainTabLayout mMainTabLayout;
|
||
private int mCurrentTabType = MainTabType.TAB_TYPE_HOME;
|
||
/**
|
||
* 房间最小化动画,换成属性动画,原先的补间动画影响了activity的生命周期
|
||
*/
|
||
private ObjectAnimator roomMinAnim;
|
||
/**
|
||
* 管理限制进房
|
||
*/
|
||
private LimitEnterRoomHelper limitEnterRoomHelper;
|
||
private HomeViewModel homeViewModel;
|
||
@Nullable
|
||
private Fragment tempFragment = null;
|
||
private ContactEventListener listener1 = new ContactEventListener() {
|
||
@Override
|
||
public void onItemClick(Context context, String account) {
|
||
NimP2PMessageActivity.start(context, account);
|
||
}
|
||
|
||
@Override
|
||
public void onItemLongClick(Context context, String account) {
|
||
|
||
}
|
||
|
||
@Override
|
||
public void onAvatarClick(Context context, String account) {
|
||
UserInfoActivity.Companion.start(MainActivity.this, Long.parseLong(account));
|
||
}
|
||
};
|
||
private SessionEventListener listener = new SessionEventListener() {
|
||
@Override
|
||
public void onAvatarClicked(Context context, IMMessage message) {
|
||
if (message == null) return;
|
||
UserInfoActivity.Companion.start(MainActivity.this, Long.parseLong(message.getFromAccount()));
|
||
}
|
||
|
||
@Override
|
||
public void onAvatarLongClicked(Context context, IMMessage message) {
|
||
|
||
}
|
||
};
|
||
|
||
{
|
||
fragmentArray.put(MainTabType.TAB_TYPE_HOME, new HomeFragment());
|
||
fragmentArray.put(MainTabType.TAB_TYPE_MSG, new ContactsListFragment());
|
||
fragmentArray.put(MainTabType.TAB_TYPE_SQUARE, new SquareFragment());
|
||
fragmentArray.put(MainTabType.TAB_TYPE_ME, new MeFragment());
|
||
fragmentArray.put(MainTabType.TAB_TYPE_GAME, new GameFragment
|
||
.CachedEngineFragmentBuilder(GameFragment.class, FlutterBoost.ENGINE_ID)
|
||
.url(BuildConfig.DEBUG ? RouterConstants.FLUTTER_PAGE_MAIN_DEBUG : RouterConstants.FLUTTER_PAGE_MAIN)
|
||
.build());
|
||
}
|
||
|
||
public static void start(Context context) {
|
||
start(context, null);
|
||
}
|
||
|
||
public static void start(Context context, Intent extras) {
|
||
Intent intent = new Intent();
|
||
intent.setClass(context, MainActivity.class);
|
||
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||
if (extras != null) {
|
||
intent.putExtras(extras);
|
||
}
|
||
context.startActivity(intent);
|
||
}
|
||
|
||
@Override
|
||
protected void onSaveInstanceState(Bundle outState) {
|
||
super.onSaveInstanceState(outState);
|
||
outState.putInt(Constants.KEY_MAIN_POSITION, mCurrentTabType);
|
||
}
|
||
|
||
@Override
|
||
protected void onRestoreInstanceState(@NotNull Bundle savedInstanceState) {
|
||
super.onRestoreInstanceState(savedInstanceState);
|
||
mCurrentTabType = savedInstanceState.getInt(Constants.KEY_MAIN_POSITION);
|
||
}
|
||
|
||
@Override
|
||
protected void onCreate(Bundle savedInstanceState) {
|
||
super.onCreate(savedInstanceState);
|
||
homeViewModel = new ViewModelProvider(this).get(HomeViewModel.class);
|
||
NimMiddleActivity.firstEnter = false;
|
||
if (savedInstanceState != null) {
|
||
mCurrentTabType = savedInstanceState.getInt(Constants.KEY_MAIN_POSITION);
|
||
}
|
||
setContentView(R.layout.activity_main);
|
||
//自动登录
|
||
AuthModel.get().autoLogin()
|
||
.doOnError(throwable -> onNeedLogin())
|
||
.subscribe();
|
||
initView();
|
||
InitialModel.get().getMainTabInfosLiveData().observeForever(mainTabInfos -> {
|
||
if (mainTabInfos != null) {
|
||
mMainTabLayout.setMainTabInfoList(mainTabInfos);
|
||
}
|
||
});
|
||
initMaterialView();
|
||
onParseIntent();
|
||
updateDatas();
|
||
updateRoomState();
|
||
initP2PSessionCustomization();
|
||
initTeamSessionCustomization();
|
||
EventBus.getDefault().register(this);
|
||
otherModelInit();
|
||
|
||
}
|
||
|
||
private void otherModelInit() {
|
||
PwdCodeMgr.get().onCreateInit();
|
||
//初始化线程池
|
||
ThreadPoolManager.instance().init();
|
||
IMBroadcastManager.get().onCreate();
|
||
ImageLoadUtilsV2.init(context);
|
||
}
|
||
|
||
@Override
|
||
protected void onReceiveChatRoomEvent(RoomEvent roomEvent) {
|
||
super.onReceiveChatRoomEvent(roomEvent);
|
||
if (roomEvent == null || roomEvent.getEvent() == RoomEvent.NONE) return;
|
||
int event = roomEvent.getEvent();
|
||
if (event == RoomEvent.ENTER_ROOM) {
|
||
onEnter(AvRoomDataManager.get().mCurrentRoomInfo);
|
||
} else if (event == RoomEvent.KICK_OUT_ROOM) {
|
||
|
||
ChatRoomKickOutEvent reason = roomEvent.getReason();
|
||
if (reason == null) return;
|
||
//加入黑名单,踢出房间回调
|
||
ChatRoomKickOutEvent.ChatRoomKickOutReason reasonReason = reason.getReason();
|
||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.USER_KICKED_EVENT, "用户被踢");
|
||
if (reasonReason == ChatRoomKickOutEvent.ChatRoomKickOutReason.BE_BLACKLISTED
|
||
|| reasonReason == ChatRoomKickOutEvent.ChatRoomKickOutReason.KICK_OUT_BY_MANAGER
|
||
|| reasonReason == ChatRoomKickOutEvent.ChatRoomKickOutReason.KICK_OUT_BY_CONFLICT_LOGIN
|
||
|| reasonReason == ChatRoomKickOutEvent.ChatRoomKickOutReason.CHAT_ROOM_INVALID) {
|
||
exitRoom(AvRoomDataManager.get().mCurrentRoomInfo);
|
||
}
|
||
} else if (event == RoomEvent.ROOM_EXIT) {
|
||
exitRoom(roomEvent.getRoomInfo());
|
||
} else if (event == RoomEvent.ROOM_CHAT_RECONNECTION) {
|
||
updateRoomState();
|
||
} else if (event == RoomEvent.MY_SELF_KICK_OUT_ROOM_BY_S_ADMIN) {
|
||
toast(R.string.kick_out_room_by_s_admin);
|
||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.USER_KICKED_EVENT, "用户被踢");
|
||
getMvpPresenter().exitRoom();
|
||
}
|
||
}
|
||
|
||
private void closeOpenRoomAnimation() {
|
||
stopRoomMinAnim();
|
||
avatarLayout.setVisibility(View.GONE);
|
||
}
|
||
|
||
private void initP2PSessionCustomization() {
|
||
SessionCustomization sessionCustomization = new SessionCustomization();
|
||
ArrayList<BaseAction> actions = new ArrayList<>();
|
||
actions.add(new ImageAction());
|
||
actions.add(new GiftAction());
|
||
sessionCustomization.actions = actions;
|
||
sessionCustomization.withSticker = true;
|
||
NimUIKit.setCommonP2PSessionCustomization(sessionCustomization);
|
||
|
||
// 语音派对
|
||
NimUIKit.registerMsgItemViewHolder(OpenAudioPartyAttachment.class, MsgViewHolderAudioParty.class);
|
||
|
||
NimUIKit.registerMsgItemViewHolder(OpenRoomNotiAttachment.class, MsgViewHolderOnline.class);
|
||
NimUIKit.registerMsgItemViewHolder(GiftAttachment.class, MsgViewHolderGift.class);
|
||
NimUIKit.registerMsgItemViewHolder(NoticeAttachment.class, MsgViewHolderContent.class);
|
||
NimUIKit.registerMsgItemViewHolder(RedPacketAttachment.class, MsgViewHolderRedPacket.class);
|
||
NimUIKit.registerMsgItemViewHolder(NewbieHelloAttachment.class, MsgViewHolderHello.class);
|
||
NimUIKit.registerMsgItemViewHolder(LotteryAttachment.class, MsgViewHolderLottery.class);
|
||
NimUIKit.registerMsgItemViewHolder(NobleAttachment.class, MsgViewHolderText.class);
|
||
NimUIKit.registerMsgItemViewHolder(CarAttachment.class, MsgViewHolderText.class);
|
||
NimUIKit.registerMsgItemViewHolder(AssistantAttachment.class, MsgViewHolderText.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingRoomAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingFamilyAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingMiniWorldAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingTeamAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(SysMsgAttachment.class, SysMsgViewHolder.class);
|
||
//V2系统消息,废弃23 V1
|
||
NimUIKit.registerMsgItemViewHolder(SysMsgV2Attachment.class, SysMsgV2ViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(LevelUpAttachment.class, MsgViewHolderLevel.class);
|
||
NimUIKit.registerMsgItemViewHolder(AitMeAttachment.class, MsgViewHolderAitMe.class);
|
||
NimUIKit.registerMsgItemViewHolder(RedPackageAttachment.class, MsgViewHolderRedPackage.class);
|
||
//模厅模块
|
||
HallDataManager.get().mainNimOnCreate();
|
||
//签到
|
||
NimUIKit.registerMsgItemViewHolder(OpenSignInAttachment.class, SignInNoticeMsgViewHolder.class);
|
||
//瓜分钻石 三级
|
||
NimUIKit.registerMsgItemViewHolder(CarveUpGoldThirdLevelAttachment.class, MsgViewHolderText.class);
|
||
|
||
// 社区动态
|
||
NimUIKit.registerMsgItemViewHolder(DynamicSysAttachment.class, DynamicSysHolder.class); // 动态审核, 违规删除
|
||
//世界动态分享
|
||
NimUIKit.registerMsgItemViewHolder(WorldDynamicAttachment.class, WorldDynamicShareViewHolder.class);
|
||
|
||
NimUIKit.registerMsgItemViewHolder(ChatHintAttachment.class, MsgViewHolderChatHint.class);
|
||
|
||
NimUIKit.registerMsgItemViewHolder(MatchAttachment.class, MsgViewHolderMatch.class);
|
||
NimUIKit.setSessionListener(listener);
|
||
NimUIKit.setContactEventListener(listener1);
|
||
}
|
||
|
||
private void initTeamSessionCustomization() {
|
||
SessionCustomization sessionCustomization = new SessionCustomization();
|
||
ArrayList<BaseAction> actions = new ArrayList<>();
|
||
actions.add(new ImageAction());
|
||
sessionCustomization.actions = actions;
|
||
sessionCustomization.withSticker = true;
|
||
NimUIKit.setCommonTeamSessionCustomization(sessionCustomization);
|
||
|
||
NimUIKit.registerMsgItemViewHolder(LuckyMoneyAttachment.class, LuckyMoneyMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingRoomAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingFamilyAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingMiniWorldAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(InAppSharingTeamAttachment.class, InAppSharingMsgViewHolder.class);
|
||
NimUIKit.registerMsgItemViewHolder(LuckyMoneyTipsAttachment.class, LuckyMoneyTipsViewHolder.class);
|
||
//邀请
|
||
// NimUIKit.registerMsgItemViewHolder(RoomInviteFansAttachment.class, LuckyMoneyTipsViewHolder.class);
|
||
|
||
NimUIKit.setSessionListener(listener);
|
||
NimUIKit.setContactEventListener(listener1);
|
||
}
|
||
|
||
@Override
|
||
protected void onResume() {
|
||
super.onResume();
|
||
if (avatarLayout.getVisibility() == View.VISIBLE) {
|
||
userLivingView.start();
|
||
}
|
||
//这里是为了处理APP后台运行的情况下点击分享房间等LinkedMe链接的情况
|
||
if (UserModel.get().getCacheLoginUserInfo() != null) {
|
||
handleLinkedJump();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
protected void onPause() {
|
||
super.onPause();
|
||
if (avatarLayout.getVisibility() == View.VISIBLE) {
|
||
userLivingView.stop();
|
||
}
|
||
}
|
||
|
||
private void initView() {
|
||
mMainTabLayout = findViewById(R.id.main_tab_layout);
|
||
avatarLayout = findViewById(R.id.avatar_image_layout);
|
||
tvName = findViewById(R.id.tv_name);
|
||
tvId = findViewById(R.id.tv_id);
|
||
|
||
avatarImage = findViewById(R.id.avatar_image);
|
||
userLivingView = findViewById(R.id.liv_user);
|
||
viewClose = findViewById(R.id.view_close);
|
||
llDragInfo = findViewById(R.id.ll_drag_info);
|
||
userLivingView.setColor(Color.WHITE);
|
||
mMainTabLayout.setOnTabClickListener(this);
|
||
}
|
||
|
||
|
||
private void updateDatas() {
|
||
mMainTabLayout.setDefaultTabType(mCurrentTabType);
|
||
handleNimIntent();
|
||
}
|
||
|
||
|
||
@Override
|
||
protected void onNewIntent(Intent intent) {
|
||
super.onNewIntent(intent);
|
||
setIntent(intent);
|
||
//这里退出登录,实际上mainActivity是没有销毁的,当从linkme 调起来时候这里需要检查一下登录状态。
|
||
if (TextUtils.isEmpty(AuthModel.get().getTicket())) {
|
||
onNeedLogin();
|
||
return;
|
||
}
|
||
onParseIntent();
|
||
handleNimIntent();
|
||
if (tempFragment instanceof FlutterFragment) {
|
||
((FlutterFragment) tempFragment).onNewIntent(intent);
|
||
}
|
||
}
|
||
|
||
|
||
private void onParseIntent() {
|
||
Intent intent = getIntent();
|
||
if (intent.hasExtra(EXTRA_APP_QUIT)) {
|
||
onLogout();
|
||
} else if (intent.hasExtra(Extras.EXTRA_JUMP_P2P)) {
|
||
Intent data = intent.getParcelableExtra(Extras.EXTRA_DATA);
|
||
String account = data.getStringExtra(Extras.EXTRA_ACCOUNT);
|
||
if (!TextUtils.isEmpty(account)) {
|
||
NimP2PMessageActivity.start(this, account);
|
||
}
|
||
} else if (intent.hasExtra(GAME_TAB) && intent.getBooleanExtra(GAME_TAB, false)) {
|
||
if (mMainTabLayout != null) {
|
||
mMainTabLayout.setDefaultTabType(MainTabType.TAB_TYPE_GAME);
|
||
}
|
||
} else if (intent.hasExtra(MSG_TAB) && intent.getBooleanExtra(MSG_TAB, false)) {
|
||
if (mMainTabLayout != null) {
|
||
mMainTabLayout.setDefaultTabType(MainTabType.TAB_TYPE_MSG);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void initMaterialView() {
|
||
avatarLayout.setVisibility(View.GONE);
|
||
avatarImage.setOnClickListener(this);
|
||
llDragInfo.setOnClickListener(this);
|
||
viewClose.setOnClickListener(this);
|
||
|
||
|
||
}
|
||
|
||
@Override
|
||
protected void onDestroy() {
|
||
CleanLeakUtils.fixInputMethodManagerLeak(MainActivity.this);
|
||
super.onDestroy();
|
||
listener = null;
|
||
listener1 = null;
|
||
NimUIKit.setSessionListener(null);
|
||
NimUIKit.setContactEventListener(null);
|
||
|
||
EventBus.getDefault().unregister(this);
|
||
stopRoomMinAnim();
|
||
if (limitEnterRoomHelper != null) {
|
||
limitEnterRoomHelper.release();
|
||
}
|
||
IMBroadcastManager.get().onDestroy();
|
||
}
|
||
|
||
/**
|
||
* 双击返回键退出
|
||
*/
|
||
@Override
|
||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||
|
||
if (keyCode == KeyEvent.KEYCODE_BACK) {
|
||
|
||
/**
|
||
* 防止华为机型未加入白名单时按返回键回到桌面再锁屏后几秒钟进程被杀
|
||
*/
|
||
try {
|
||
Intent launcherIntent = new Intent(Intent.ACTION_MAIN);
|
||
launcherIntent.addCategory(Intent.CATEGORY_HOME);
|
||
startActivity(launcherIntent);
|
||
} catch (Throwable e) {
|
||
e.printStackTrace();
|
||
}
|
||
|
||
try {
|
||
moveTaskToBack(false);
|
||
} catch (Exception e) {
|
||
return super.onKeyDown(keyCode, event);
|
||
}
|
||
}
|
||
return super.onKeyDown(keyCode, event);
|
||
}
|
||
|
||
@Override
|
||
public void onBackPressed() {
|
||
try {
|
||
moveTaskToBack(false);
|
||
} catch (Exception e) {
|
||
e.printStackTrace();
|
||
}
|
||
if (tempFragment instanceof FlutterFragment) {
|
||
((FlutterFragment) tempFragment).onBackPressed();
|
||
}
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onLoginEvent(LoginEvent event) {
|
||
onLogin(AuthModel.get().getCurrentUid());
|
||
}
|
||
|
||
/**
|
||
* 检查是否绑定手机
|
||
*/
|
||
private void checkBindPhone() {
|
||
BindPhoneActivity.start(context);
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onLogoutEvent(LogoutEvent event) {
|
||
onLogout();
|
||
PwdCodeMgr.get().onLogout();
|
||
}
|
||
|
||
@SuppressLint("CheckResult")
|
||
public void onLogin(long uid) {
|
||
Logger.e(TAG, "onLogin Success ~~~~");
|
||
CrashReport.setUserId(this, uid + "");
|
||
|
||
Log.i("checkLostUser", "onLogin");
|
||
|
||
//登录成功查询未读信息数量
|
||
mMainTabLayout.setUnReadDynamicCount(0);
|
||
int unreadCount = IMMessageManager.get().queryUnreadMsg();
|
||
mMainTabLayout.setMsgNum(unreadCount);
|
||
openCommunityNotice();
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onLoadLoginUserInfoEvent(LoadLoginUserInfoEvent event) {
|
||
//签到弹窗
|
||
// handleSign();
|
||
firstLoadedUserInfo();
|
||
}
|
||
|
||
private void handleSign() {
|
||
//检查是否需要弹 签到框
|
||
//如果是新用户,因为有资料未完善,所以先不弹签到框
|
||
UserInfo loginUserInfo = UserModel.get().getCacheLoginUserInfo();
|
||
if (loginUserInfo == null) {
|
||
//弹出去绑定用户
|
||
|
||
return;
|
||
}
|
||
if (!TextUtils.isEmpty(loginUserInfo.getNick()) && !TextUtils.isEmpty(loginUserInfo.getAvatar())) {
|
||
//noinspection ResultOfMethodCallIgnored
|
||
SignDialogTimeManager.checkSignDialog(this, false);
|
||
}
|
||
}
|
||
|
||
public void onLogout() {
|
||
Logger.e(TAG, "onLogout Success ~~~~");
|
||
getMvpPresenter().exitRoom();
|
||
// LoginActivity.start(MainActivity.this);
|
||
QuickPassLoginAct.start(MainActivity.this);
|
||
PmDialogShowMrg.get().onLogout();
|
||
}
|
||
|
||
public void onNeedLogin() {
|
||
NimMiddleActivity.openCommunity = false;
|
||
QuickPassLoginAct.start(MainActivity.this);
|
||
}
|
||
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onKickedOutEvent(KickOutEvent event) {
|
||
toast("您已被踢下线,若非正常行为,请及时修改密码");
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onReceiveRecentContactChanged(List<RecentContact> imMessages) {
|
||
|
||
int countIgnore = 0;
|
||
for (RecentContact recentContact : imMessages) {
|
||
|
||
if (recentContact.getSessionType() == SessionTypeEnum.Team) {
|
||
Team team = NIMClient.getService(TeamService.class).queryTeamBlock(recentContact.getContactId());
|
||
if (team != null && team.getMessageNotifyType() == TeamMessageNotifyTypeEnum.Mute) {
|
||
countIgnore += recentContact.getUnreadCount();
|
||
}
|
||
|
||
}
|
||
|
||
}
|
||
int unreadCount = IMMessageManager.get().queryUnreadMsg() + countIgnore;
|
||
mMainTabLayout.setMsgNum(unreadCount);
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onNeedCompleteInfo(NeedCompleteInfoEvent event) {
|
||
getDialogManager().dismissDialog();
|
||
UIHelper.showAddInfoAct(this);
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onLoginUserInfoUpdateEvent(LoginUserInfoUpdateEvent event) {
|
||
int unreadCount = IMMessageManager.get().queryUnreadMsg();
|
||
mMainTabLayout.setMsgNum(unreadCount);
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onReceiveLevelUpActivity(LevelUpEvent event) {
|
||
if (AvRoomDataManager.get().isSelfGamePlaying()) return;
|
||
LevelUpDialog.start(this, event.getLevelName(), true);
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onReceiveCharmLevelUpActivity(CharmLevelUpEvent event) {
|
||
if (AvRoomDataManager.get().isSelfGamePlaying()) return;
|
||
LevelUpDialog.start(this, event.getLevelName(), false);
|
||
}
|
||
|
||
@SuppressLint("CheckResult")
|
||
private void updateRoomState() {
|
||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||
if (roomInfo != null) {
|
||
UserModel.get().getUserInfo(roomInfo.getUid())
|
||
.subscribe(userInfo -> {
|
||
if (userInfo != null) {
|
||
displayAvatarLayout(userInfo.getAvatar(), roomInfo.getTitle(), userInfo.getErbanNo());
|
||
} else {
|
||
NimUserInfo nimUserInfo = NimUserInfoCache.getInstance().getUserInfo(roomInfo.getUid() + "");
|
||
if (nimUserInfo == null) {
|
||
NimUserInfoCache.getInstance().getUserInfoFromRemote(roomInfo.getUid() + "", new RequestCallbackWrapper<NimUserInfo>() {
|
||
@Override
|
||
public void onResult(int i, NimUserInfo nimUserInfo, Throwable throwable) {
|
||
if (nimUserInfo != null) {
|
||
displayAvatarLayout(nimUserInfo.getAvatar(), roomInfo.getTitle(), userInfo.getUid());
|
||
}
|
||
}
|
||
});
|
||
} else {
|
||
displayAvatarLayout(nimUserInfo.getAvatar(), roomInfo.getTitle(), userInfo.getUid());
|
||
}
|
||
}
|
||
});
|
||
|
||
}
|
||
}
|
||
|
||
private void startRoomMinAnim() {
|
||
roomMinAnim = ObjectAnimator.ofFloat(avatarImage, "rotation", 0f, 360f);
|
||
roomMinAnim.setDuration(10000);
|
||
roomMinAnim.setRepeatCount(-1);
|
||
roomMinAnim.setInterpolator(new LinearInterpolator());
|
||
roomMinAnim.start();
|
||
}
|
||
|
||
private void stopRoomMinAnim() {
|
||
if (roomMinAnim != null) {
|
||
roomMinAnim.cancel();
|
||
roomMinAnim = null;
|
||
}
|
||
}
|
||
|
||
@SuppressLint("SetTextI18n")
|
||
private void displayAvatarLayout(String avatar, String nickName, long uid) {
|
||
avatarLayout.clearAnimation();
|
||
avatarLayout.setVisibility(View.VISIBLE);
|
||
tvName.setText(nickName);
|
||
tvId.setText("ID:" + uid);
|
||
userLivingView.start();
|
||
stopRoomMinAnim();
|
||
startRoomMinAnim();
|
||
ImageLoadUtils.loadAvatar(MainActivity.this, avatar, avatarImage);
|
||
}
|
||
|
||
public void onEnter(RoomInfo roomInfo) {
|
||
updateRoomState();
|
||
DaemonService.start(this, roomInfo);
|
||
}
|
||
|
||
@SuppressLint("RestrictedApi")
|
||
@Override
|
||
public void onTabClick(int tabType) {
|
||
|
||
Fragment showFragment = fragmentArray.get(tabType);
|
||
if (showFragment == tempFragment) return;
|
||
|
||
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
|
||
if (!showFragment.isAdded()) {
|
||
transaction.add(R.id.main_fragment, showFragment, null);
|
||
}
|
||
transaction.show(showFragment);
|
||
if (tempFragment != null) transaction.hide(tempFragment);
|
||
tempFragment = showFragment;
|
||
if (!isDestroyed()) transaction.commitNowAllowingStateLoss();
|
||
mCurrentTabType = tabType;
|
||
}
|
||
|
||
@Override
|
||
public void exitRoom(RoomInfo roomInfo) {
|
||
closeOpenRoomAnimation();
|
||
//ktv退出的时候需要用到
|
||
if (AudioEngineManager.get().isOpenKtv() && roomInfo != null) {
|
||
KtvMusicManager.INSTANCE.deleteUserAllChooseMusic(roomInfo.getUid()).subscribe();
|
||
AudioEngineManager.get().closeKtvModel();
|
||
}
|
||
DaemonService.stop(MainActivity.this);
|
||
}
|
||
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onReceiveRecallStatus(CheckLostUserEvent event) {
|
||
//如果没有获取到当前登录用户的信息,不弹出提示
|
||
if (UserModel.get().getCacheLoginUserInfo() == null) {
|
||
return;
|
||
}
|
||
|
||
CheckLostUserInfo checkLostUserInfo = (CheckLostUserInfo) event.getData();
|
||
|
||
boolean goBackOnce = (boolean) SharedPreferenceUtils.get(RecallDialog.GO_BACK_ONCE, false);
|
||
|
||
if (!goBackOnce && !event.isFailed() && checkLostUserInfo.isLostUser() && !checkLostUserInfo.isClaimedAward())
|
||
RecallDialog.start(this);
|
||
}
|
||
|
||
public boolean isShowMeTab() {
|
||
return mCurrentTabType == MainTabType.TAB_TYPE_ME;
|
||
}
|
||
|
||
/**
|
||
* 第一次加载到用户信息
|
||
* 跳转优先级 闪屏→linkedMe→渠道指定房间→邀请码
|
||
*/
|
||
@SuppressLint("CheckResult")
|
||
private void firstLoadedUserInfo() {
|
||
//青少年弹窗处理
|
||
PmDialogShowMrg.get().handle(new WeakReference<>(this));
|
||
|
||
//通知栏权限判断
|
||
NoticationsUiHelper.handle(this, getDialogManager());
|
||
|
||
handleChannelPageInfo();
|
||
|
||
checkProtocolUpdate();
|
||
|
||
// 互动消息未读数量
|
||
HomeModel.INSTANCE.getUnreadCount(AuthModel.get().getCurrentUid())
|
||
.compose(bindUntilEvent(ActivityEvent.DESTROY))
|
||
.subscribe((integer, throwable) -> {
|
||
if (integer != null) {
|
||
EventBus.getDefault().post(new UnReadCountEvent(integer));
|
||
}
|
||
});
|
||
|
||
}
|
||
|
||
@SuppressLint("CheckResult")
|
||
private void checkProtocolUpdate() {
|
||
UserModel.get()
|
||
.getProtocolInfo()
|
||
.compose(bindUntilEvent(ActivityEvent.DESTROY))
|
||
.subscribe(protocolInfo -> {
|
||
float version = (float) SharedPreferenceUtils.get(ProtocolUpdateDialog.SP_KEY, 0f);
|
||
//第一次打开APP不弹,因为闪屏页已经弹了!
|
||
if (version == 0f) {
|
||
SharedPreferenceUtils.put(ProtocolUpdateDialog.SP_KEY, protocolInfo.getVer());
|
||
} else if (version < protocolInfo.getVer()) {
|
||
new ProtocolUpdateDialog(MainActivity.this, protocolInfo).show();
|
||
}
|
||
});
|
||
}
|
||
|
||
//闪屏→linkedme→渠道指定房间→邀请码
|
||
@SuppressLint("CheckResult")
|
||
private void handleChannelPageInfo() {
|
||
|
||
if (handleSplashJump()) return;
|
||
if (handleLinkedJump()) return;
|
||
|
||
//渠道落地页和邀请码跳转只需要完善资料后处理一次
|
||
String spKey = KEY_FLAG_VALID_CHANNEL_PAGE + AuthModel.get().getCurrentUid();
|
||
if ((boolean) SharedPreferenceUtils.get(spKey, true)) {
|
||
SharedPreferenceUtils.put(spKey, false);
|
||
checkInviteUserInRoom();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 检查邀请码跳转
|
||
*/
|
||
@SuppressLint("CheckResult")
|
||
private void checkInviteUserInRoom() {
|
||
if (!TextUtils.isEmpty(AddUserInfoFragment.INVITE_USER_CODE)) {
|
||
ChannelPageModel.get().checkInviteUserInRoom(AddUserInfoFragment.INVITE_USER_CODE)
|
||
.subscribe(inviteUserInfo -> {
|
||
if (inviteUserInfo.isInRoom()) {
|
||
if (inviteUserInfo.getFromType() == 0) {
|
||
AVRoomActivity.start(context, inviteUserInfo.getRoomUid());
|
||
} else {
|
||
AVRoomActivity.startForFromType(context,
|
||
inviteUserInfo.getRoomUid(),
|
||
inviteUserInfo.getFromType(),
|
||
inviteUserInfo.getInviteNick(),
|
||
String.valueOf(inviteUserInfo.getInviteUid()));
|
||
}
|
||
} else {
|
||
checkChannelPageInRoom();
|
||
}
|
||
}, throwable -> checkChannelPageInRoom());
|
||
AddUserInfoFragment.INVITE_USER_CODE = "";
|
||
} else {
|
||
checkChannelPageInRoom();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 处理渠道落地页
|
||
*/
|
||
@SuppressLint("CheckResult")
|
||
private void checkChannelPageInRoom() {
|
||
GameHomeModel.get().getRoomShortcut()
|
||
.compose(bindUntilEvent(ActivityEvent.DESTROY))
|
||
.subscribe(uid -> AVRoomActivity.start(context, StringUtils.toLong(uid)),
|
||
Throwable::printStackTrace);
|
||
}
|
||
|
||
/**
|
||
* @return true 如果处理了跳转
|
||
*/
|
||
private boolean handleSplashJump() {
|
||
if (getIntent().hasExtra("url") && getIntent().hasExtra("type")) {
|
||
LogUtil.print("点击了闪屏");
|
||
//如果没有渠道页,就按原来的逻辑即可
|
||
int type = getIntent().getIntExtra("type", 0);
|
||
String url = getIntent().getStringExtra("url");
|
||
if (type == 3) {
|
||
Intent intent = new Intent(context, CommonWebViewActivity.class);
|
||
intent.putExtra("url", url);
|
||
startActivity(intent);
|
||
} else if (type == 2) {
|
||
AVRoomActivity.start(context, Long.parseLong(url));
|
||
} else {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
/**
|
||
* @return true 如果处理了跳转
|
||
*/
|
||
public boolean handleLinkedJump() {
|
||
LinkedInfo linkedInfo = LinkedModel.get().getLinkedInfo();
|
||
LinkedModel.get().setLinkedInfo(null);
|
||
|
||
if (linkedInfo == null || linkedInfo.getType() == null) {
|
||
return false;
|
||
}
|
||
LogUtil.print("linkedme跳转");
|
||
// 跳转
|
||
if (!StringUtil.isEmpty(linkedInfo.getRoomUid()) && linkedInfo.getType().equals("2")) {
|
||
AVRoomActivity.start(this, Long.parseLong(linkedInfo.getRoomUid()));
|
||
} else if (!StringUtil.isEmpty(linkedInfo.getFamilyId()) && linkedInfo.getType().equals("4")) {
|
||
FamilyHomeActivity.start(this, linkedInfo.getFamilyId());
|
||
} else if (!TextUtils.isEmpty(linkedInfo.getUrl()) && linkedInfo.getType().equals("3")) {
|
||
CommonWebViewActivity.start(context, UriProvider.getLinkUrl(linkedInfo.getUrl()));
|
||
} else if (!TextUtils.isEmpty(linkedInfo.getWorldId()) && linkedInfo.getType().equals("5")) {
|
||
MiniWorldGuestPageActivity.start(context, linkedInfo.getWorldId());
|
||
} else if (linkedInfo.getType().equals("6") && !TextUtils.isEmpty(linkedInfo.getWorldId()) &&
|
||
!TextUtils.isEmpty(linkedInfo.getDynamicId())) {
|
||
DynamicDetailActivity.start(context, JavaUtil.str2long(linkedInfo.getDynamicId()),
|
||
JavaUtil.str2long(linkedInfo.getWorldId()), 6);
|
||
} else {
|
||
return false;
|
||
}
|
||
return true;
|
||
}
|
||
|
||
|
||
public LimitEnterRoomHelper getLimitEnterRoomHelper() {
|
||
if (limitEnterRoomHelper == null) {
|
||
limitEnterRoomHelper = new LimitEnterRoomHelper();
|
||
}
|
||
return limitEnterRoomHelper;
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onImPushMsgPmLimitTimeEvent(ImPushMsgPmLimitTimeEvent event) {
|
||
//先判断Avroom存不存在,存在的话则不处理,avroom会处理
|
||
WeakReference<Activity> reference = ActivityStackManager.getInstance().getAvRoomActWeakRef();
|
||
if (reference != null && reference.get() != null) {
|
||
return;
|
||
}
|
||
getLimitEnterRoomHelper().handleThisContext(this, event.getData(), true, this::handlePmExitRoom);
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onPmDismissAllLimitDialogEvent(PmDismissAllLimitDialogEvent event) {
|
||
if (limitEnterRoomHelper != null) {
|
||
limitEnterRoomHelper.dismissDialog();
|
||
}
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onUnReadCount(UnReadCountEvent event) {
|
||
mMainTabLayout.setUnReadDynamicCount(event.getTotal());
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void SquarePublish(SquareTaskEvent event) {
|
||
if (getDialogManager() != null) {
|
||
PublishActivity.start(getDialogManager());
|
||
}
|
||
}
|
||
|
||
private void handlePmExitRoom() {
|
||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||
closeOpenRoomAnimation();
|
||
getMvpPresenter().exitRoom();
|
||
}
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onCloseMinRoomEvent(CloseMinRoomEvent event) {
|
||
//如果房间存在,就关闭
|
||
if (AvRoomDataManager.get().mCurrentRoomInfo != null) {
|
||
handlePmExitRoom();
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 处理开房限制时长
|
||
*/
|
||
public void handleOpenRoomWhenPmLimit(String error) {
|
||
getLimitEnterRoomHelper().handleThisContext(this, error, false, this::handlePmExitRoom);
|
||
}
|
||
|
||
/**
|
||
* 云信通知栏跳转的处理
|
||
*/
|
||
private void handleNimIntent() {
|
||
openCommunityNotice();
|
||
|
||
Intent intent = getIntent();
|
||
if (intent == null) {
|
||
return;
|
||
}
|
||
boolean isNimPush = intent.getBooleanExtra(NimMiddleActivity.EXTRA_IS_NIM_PUSH, false);
|
||
if (isNimPush && mMainTabLayout != null) {
|
||
mMainTabLayout.setDefaultTabType(MainTabType.TAB_TYPE_MSG);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* 点击互动通知通知栏,重启进程打开互动通知页
|
||
*/
|
||
private void openCommunityNotice() {
|
||
if (NimMiddleActivity.delayOpenCommunity) {
|
||
return;
|
||
}
|
||
if (NimMiddleActivity.openCommunity) {
|
||
NimMiddleActivity.openCommunity = false;
|
||
if (NimMiddleActivity.skipType == 0) return;
|
||
new Handler().postDelayed(new Runnable() {
|
||
@Override
|
||
public void run() {
|
||
if (NimMiddleActivity.skipType == PushMessageHandler.PAYLOAD_SKIPTYPE_INVITE_FANS &&
|
||
NimMiddleActivity.payloadUid > 0) {
|
||
AVRoomActivity.start(MainActivity.this, NimMiddleActivity.payloadUid);
|
||
} else if (NimMiddleActivity.skipType == PushMessageHandler.PAYLOAD_SKIPTYPE_PRIVATE_MSG &&
|
||
NimMiddleActivity.payloadUid > 0) {
|
||
NimP2PMessageActivity.start(MainActivity.this, NimMiddleActivity.payloadUid + "");
|
||
} else if (NimMiddleActivity.skipType == PushMessageHandler.PAYLOAD_SKIPTYPE_H5 &&
|
||
!TextUtils.isEmpty(NimMiddleActivity.payloadUrl)) {
|
||
CommonWebViewActivity.start(MainActivity.this, NimMiddleActivity.payloadUrl);
|
||
}
|
||
}
|
||
}, 2000);
|
||
}
|
||
}
|
||
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onNeedBindPhoneEvent(NeedBindPhoneEvent event) {
|
||
checkBindPhone();
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onShowCommonWebEvent(ShowCommonWebEvent event) {
|
||
CommonWebViewActivity.start(event.getContext(), event.getUrl());
|
||
}
|
||
|
||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||
public void onVisitorUnreadCountEvent(VisitorUnreadCountEvent event) {
|
||
if (mMainTabLayout != null) {
|
||
mMainTabLayout.setUnreadVisitorCount(event.getVisitNum());
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onClick(View v) {
|
||
switch (v.getId()) {
|
||
case R.id.avatar_image:
|
||
case R.id.ll_drag_info:
|
||
RoomInfo roomInfo = AvRoomDataManager.get().mCurrentRoomInfo;
|
||
if (roomInfo != null) {
|
||
if (AvRoomDataManager.get().isParty()) {
|
||
AVRoomActivity.start(MainActivity.this, true);
|
||
} else {
|
||
AVRoomActivity.start(MainActivity.this, roomInfo.getUid());
|
||
}
|
||
} else {
|
||
toast("-房间信息为空-");
|
||
}
|
||
|
||
break;
|
||
case R.id.view_close:
|
||
StatisticManager.Instance().onEvent(StatisticsProtocol.Event.EVENT_ROOM_MINIMIZE_CLOSED,
|
||
"房间最小化关闭按钮");
|
||
MainActivity.this.getMvpPresenter().exitRoom();
|
||
break;
|
||
}
|
||
}
|
||
|
||
@Override
|
||
protected boolean needSteepStateBar() {
|
||
return true;
|
||
}
|
||
|
||
@Override
|
||
protected void setStatusBar() {
|
||
super.setStatusBar();
|
||
StatusBarUtil.transparencyBar(this);
|
||
StatusBarUtil.StatusBarLightMode(this);
|
||
}
|
||
|
||
@Override
|
||
public void onPostResume() {
|
||
super.onPostResume();
|
||
if (tempFragment instanceof FlutterFragment) {
|
||
((FlutterFragment) tempFragment).onPostResume();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onRequestPermissionsResult(
|
||
int requestCode,
|
||
@NonNull String[] permissions,
|
||
@NonNull int[] grantResults
|
||
) {
|
||
if (tempFragment instanceof FlutterFragment) {
|
||
tempFragment.onRequestPermissionsResult(
|
||
requestCode,
|
||
permissions,
|
||
grantResults
|
||
);
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onUserLeaveHint() {
|
||
if (tempFragment instanceof FlutterFragment) {
|
||
((FlutterFragment) tempFragment).onUserLeaveHint();
|
||
}
|
||
}
|
||
|
||
@Override
|
||
public void onTrimMemory(int level) {
|
||
super.onTrimMemory(level);
|
||
if (tempFragment instanceof FlutterFragment) {
|
||
((FlutterFragment) tempFragment).onTrimMemory(level);
|
||
}
|
||
}
|
||
}
|