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); callback.onFailed(RTCErrorCode.RongRTCCodeJoinRepeatedRoom);
return; return;
} }
if (rtcRoom != null) { if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
/* /*
inviteeRoomId - 被邀请者所在房间 id inviteeRoomId - 被邀请者所在房间 id
inviteeUserId - 被邀请用户 id inviteeUserId - 被邀请用户 id
@ -130,7 +130,7 @@ public class IMRTCManager {
* @param listener * @param listener
*/ */
public void registerRoomListener(IRCRTCRoomEventsListener listener) { public void registerRoomListener(IRCRTCRoomEventsListener listener) {
if (rtcRoom != null) { if (rtcRoom != null && rtcRoom.getLocalUser() != null) {
rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() { rtcRoom.registerRoomListener(new IRCRTCRoomEventsListener() {
@Override @Override
public void onRemoteUserPublishResource(RCRTCRemoteUser remoteUser, List<RCRTCInputStream> streams) { public void onRemoteUserPublishResource(RCRTCRemoteUser remoteUser, List<RCRTCInputStream> streams) {
@ -188,7 +188,7 @@ public class IMRTCManager {
* @param callback 回调 * @param callback 回调
*/ */
public void cancelRequestJoinOtherRoom(String liveUid, String extra, IRCRTCResultCallback 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() { rtcRoom.getLocalUser().cancelRequestJoinOtherRoom(liveUid, liveUid, extra, new IRCRTCResultCallback() {
@Override @Override
public void onSuccess() { public void onSuccess() {

View File

@ -10,9 +10,9 @@ ext {
manifestPlaceholders = [ 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", txMapAppKey : "EOZBZ-ASLCU-4XPV3-BDCHZ-4E3Q7-H4BWB",

View File

@ -135,7 +135,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
mRandomPkSwitch.setOnClickListener(this); mRandomPkSwitch.setOnClickListener(this);
mPkBtn.setOnClickListener(this); mPkBtn.setOnClickListener(this);
mPkBtn.setTag(false); mPkBtn.setTag(false);
/* mPkBtn.setOnLongClickListener(v -> { mPkBtn.setOnLongClickListener(v -> {
DialogUitl.showSimpleInputDialog(mContext, "输入指定UID", new DialogUitl.SimpleCallback() { DialogUitl.showSimpleInputDialog(mContext, "输入指定UID", new DialogUitl.SimpleCallback() {
@Override @Override
public void onConfirmClick(Dialog dialog, String content) { public void onConfirmClick(Dialog dialog, String content) {
@ -145,7 +145,7 @@ public class RandomPkDialogFragment extends AbsDialogFragment implements View.On
} }
}); });
return false; return false;
});*/ });
} }
private void initData() { 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")) { } else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) {
//跳转消息列表 //跳转消息列表
if (mViewPager != null) {
mViewPager.setCurrentItem(2); mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2); mTabButtonGroup.setCurPosition(2);
}
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("8")) { } else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("8")) {
WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true); WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true);
@ -381,8 +383,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
mUrlCsd = configBean.getCustomerServerUrl(); mUrlCsd = configBean.getCustomerServerUrl();
init(); init();
initTXIM(); initTXIM();
if (mViewPager != null) {
mViewPager.setCurrentItem(0); mViewPager.setCurrentItem(0);
mTabButtonGroup.setCurPosition(0); mTabButtonGroup.setCurPosition(0);
}
isInstructor(); isInstructor();
RongConfigCenter.notificationConfig().setInterceptor(new NotificationConfig.Interceptor() { RongConfigCenter.notificationConfig().setInterceptor(new NotificationConfig.Interceptor() {
@ -1160,7 +1164,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
finish(); finish();
} else if (event.getPage() == 17) { } else if (event.getPage() == 17) {
showStartDialog(); showStartDialog();
} else { } else if (mViewPager != null) {
mViewPager.setCurrentItem(event.getPage()); mViewPager.setCurrentItem(event.getPage());
mTabButtonGroup.setCurPosition(event.getPage()); mTabButtonGroup.setCurPosition(event.getPage());
if (event.getPage() == 0) { if (event.getPage() == 0) {
@ -1229,10 +1233,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Subscribe(threadMode = ThreadMode.MAIN) @Subscribe(threadMode = ThreadMode.MAIN)
public void onInstructorOperationEvent(InstructorOperationEvent event) { public void onInstructorOperationEvent(InstructorOperationEvent event) {
//跳转消息列表 //跳转消息列表
if (mViewPager != null) {
mViewPager.setCurrentItem(2); mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2); mTabButtonGroup.setCurPosition(2);
mainMessageViewHolder.setHomeZdyPop(NoviceInstructorManager.get(this).getHomeZdyPop()); mainMessageViewHolder.setHomeZdyPop(NoviceInstructorManager.get(this).getHomeZdyPop());
} }
}
/** /**
* 新人面向指导员的引导 * 新人面向指导员的引导
@ -1262,9 +1268,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Override @Override
public void onClick(View v) { public void onClick(View v) {
//跳转消息列表 //跳转消息列表
if (mViewPager != null) {
mViewPager.setCurrentItem(2); mViewPager.setCurrentItem(2);
mTabButtonGroup.setCurPosition(2); mTabButtonGroup.setCurPosition(2);
} }
}
}); });
} else { } else {
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) floatBanner.getLayoutParams(); RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) floatBanner.getLayoutParams();