From 5317f6d88fe1a14d3e341d4c1c7de0003040449c Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Tue, 13 Dec 2022 13:23:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E4=BF=AE=E5=A4=8D=E9=A6=96=E9=A1=B5ViewPag?= =?UTF-8?q?er.setCurrentItem(int)=E4=B8=BAnull=E5=AF=BC=E8=87=B4=E7=9A=84?= =?UTF-8?q?=E9=97=AA=E9=80=80=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../yunbao/common/manager/IMRTCManager.java | 10 +++---- config.gradle | 4 +-- .../live/dialog/RandomPkDialogFragment.java | 4 +-- .../yunbao/main/activity/MainActivity.java | 28 ++++++++++++------- 4 files changed, 27 insertions(+), 19 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java b/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java index 234faed65..e56e62703 100644 --- a/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java +++ b/common/src/main/java/com/yunbao/common/manager/IMRTCManager.java @@ -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 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() { diff --git a/config.gradle b/config.gradle index b1defc16c..b09f3fcbf 100644 --- a/config.gradle +++ b/config.gradle @@ -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", diff --git a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java index 2503ee80a..a8552e9aa 100644 --- a/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java +++ b/live/src/main/java/com/yunbao/live/dialog/RandomPkDialogFragment.java @@ -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() { diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java index efd5f0da4..4edc5b9c1 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -259,8 +259,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene }); } else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("2")) { //跳转消息列表 - mViewPager.setCurrentItem(2); - mTabButtonGroup.setCurPosition(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(); - mViewPager.setCurrentItem(0); - mTabButtonGroup.setCurPosition(0); + 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,9 +1233,11 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Subscribe(threadMode = ThreadMode.MAIN) public void onInstructorOperationEvent(InstructorOperationEvent event) { //跳转消息列表 - mViewPager.setCurrentItem(2); - mTabButtonGroup.setCurPosition(2); - mainMessageViewHolder.setHomeZdyPop(NoviceInstructorManager.get(this).getHomeZdyPop()); + if (mViewPager != null) { + mViewPager.setCurrentItem(2); + mTabButtonGroup.setCurPosition(2); + mainMessageViewHolder.setHomeZdyPop(NoviceInstructorManager.get(this).getHomeZdyPop()); + } } /** @@ -1262,8 +1268,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene @Override public void onClick(View v) { //跳转消息列表 - mViewPager.setCurrentItem(2); - mTabButtonGroup.setCurPosition(2); + if (mViewPager != null) { + mViewPager.setCurrentItem(2); + mTabButtonGroup.setCurPosition(2); + } } }); } else {