AVRoomActivity start方法整理

This commit is contained in:
huangjian
2022-08-01 17:52:17 +08:00
parent 60b910179c
commit 37a09ae941
4 changed files with 32 additions and 131 deletions

View File

@@ -1180,11 +1180,7 @@ public class MainActivity extends BaseMvpActivity<IMainView, MainPresenter>
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());
}
AVRoomActivity.start(MainActivity.this, roomInfo.getUid());
} else {
toast("-房间信息为空-");
}

View File

@@ -108,7 +108,6 @@ import com.yizhuan.xchat_android_core.redpackage.RedPackageModel;
import com.yizhuan.xchat_android_core.redpackage.RedPackageNotifyInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomInfo;
import com.yizhuan.xchat_android_core.room.bean.RoomModeType;
import com.yizhuan.xchat_android_core.room.bean.SimplePartyRoomInfo;
import com.yizhuan.xchat_android_core.room.dragonball.DragonBallModel;
import com.yizhuan.xchat_android_core.room.event.FinishAvRoomEvent;
import com.yizhuan.xchat_android_core.room.pk.event.PKStateEvent;
@@ -164,7 +163,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
* 管理限制进房
*/
LimitEnterRoomHelper limitEnterRoomHelper;
boolean isLast = true;
private int fromType = FROM_TYPE_NORMAL;// 入口类型 0 其他 1 推荐 2 个人主页或者广场
private String fromNick = "";// 从萌圈进入时 需要传入作品发布者的昵称
private String fromUid = "";
@@ -197,13 +195,27 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
private SingleRoomTipDialog singleRoomTipDialog;
public static void start(Context context, long roomUid) {
Intent intent = new Intent(context, AVRoomActivity.class);
intent.putExtra(Constants.ROOM_UID, roomUid);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
startForFromType(context, roomUid, FROM_TYPE_NORMAL, null, null);
}
public static void start(Context context, long roomUid, int fromType, String fromNick, @Nullable RedPackageNotifyInfo notifyInfo) {
startForFromType(context, roomUid, fromType, fromNick, null, notifyInfo);
}
public static void startForFromType(Context context, long roomUid, int fromType) {
startForFromType(context, roomUid, fromType, null, null);
}
public static void startForFromType(Context context, long roomUid, int fromType, @Nullable String fromNick, @Nullable String fromUid) {
startForFromType(context, roomUid, fromType, fromNick, fromUid, null);
}
/**
* 如果在进房的时候就已经调用了room/get的话,可以使用这个方法进入房间,可以少调用一次room/get!
*
* @param context
* @param roomInfo
*/
public static void start(Context context, @NonNull RoomInfo roomInfo) {
Intent intent = new Intent(context, AVRoomActivity.class);
intent.putExtra(Constants.ROOM_INFO, (Parcelable) roomInfo);
@@ -213,24 +225,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
}
public static void start(Context context, long roomUid, int fromType, String fromNick, @Nullable RedPackageNotifyInfo notifyInfo) {
Intent intent = new Intent(context, AVRoomActivity.class);
intent.putExtra(Constants.ROOM_UID, roomUid);
intent.putExtra("fromType", fromType);
intent.putExtra("fromNick", fromNick);
if (notifyInfo != null) {
intent.putExtra("notifyInfo", notifyInfo);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
}
public static void startForFromType(Context context, long roomUid, int fromType) {
startForFromType(context, roomUid, fromType, null, null);
}
public static void startForFromType(Context context, long roomUid, int fromType, @Nullable String fromNick, @Nullable String fromUid) {
public static void startForFromType(Context context, long roomUid, int fromType, @Nullable String fromNick, @Nullable String fromUid, @Nullable RedPackageNotifyInfo notifyInfo) {
Intent intent = new Intent(context, AVRoomActivity.class);
intent.putExtra(Constants.ROOM_UID, roomUid);
intent.putExtra("fromType", fromType);
@@ -240,31 +235,14 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
if (!TextUtils.isEmpty(fromUid)) {
intent.putExtra("fromUid", fromUid);
}
if (notifyInfo != null) {
intent.putExtra("notifyInfo", notifyInfo);
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
}
public static void start(Context context, long roomUid, int roomType) {
Intent intent = new Intent(context, AVRoomActivity.class);
intent.putExtra(Constants.ROOM_UID, roomUid);
intent.putExtra(Constants.ROOM_TYPE, roomType);
AvRoomDataManager.get().setIsParty(false);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
}
public static void start(Context context, boolean isParty) {
Intent intent = new Intent(context, AVRoomActivity.class);
intent.putExtra(Constants.IS_PARTY, isParty);
AvRoomDataManager.get().setIsParty(true);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent);
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_INTO_ROOM_CLICK, "进入房间");
}
public static void setBackBg(Context context, RoomInfo roomInfo, SVGAImageView svgaRoomBg, String[] bgPicture) {
if (roomInfo != null && svgaRoomBg != null) {
if (!StringUtils.isBlank(roomInfo.getBackPic())) {
@@ -346,7 +324,6 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
// setIntent(intent);
// 如果是同一个房间,则只更新房间的信息
long newRoomUid = intent.getLongExtra(Constants.ROOM_UID, 0);
fromType = intent.getIntExtra("fromType", 0);
@@ -355,9 +332,8 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
mRoomInfo = intent.getParcelableExtra(Constants.ROOM_INFO);
if (newRoomUid != 0 && newRoomUid == roomUid) {
updateRoomInfo();
//updateRoomInfo之后进入云信进房逻辑后直接return了,不会再次调用addRoomFragment()
showRedPackage(AvRoomDataManager.get().mCurrentRoomInfo);
addRoomFragment(false);
showRoomFragment(false);
dismissLoadingDialog();
return;
}
@@ -382,6 +358,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
}
}
@SuppressLint("CheckResult")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -392,17 +369,10 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
fromNick = getIntent().getStringExtra("fromNick");
fromUid = getIntent().getStringExtra("fromUid");
mRoomInfo = (RoomInfo) getIntent().getSerializableExtra(Constants.ROOM_INFO);
boolean isParty = getIntent().getBooleanExtra(Constants.IS_PARTY, false);
//如果是嗨聊房入口roomUid就不从intent中取值
if (isParty) {
List<SimplePartyRoomInfo> roomUidList = AvRoomDataManager.get().getRoomUidList();
if (roomUidList != null && roomUidList.size() > 0) {
roomUid = roomUidList.get(0).getUid();
}
}
mVsRoomOffline = findViewById(R.id.vs_room_offline);
mVsNobleOpen = findViewById(R.id.vs_noble_open_notice);
viewpager = findViewById(R.id.fragment_container);
IMNetEaseManager.get().getChatRoomEventObservable()
.compose(bindToLifecycle())
.subscribe(this::onRoomEventReceive);
@@ -457,9 +427,9 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
} else {
requestRoomInfoSuccessView(mRoomInfo);
}
return;
} else {
showRoomFragment(true);
}
addRoomFragment(true);
});
@@ -628,7 +598,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
/**
* @param isRoomMin 如果是最小化则传ture
*/
private void addRoomFragment(boolean isRoomMin) {
private void showRoomFragment(boolean isRoomMin) {
mCurrentFragment = (HomePartyFragment) mAdapter.getItem(0);
viewpager.setUserInputEnabled(AvRoomDataManager.get().isSingleRoom());
viewpager.setCurrentItem(0, false);
@@ -1018,7 +988,7 @@ public class AVRoomActivity extends BaseMvpActivity<IAvRoomView, AvRoomPresenter
@Override
public void enterRoomSuccess() {
addRoomFragment(false);
showRoomFragment(false);
//获取管理员
getMvpPresenter().getNormalChatMember();
getMvpPresenter().getSuperAdminList();

View File

@@ -228,27 +228,6 @@ public class RouterHandler {
case RouterType.VOICE_BOTTLE_PAGE:
VoiceMatchActivity.start(context);
break;
//嗨聊派对
case RouterType.CHAT_PARTY:
if (!(context instanceof DialogManagerInterface) || !(context instanceof RxAppCompatActivity)) {
return false;
}
dmi = (DialogManagerInterface) context;
RxAppCompatActivity rxAppCompatActivity = (RxAppCompatActivity) context;
StatisticManager.Instance().onEvent(StatisticsProtocol.game_homepage_hiparty, "嗨聊派对");
if (AvRoomDataManager.get().isRoomOwner()
&& AvRoomDataManager.get().isCpRoom()
&& DemoCache.readBoolean(DemoCache.KEY_IS_FIRST_HOME_HIGH_PARTY_DIALOG, true)) {
DemoCache.saveBoolean(DemoCache.KEY_IS_FIRST_HOME_HIGH_PARTY_DIALOG, false);
dmi.getDialogManager().showOkCancelDialog("匹配会退出当前房间并解散用户", true,
() -> getGuildRoomId(context));
} else {
getGuildRoomId(context);
}
break;
//异性匹配
case RouterType.OPPOSITE_SEX_MATCHING:
if (!(context instanceof DialogManagerInterface) || !(context instanceof RxAppCompatActivity)) {
@@ -377,48 +356,4 @@ public class RouterHandler {
});
}
private static void getGuildRoomId(Context context) {
AvRoomModel.get()
.getPartyRoomList(AuthModel.get().getCurrentUid())
.doOnError(throwable -> {
if (throwable instanceof PmRoomLimitException) {
new LimitEnterRoomHelper().handleThisContext(
context, throwable.getMessage(), false, null
);
}
})
.doOnSuccess(partyRoomResult -> {
if (partyRoomResult != null) {
if (partyRoomResult.getData() != null && partyRoomResult.isSuccess()) {
if (partyRoomResult.getData().size() > 0) {
AvRoomDataManager.get().setRoomUidList(partyRoomResult.getData());
AVRoomActivity.start(context, true);
} else {
SingleToastUtil.showToastShort("暂无嗨聊房");
}
} else if (partyRoomResult.getData() != null && !partyRoomResult.isSuccess()) {
SingleToastUtil.showToastShort(partyRoomResult.getError());
} else {
SingleToastUtil.showToastShort("未知错误");
}
} else {
SingleToastUtil.showToastShort("暂无嗨聊房");
}
})
.subscribe();
// HomeModel.get().getGuildRoomId()
// .doOnError(throwable -> {
// if (throwable instanceof PmRoomLimitException) {
// new LimitEnterRoomHelper().handleThisContext(
// context, throwable.getMessage(), false, null
// );
// }
// })
// .doOnSuccess(s -> AVRoomActivity.start(context, JavaUtil.str2long(s)))
// .subscribe();
}
}

View File

@@ -68,7 +68,7 @@ public class MsgViewHolderHello extends MsgViewHolderBase implements View.OnClic
public void accept(RoomInfo roomInfo, Throwable throwable) throws Exception {
if (throwable == null) {
if (roomInfo != null && roomInfo.getUid() > 0 && roomInfo.getUid() == inRoomUid) {
AVRoomActivity.start(context, inRoomUid, roomInfo.getType());
AVRoomActivity.start(context, inRoomUid);
} else {
SingleToastUtil.showToast("来聊聊天嘛~");
}