From b394a8f9b55d303a43ef2bb1f5bcb6bac07874fa Mon Sep 17 00:00:00 2001 From: zlzw <583819556@qq.com> Date: Fri, 28 Oct 2022 13:50:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dfirebase=E5=8F=8D=E9=A6=88?= =?UTF-8?q?=E7=9A=84=E7=A9=BA=E6=8C=87=E9=92=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/shayu/phonelive/AppContext.java | 7 +++++-- .../com/yunbao/common/glide/ImgLoader.java | 2 +- .../com/yunbao/common/utils/StringUtil.java | 4 ++-- .../live/views/PortraitLiveManager.java | 3 +++ .../yunbao/main/activity/MainActivity.java | 7 ++++++- .../yunbao/main/dialog/OneLoginDialog.java | 5 +++-- .../main/views/MainHomeLiveViewHolder.java | 20 ++++++++++++------- 7 files changed, 33 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java index ba2f78824..ccb9772e5 100644 --- a/app/src/main/java/com/shayu/phonelive/AppContext.java +++ b/app/src/main/java/com/shayu/phonelive/AppContext.java @@ -287,6 +287,9 @@ public class AppContext extends CommonAppContext { public boolean isMainProcess() { int pid = android.os.Process.myPid(); ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); + if (activityManager.getRunningAppProcesses() == null) { + return true; + } for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) { if (appProcess.pid == pid) { return getApplicationInfo().packageName.equals(appProcess.processName); @@ -338,8 +341,8 @@ public class AppContext extends CommonAppContext { FirebaseApp.initializeApp(this); } - - private void setFirebaseCrashData(){ + + private void setFirebaseCrashData() { if (!CommonAppConfig.IS_UPLOAD_ERROR_LOG) { return; } diff --git a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java index e987f4d95..4557699e2 100644 --- a/common/src/main/java/com/yunbao/common/glide/ImgLoader.java +++ b/common/src/main/java/com/yunbao/common/glide/ImgLoader.java @@ -131,7 +131,7 @@ public class ImgLoader { } public static void displayAvatar(Context context, String url, ImageView imageView, int width, int height) { - if (!contextIsExist(context)) { + if (!contextIsExist(context) || imageView == null) { return; } diff --git a/common/src/main/java/com/yunbao/common/utils/StringUtil.java b/common/src/main/java/com/yunbao/common/utils/StringUtil.java index b8ac11e99..c32f2c9b2 100644 --- a/common/src/main/java/com/yunbao/common/utils/StringUtil.java +++ b/common/src/main/java/com/yunbao/common/utils/StringUtil.java @@ -147,7 +147,7 @@ public class StringUtil { return sStringBuilder.toString(); } - public static boolean isEmpty(String bgColor) { - return bgColor == null || "".equals(bgColor.trim()) || bgColor.trim().length() == 0; + public static boolean isEmpty(String str) { + return str == null || "".equals(str.trim()) || str.trim().length() == 0; } } diff --git a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java index 175230f32..731b02615 100644 --- a/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java +++ b/live/src/main/java/com/yunbao/live/views/PortraitLiveManager.java @@ -508,6 +508,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe DialogUitl.showSimpleDialog(mContext, null, "連麥中,退出將斷開語音連麥!", false, new DialogUitl.SimpleCallback3() { @Override public void onConfirmClick(Dialog dialog) { + if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) { + return; + } ToastUtil.show("下麥中,稍等....."); RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() { 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 81ef9403b..65683ecf3 100644 --- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java @@ -202,6 +202,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene CommonHttpUtil.getConfig(mContext, new CommonCallback() { @Override public void callback(ConfigBean bean) { + if(bean==null){ + return; + } //是否需要老用户回归弹窗 if (TextUtils.equals(bean.getIsReturnUser(), "1")) { new Handler().postDelayed(new Runnable() { @@ -726,7 +729,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene bundle.putString("send_exp", obj.getString("send_exp")); bundle.putString("sign_day", obj.getString("sign_day")); fragment.setArguments(bundle); - fragment.show(getSupportFragmentManager(), "SigninDialog"); + if(!getSupportFragmentManager().isStateSaved()) { + fragment.show(getSupportFragmentManager(), "SigninDialog"); + } } if (obj != null && obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) { Log.e("MainActivity333", info[0]); diff --git a/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java b/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java index 194473c81..5bb700f6f 100644 --- a/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java +++ b/main/src/main/java/com/yunbao/main/dialog/OneLoginDialog.java @@ -23,6 +23,7 @@ import com.yunbao.common.http.HttpCallback; import com.yunbao.common.http.HttpClient; import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.NoviceInstructorManager; +import com.yunbao.common.utils.StringUtil; import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.live.activity.LiveAudienceActivity; @@ -117,9 +118,9 @@ public class OneLoginDialog extends AbsDialogFragment { @Override public void onSuccess(int code, String msg, String[] info) { dismiss(); - if (info[0] != null) { + if (info.length > 0 && !StringUtil.isEmpty(info[0])) { JSONObject obj = JSON.parseObject(info[0]); - if(obj.containsKey("home_zdy_img_us")) { + if (obj.containsKey("home_zdy_img_us")) { home_zdy_img_us = obj.getString("home_zdy_img_us"); home_zdy_img_cn = obj.getString("home_zdy_img_cn"); } diff --git a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java index ae889d5be..c00ac8e45 100644 --- a/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainHomeLiveViewHolder.java @@ -106,7 +106,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement mRefreshView.showRefreshBar(); mRefreshView.mRecyclerView.scrollToPosition(0); } - }else if ("blacklist".equals(str)) { + } else if ("blacklist".equals(str)) { if (mRefreshView != null) { mRefreshView.showRefreshBar(); } @@ -199,8 +199,14 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement JSONObject obj = JSON.parseObject(info[0]); if (select == 0) { mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class); + if (!obj.containsKey("list")) { + return new_data; + } List old_data = JSON.parseArray(obj.getString("list"), LiveBean.class); LiveBean liveModel = null; + if (old_data == null) { + return new_data; + } for (LiveBean model : old_data) { //判断周星榜数据 if (TextUtils.equals(model.getIs_week(), "1")) { @@ -322,7 +328,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement return; } intoIndex = 1; - if (gotoRoomKey!=null&&gotoRoomKey.isEmpty()) { + if (gotoRoomKey != null && gotoRoomKey.isEmpty()) { gotoRoomKey = null; } LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", gotoRoomKey, 0, liveSdk); @@ -363,8 +369,8 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement ToastUtil.show("暫無法簽到,請稍後再試"); return; } else { - if(gotoRoomKey==null){ - gotoRoomKey=new HashMap<>(); + if (gotoRoomKey == null) { + gotoRoomKey = new HashMap<>(); } gotoRoomKey.put("OPEN", "NEWUSER"); } @@ -386,7 +392,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement /** * Banner双击可能会导致进入两次直播间,点击Banner后需要展示加载中动画 */ - private void showLoadingDialog(){ + private void showLoadingDialog() { mShowLoadingDialog = DialogUitl.loadingDialog(mContext); mShowLoadingDialog.show(); } @@ -469,9 +475,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement @Override public void onPause() { super.onPause(); - if(mShowLoadingDialog !=null){ + if (mShowLoadingDialog != null) { mShowLoadingDialog.dismiss(); - mShowLoadingDialog =null; + mShowLoadingDialog = null; } } }