diff options
author | Christian Schneppe <christian@pix-art.de> | 2019-04-12 21:16:26 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2019-04-12 21:16:26 +0200 |
commit | 39faf1736756aa31222a4e621d16c18851361d31 (patch) | |
tree | 528d03bcd7eaf821ee9aceb069b9168cd7d9aa95 /src/main | |
parent | e7a54fb663fe7f66082c88aae6bb9baf9d042639 (diff) |
fix some NPE
Diffstat (limited to 'src/main')
3 files changed, 24 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java index 90b2784a5..5ba0355a8 100644 --- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java +++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java @@ -1734,7 +1734,7 @@ public class XmppConnectionService extends Service { } public void pushBookmarks(Account account) { - if (account.getXmppConnection().getFeatures().bookmarksConversion()) { + if (account.getXmppConnection() != null && account.getXmppConnection().getFeatures().bookmarksConversion()) { pushBookmarksPep(account); } else { pushBookmarksPrivateXml(account); diff --git a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java index 8ac8868fc..0840fc3fc 100644 --- a/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java +++ b/src/main/java/de/pixart/messenger/ui/ConferenceDetailsActivity.java @@ -221,20 +221,22 @@ public class ConferenceDetailsActivity extends XmppActivity implements OnConvers this.mAdvancedMode = getPreferences().getBoolean("advanced_muc_mode", false); this.binding.mucInfoMore.setVisibility(this.mAdvancedMode ? View.VISIBLE : View.GONE); this.binding.notificationStatusButton.setOnClickListener(this.mNotifyStatusClickListener); - this.binding.detailsMucAvatar.setOnClickListener(v -> { - final MucOptions mucOptions = mConversation.getMucOptions(); - if (!mucOptions.hasVCards()) { - Toast.makeText(this, R.string.host_does_not_support_group_chat_avatars, Toast.LENGTH_SHORT).show(); - return; - } - if (!mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { - Toast.makeText(this, R.string.only_the_owner_can_change_group_chat_avatar, Toast.LENGTH_SHORT).show(); - return; - } - final Intent intent = new Intent(this, PublishGroupChatProfilePictureActivity.class); - intent.putExtra("uuid", mConversation.getUuid()); - startActivity(intent); - }); + if (mConversation != null) { + this.binding.detailsMucAvatar.setOnClickListener(v -> { + final MucOptions mucOptions = mConversation.getMucOptions(); + if (!mucOptions.hasVCards()) { + Toast.makeText(this, R.string.host_does_not_support_group_chat_avatars, Toast.LENGTH_SHORT).show(); + return; + } + if (!mucOptions.getSelf().getAffiliation().ranks(MucOptions.Affiliation.OWNER)) { + Toast.makeText(this, R.string.only_the_owner_can_change_group_chat_avatar, Toast.LENGTH_SHORT).show(); + return; + } + final Intent intent = new Intent(this, PublishGroupChatProfilePictureActivity.class); + intent.putExtra("uuid", mConversation.getUuid()); + startActivity(intent); + }); + } this.binding.editMucNameButton.setOnClickListener(this::onMucEditButtonClicked); this.binding.mucEditTitle.addTextChangedListener(this); this.binding.mucEditSubject.addTextChangedListener(this); diff --git a/src/main/java/de/pixart/messenger/utils/RichPreview.java b/src/main/java/de/pixart/messenger/utils/RichPreview.java index e0bff1cf2..10e10b033 100644 --- a/src/main/java/de/pixart/messenger/utils/RichPreview.java +++ b/src/main/java/de/pixart/messenger/utils/RichPreview.java @@ -19,8 +19,10 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; +import java.io.UnsupportedEncodingException; import java.net.URI; import java.net.URISyntaxException; +import java.net.URLEncoder; import java.util.Calendar; import java.util.Date; import java.util.regex.Pattern; @@ -134,7 +136,11 @@ public class RichPreview { } catch (URISyntaxException e) { e.printStackTrace(); } - base_uri = base_uri != null ? base_uri.resolve(part) : null; + try { + base_uri = base_uri != null ? base_uri.resolve(URLEncoder.encode(part, "UTF-8")) : null; + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } return base_uri != null ? base_uri.toString() : null; } } |