修复firebase反馈的空指针问题

This commit is contained in:
zlzw 2022-10-28 13:50:34 +08:00
parent 07ae094bed
commit b394a8f9b5
7 changed files with 33 additions and 15 deletions

View File

@ -287,6 +287,9 @@ public class AppContext extends CommonAppContext {
public boolean isMainProcess() { public boolean isMainProcess() {
int pid = android.os.Process.myPid(); int pid = android.os.Process.myPid();
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE); ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
if (activityManager.getRunningAppProcesses() == null) {
return true;
}
for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) { for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) {
if (appProcess.pid == pid) { if (appProcess.pid == pid) {
return getApplicationInfo().packageName.equals(appProcess.processName); return getApplicationInfo().packageName.equals(appProcess.processName);
@ -339,7 +342,7 @@ public class AppContext extends CommonAppContext {
} }
private void setFirebaseCrashData(){ private void setFirebaseCrashData() {
if (!CommonAppConfig.IS_UPLOAD_ERROR_LOG) { if (!CommonAppConfig.IS_UPLOAD_ERROR_LOG) {
return; return;
} }

View File

@ -131,7 +131,7 @@ public class ImgLoader {
} }
public static void displayAvatar(Context context, String url, ImageView imageView, int width, int height) { public static void displayAvatar(Context context, String url, ImageView imageView, int width, int height) {
if (!contextIsExist(context)) { if (!contextIsExist(context) || imageView == null) {
return; return;
} }

View File

@ -147,7 +147,7 @@ public class StringUtil {
return sStringBuilder.toString(); return sStringBuilder.toString();
} }
public static boolean isEmpty(String bgColor) { public static boolean isEmpty(String str) {
return bgColor == null || "".equals(bgColor.trim()) || bgColor.trim().length() == 0; return str == null || "".equals(str.trim()) || str.trim().length() == 0;
} }
} }

View File

@ -508,6 +508,9 @@ public class PortraitLiveManager implements LivePlayListener, SocketMessageListe
DialogUitl.showSimpleDialog(mContext, null, "連麥中,退出將斷開語音連麥!", false, new DialogUitl.SimpleCallback3() { DialogUitl.showSimpleDialog(mContext, null, "連麥中,退出將斷開語音連麥!", false, new DialogUitl.SimpleCallback3() {
@Override @Override
public void onConfirmClick(Dialog dialog) { public void onConfirmClick(Dialog dialog) {
if (RCRTCEngine.getInstance().getRoom() == null || RCRTCEngine.getInstance().getRoom().getLocalUser() == null) {
return;
}
ToastUtil.show("下麥中,稍等....."); ToastUtil.show("下麥中,稍等.....");
RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() { RCRTCEngine.getInstance().getRoom().getLocalUser().switchToAudience(new IRCRTCSwitchRoleCallback() {

View File

@ -202,6 +202,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() { CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
@Override @Override
public void callback(ConfigBean bean) { public void callback(ConfigBean bean) {
if(bean==null){
return;
}
//是否需要老用户回归弹窗 //是否需要老用户回归弹窗
if (TextUtils.equals(bean.getIsReturnUser(), "1")) { if (TextUtils.equals(bean.getIsReturnUser(), "1")) {
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@ -726,8 +729,10 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
bundle.putString("send_exp", obj.getString("send_exp")); bundle.putString("send_exp", obj.getString("send_exp"));
bundle.putString("sign_day", obj.getString("sign_day")); bundle.putString("sign_day", obj.getString("sign_day"));
fragment.setArguments(bundle); fragment.setArguments(bundle);
if(!getSupportFragmentManager().isStateSaved()) {
fragment.show(getSupportFragmentManager(), "SigninDialog"); fragment.show(getSupportFragmentManager(), "SigninDialog");
} }
}
if (obj != null && obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) { if (obj != null && obj.containsKey("msg_zdy_send") && obj.containsKey("msg_zdy_send_text")) {
Log.e("MainActivity333", info[0]); Log.e("MainActivity333", info[0]);
NoviceInstructorManager.get(mContext).getNetNoviceInstructor(info[0]); NoviceInstructorManager.get(mContext).getNetNoviceInstructor(info[0]);

View File

@ -23,6 +23,7 @@ import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.http.HttpClient; import com.yunbao.common.http.HttpClient;
import com.yunbao.common.manager.IMLoginManager; import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.manager.NoviceInstructorManager; import com.yunbao.common.manager.NoviceInstructorManager;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.activity.LiveAudienceActivity; import com.yunbao.live.activity.LiveAudienceActivity;
@ -117,9 +118,9 @@ public class OneLoginDialog extends AbsDialogFragment {
@Override @Override
public void onSuccess(int code, String msg, String[] info) { public void onSuccess(int code, String msg, String[] info) {
dismiss(); dismiss();
if (info[0] != null) { if (info.length > 0 && !StringUtil.isEmpty(info[0])) {
JSONObject obj = JSON.parseObject(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_us = obj.getString("home_zdy_img_us");
home_zdy_img_cn = obj.getString("home_zdy_img_cn"); home_zdy_img_cn = obj.getString("home_zdy_img_cn");
} }

View File

@ -106,7 +106,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
mRefreshView.showRefreshBar(); mRefreshView.showRefreshBar();
mRefreshView.mRecyclerView.scrollToPosition(0); mRefreshView.mRecyclerView.scrollToPosition(0);
} }
}else if ("blacklist".equals(str)) { } else if ("blacklist".equals(str)) {
if (mRefreshView != null) { if (mRefreshView != null) {
mRefreshView.showRefreshBar(); mRefreshView.showRefreshBar();
} }
@ -199,8 +199,14 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
JSONObject obj = JSON.parseObject(info[0]); JSONObject obj = JSON.parseObject(info[0]);
if (select == 0) { if (select == 0) {
mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class); mBannerList = JSON.parseArray(obj.getString("slide"), BannerBean.class);
if (!obj.containsKey("list")) {
return new_data;
}
List<LiveBean> old_data = JSON.parseArray(obj.getString("list"), LiveBean.class); List<LiveBean> old_data = JSON.parseArray(obj.getString("list"), LiveBean.class);
LiveBean liveModel = null; LiveBean liveModel = null;
if (old_data == null) {
return new_data;
}
for (LiveBean model : old_data) { for (LiveBean model : old_data) {
//判断周星榜数据 //判断周星榜数据
if (TextUtils.equals(model.getIs_week(), "1")) { if (TextUtils.equals(model.getIs_week(), "1")) {
@ -322,7 +328,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
return; return;
} }
intoIndex = 1; intoIndex = 1;
if (gotoRoomKey!=null&&gotoRoomKey.isEmpty()) { if (gotoRoomKey != null && gotoRoomKey.isEmpty()) {
gotoRoomKey = null; gotoRoomKey = null;
} }
LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", gotoRoomKey, 0, liveSdk); LiveAudienceActivity.forward(mContext, liveBean, liveType, liveTypeVal, "", gotoRoomKey, 0, liveSdk);
@ -363,8 +369,8 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
ToastUtil.show("暫無法簽到,請稍後再試"); ToastUtil.show("暫無法簽到,請稍後再試");
return; return;
} else { } else {
if(gotoRoomKey==null){ if (gotoRoomKey == null) {
gotoRoomKey=new HashMap<>(); gotoRoomKey = new HashMap<>();
} }
gotoRoomKey.put("OPEN", "NEWUSER"); gotoRoomKey.put("OPEN", "NEWUSER");
} }
@ -386,7 +392,7 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
/** /**
* Banner双击可能会导致进入两次直播间点击Banner后需要展示加载中动画 * Banner双击可能会导致进入两次直播间点击Banner后需要展示加载中动画
*/ */
private void showLoadingDialog(){ private void showLoadingDialog() {
mShowLoadingDialog = DialogUitl.loadingDialog(mContext); mShowLoadingDialog = DialogUitl.loadingDialog(mContext);
mShowLoadingDialog.show(); mShowLoadingDialog.show();
} }
@ -469,9 +475,9 @@ public class MainHomeLiveViewHolder extends AbsMainHomeChildViewHolder implement
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
if(mShowLoadingDialog !=null){ if (mShowLoadingDialog != null) {
mShowLoadingDialog.dismiss(); mShowLoadingDialog.dismiss();
mShowLoadingDialog =null; mShowLoadingDialog = null;
} }
} }
} }