aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2019-03-06 21:38:41 +0100
committerChristian Schneppe <christian@pix-art.de>2019-03-06 21:38:41 +0100
commitd450fe5113c5dab799eed214bf0b995dc57b985b (patch)
tree0125a1695d182e5e11fb5b8e3bf5e1139131219a /src
parent9b4fcd7e1f7b721b477ac67f3ff18ebdc45de6a2 (diff)
try to catch some NPE
Diffstat (limited to 'src')
-rw-r--r--src/main/java/de/pixart/messenger/services/ExportBackupService.java2
-rw-r--r--src/main/java/de/pixart/messenger/services/XmppConnectionService.java7
-rw-r--r--src/main/java/de/pixart/messenger/ui/EditAccountActivity.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/XmppActivity.java4
-rw-r--r--src/main/java/de/pixart/messenger/ui/widget/RichLinkView.java17
5 files changed, 18 insertions, 16 deletions
diff --git a/src/main/java/de/pixart/messenger/services/ExportBackupService.java b/src/main/java/de/pixart/messenger/services/ExportBackupService.java
index 90bb25452..4603a441f 100644
--- a/src/main/java/de/pixart/messenger/services/ExportBackupService.java
+++ b/src/main/java/de/pixart/messenger/services/ExportBackupService.java
@@ -226,7 +226,7 @@ public class ExportBackupService extends Service {
new Thread(() -> {
final Bundle extras = intent.getExtras();
boolean notify = false;
- if (extras != null & extras.containsKey("NOTIFY_ON_BACKUP_COMPLETE")) {
+ if (extras != null && extras.containsKey("NOTIFY_ON_BACKUP_COMPLETE")) {
notify = extras.getBoolean("NOTIFY_ON_BACKUP_COMPLETE");
}
final boolean success = export();
diff --git a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
index 03f347519..b06ebc85d 100644
--- a/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
+++ b/src/main/java/de/pixart/messenger/services/XmppConnectionService.java
@@ -4776,6 +4776,11 @@ public class XmppConnectionService extends Service {
}
private void expireOldMessages(long timestamp) {
- databaseBackend.expireOldMessages(timestamp);
+ try {
+ databaseBackend.expireOldMessages(timestamp);
+ } catch (Exception e) {
+ e.printStackTrace();
+ expireOldMessages(timestamp);
+ }
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
index 129f5400e..456b907df 100644
--- a/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/EditAccountActivity.java
@@ -626,10 +626,10 @@ public class EditAccountActivity extends OmemoActivity implements OnAccountUpdat
private void onEditYourNameClicked(View view) {
String nick;
try {
- if (mAccount.getDisplayName() != null) {
+ if (mAccount != null) {
nick = mAccount.getDisplayName();
} else {
- nick = mAccount.getJid().getLocal();
+ nick = "";
}
} catch (Exception e) {
e.printStackTrace();
diff --git a/src/main/java/de/pixart/messenger/ui/XmppActivity.java b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
index 10ca37c7c..b254549af 100644
--- a/src/main/java/de/pixart/messenger/ui/XmppActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/XmppActivity.java
@@ -1001,8 +1001,8 @@ public abstract class XmppActivity extends ActionBarActivity {
(dialog, id) -> {
String selection = spinner.getSelectedItem().toString();
Account mAccount = xmppConnectionService.findAccountByJid(Jid.of(selection).asBareJid());
- String user = Jid.of(selection).getLocal();
- String domain = Jid.of(selection).getDomain();
+ String user = mAccount.getDisplayName();
+ String domain = mAccount.getJid().getDomain();
String inviteURL = AdHocInviteUri(mAccount);
if (inviteURL == null) {
inviteURL = Config.inviteUserURL + user + "/" + domain;
diff --git a/src/main/java/de/pixart/messenger/ui/widget/RichLinkView.java b/src/main/java/de/pixart/messenger/ui/widget/RichLinkView.java
index dbe6a4629..ec99c6aee 100644
--- a/src/main/java/de/pixart/messenger/ui/widget/RichLinkView.java
+++ b/src/main/java/de/pixart/messenger/ui/widget/RichLinkView.java
@@ -1,5 +1,6 @@
package de.pixart.messenger.ui.widget;
+import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
@@ -12,6 +13,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
+import android.widget.Toast;
import com.squareup.picasso.Picasso;
@@ -80,14 +82,6 @@ public class RichLinkView extends RelativeLayout {
textViewTitle = findViewById(R.id.rich_link_title);
textViewDesp = findViewById(R.id.rich_link_desp);
imageView.setAdjustViewBounds(true);
- if (!meta.getImageurl().equals("") || !meta.getImageurl().isEmpty()
- && !meta.getTitle().isEmpty() || !meta.getTitle().equals("")
- && !meta.getUrl().isEmpty() || !meta.getUrl().equals("")
- && !meta.getDescription().isEmpty() || !meta.getDescription().equals("")) {
- linearLayout.setVisibility(VISIBLE);
- } else {
- linearLayout.setVisibility(VISIBLE);
- }
if (!meta.getImageurl().equals("") && !meta.getImageurl().isEmpty()) {
if (!dataSaverDisabled) {
Picasso.get()
@@ -98,7 +92,6 @@ public class RichLinkView extends RelativeLayout {
Picasso.get()
.load(meta.getImageurl())
.resize(80, 80)
- .onlyScaleDown()
.centerInside()
.placeholder(R.drawable.ic_web_grey600_48)
.into(imageView);
@@ -138,7 +131,11 @@ public class RichLinkView extends RelativeLayout {
private void richLinkClicked() {
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(main_url));
- context.startActivity(intent);
+ try {
+ context.startActivity(intent);
+ } catch (ActivityNotFoundException e) {
+ Toast.makeText(context, R.string.no_application_found_to_open_link, Toast.LENGTH_LONG).show();
+ }
}
public void setDefaultClickListener(boolean isDefault) {