fix:修复首页ViewPager.setCurrentItem(int)为null导致的闪退问题

This commit is contained in:
zlzw 2022-12-13 13:23:00 +08:00
parent 092b2ac519
commit 5317f6d88f
4 changed files with 27 additions and 19 deletions

View File

@ -85,7 +85,7 @@ public class IMRTCManager {
callback.onFailed(RTCErrorCode.RongRTCCodeJoinRepeatedRoom);
return;
}
if (rtcRoom != null) {
if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
/*
inviteeRoomId - 被邀请者所在房间 id
inviteeUserId - 被邀请用户 id
@ -100,7 +100,7 @@ public class IMRTCManager {
@Override
public void onSuccess() {
callback.onSuccess();
if(!RandomPkManager.getInstance().isRandomModel()) {
if (!RandomPkManager.getInstance().isRandomModel()) {
ToastUtil.show("发起邀请成功");
}
requestUid.add(liveUid);
@ -109,7 +109,7 @@ public class IMRTCManager {
@Override
public void onFailed(RTCErrorCode errorCode) {
if(!RandomPkManager.getInstance().isRandomModel()) {
if (!RandomPkManager.getInstance().isRandomModel()) {
ToastUtil.show("邀请失败 " + errorCode.getValue());
}
if (RandomPkManager.getInstance().isRequestPk()) {
@ -130,7 +130,7 @@ public class IMRTCManager {
* @param listener
*/
public void registerRoomListener(IRCRTCRoomEventsListener listener) {
if (rtcRoom != null) {
if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() {
@Override
public void onRemoteUserPublishResource(RCRTCRemoteUser remoteUser, List<RCRTCInputStream> streams) {
@ -188,7 +188,7 @@ public class IMRTCManager {
* @param callback 回调
*/
public void cancelRequestJoinOtherRoom(String liveUid, String extra, IRCRTCResultCallback callback) {
if (rtcRoom != null) {
if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
rtcRoom.getLocalUser().cancelRequestJoinOtherRoom(liveUid, liveUid, extra, new IRCRTCResultCallback() {
@Override
public void onSuccess() {

View File

@ -10,9 +10,9 @@ ext {
manifestPlaceholders = [
//
// serverHost : "https://napi.yaoulive.com",
serverHost : "https://napi.yaoulive.com",
//
serverHost : "https://ceshi.yaoulive.com",
// serverHost : "https://ceshi.yaoulive.com",
//
txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -135,7 +135,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
mRandomPkSwitch.setOnClickListener(this);
mPkBtn.setOnClickListener(this);
mPkBtn.setTag(false);
/* mPkBtn.setOnLongClickListener(v -> {
mPkBtn.setOnLongClickListener(v -> {
DialogUitl.showSimpleInputDialog(mContext, "输入指定UID", new DialogUitl.SimpleCallback() {
@Override
public void onConfirmClick(Dialog dialog, String content) {
@ -145,7 +145,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
}
});
return false;
});*/
});
}
private void initData() {

View File

@ -259,8 +259,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
});
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) {
//跳转消息列表
if (mViewPager != null) {
mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2);
}
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("8")) {
WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true);
@ -381,8 +383,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
mUrlCsd = configBean.getCustomerServerUrl();
init();
initTXIM();
if (mViewPager != null) {
mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0);
}
isInstructor();
RongConfigCenter.notificationConfig().setInterceptor(new NotificationConfig.Interceptor() {
@ -1160,7 +1164,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
finish();
} else if (event.getPage() == 17) {
showStartDialog();
} else {
} else if (mViewPager != null) {
mViewPager.setCurrentItem(event.getPage());
mTabButtonGroup.setCurPosition(event.getPage());
if (event.getPage() == 0) {
@ -1229,10 +1233,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Subscribe(threadMode = ThreadMode.MAIN)
public void onInstructorOperationEvent(InstructorOperationEvent event) {
//跳转消息列表
if (mViewPager != null) {
mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2);
mainMessageViewHolder.setHomeZdyPop(NoviceInstructorManager.get(this).getHomeZdyPop());
}
}
/**
* 新人面向指导员的引导
@ -1262,9 +1268,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override
public void onClick(View v) {
//跳转消息列表
if (mViewPager != null) {
mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2);
}
}
});
} else {
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) floatBanner.getLayoutParams();