From 6815021a533698975b713f1673b3a41c54c117db Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Mon, 10 Dec 2018 08:47:53 +0100 Subject: [PATCH] Fix a few crashes Signed-off-by: Mario Danic --- .../CallNotificationController.java | 2 +- .../ConversationInfoController.java | 31 +++++++++++++------ .../talk/controllers/SettingsController.java | 12 +++++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java index 0bb90d974..e4decdcd3 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/CallNotificationController.java @@ -431,7 +431,7 @@ public class CallNotificationController extends BaseController { .into(new SimpleTarget() { @Override public void onResourceReady(Bitmap resource, Transition transition) { - if (getActivity() != null) { + if (getActivity() != null && avatarImageView != null) { avatarImageView.setImageBitmap(TransformationUtils.circleCrop(GlideApp.get (getActivity()).getBitmapPool(), resource, avatarSize, avatarSize)); } diff --git a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java index ebe83ef68..493828772 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/ConversationInfoController.java @@ -161,15 +161,17 @@ public class ConversationInfoController extends BaseController { } private void setupAdapter() { - if (adapter == null) { + if (adapter == null && getActivity() != null) { adapter = new FlexibleAdapter<>(recyclerViewItems, getActivity(), true); } - SmoothScrollLinearLayoutManager layoutManager = - new SmoothScrollLinearLayoutManager(getActivity()); - recyclerView.setLayoutManager(layoutManager); - recyclerView.setHasFixedSize(true); - recyclerView.setAdapter(adapter); + if (recyclerView != null && getActivity() != null) { + SmoothScrollLinearLayoutManager layoutManager = + new SmoothScrollLinearLayoutManager(getActivity()); + recyclerView.setLayoutManager(layoutManager); + recyclerView.setHasFixedSize(true); + recyclerView.setAdapter(adapter); + } } private void handleParticipants(List participants) { @@ -260,13 +262,22 @@ public class ConversationInfoController extends BaseController { progressBar.setVisibility(View.GONE); } - nameCategoryView.setVisibility(View.VISIBLE); - conversationDisplayName.setText(conversation.getDisplayName()); + if (nameCategoryView != null) { + nameCategoryView.setVisibility(View.VISIBLE); + } + + if (conversationDisplayName != null) { + conversationDisplayName.setText(conversation.getDisplayName()); + } + loadConversationAvatar(); if (conversationUser.hasSpreedCapabilityWithName("notification-levels")) { - messageNotificationLevel.setEnabled(true); - messageNotificationLevel.setAlpha(1.0f); + if (messageNotificationLevel != null) { + messageNotificationLevel.setEnabled(true); + messageNotificationLevel.setAlpha(1.0f); + } + if (!conversation.getNotificationLevel().equals(Conversation.NotificationLevel.DEFAULT)) { String stringValue; switch (new EnumNotificationLevelConverter().convertToInt(conversation.getNotificationLevel())) { diff --git a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java index 1064724ff..8190f610d 100644 --- a/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java +++ b/app/src/main/java/com/nextcloud/talk/controllers/SettingsController.java @@ -616,13 +616,19 @@ public class SettingsController extends BaseController { } else { switch (newValue) { case "HTTP": - proxyPortEditText.setValue("3128"); + if (proxyPortEditText != null) { + proxyPortEditText.setValue("3128"); + } break; case "DIRECT": - proxyPortEditText.setValue("8080"); + if (proxyPortEditText != null) { + proxyPortEditText.setValue("8080"); + } break; case "SOCKS": - proxyPortEditText.setValue("1080"); + if (proxyPortEditText != null) { + proxyPortEditText.setValue("1080"); + } break; default: break;