From 4feb4659a3e2617433d4ce24ef561bc2a18da990 Mon Sep 17 00:00:00 2001 From: Thomas Date: Mon, 13 Feb 2023 16:11:34 +0100 Subject: [PATCH] Fix some crashes --- .../app/fedilab/android/BaseMainActivity.java | 2 +- .../mastodon/activities/MediaActivity.java | 4 +++- .../peertube/activities/PeertubeMainActivity.java | 15 +++++++++------ 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/BaseMainActivity.java b/app/src/main/java/app/fedilab/android/BaseMainActivity.java index df53fc82..daa98015 100644 --- a/app/src/main/java/app/fedilab/android/BaseMainActivity.java +++ b/app/src/main/java/app/fedilab/android/BaseMainActivity.java @@ -478,7 +478,7 @@ public abstract class BaseMainActivity extends BaseActivity implements NetworkSt if (!activity.isDestroyed() && !activity.isFinishing() && url != null) { if (url.trim().isEmpty()) { BitmapDrawable avatar = new AvatarGenerator.AvatarBuilder(activity) - .setLabel(account.peertube_account.getAcct()) + .setLabel(acct) .setAvatarSize(120) .setTextSize(30) .toSquare() diff --git a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java index db986092..e5fe7591 100644 --- a/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java +++ b/app/src/main/java/app/fedilab/android/mastodon/activities/MediaActivity.java @@ -126,8 +126,10 @@ public class MediaActivity extends BaseTransparentActivity implements OnDownload getSupportActionBar().setDisplayShowHomeEnabled(true); } - if (attachments == null || attachments.size() == 0) + if (attachments == null || attachments.size() == 0) { finish(); + return; + } setTitle(""); diff --git a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java index 8596ade3..066d978e 100644 --- a/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java +++ b/app/src/main/java/app/fedilab/android/peertube/activities/PeertubeMainActivity.java @@ -166,7 +166,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { badgeCount = 0; headerMenuOpen = false; binding.navView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); - + startInForeground(); if (getSupportActionBar() != null) { getSupportActionBar().setDisplayShowTitleEnabled(false); } @@ -377,7 +377,7 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { peertubeInformation.setPrivacies(new LinkedHashMap<>()); peertubeInformation.setPlaylistPrivacies(new LinkedHashMap<>()); peertubeInformation.setTranslations(new LinkedHashMap<>()); - startInForeground(); + //noinspection ConstantConditions if (BuildConfig.FLAVOR.compareTo("playstore") == 0) { @@ -417,10 +417,13 @@ public class PeertubeMainActivity extends PeertubeBaseMainActivity { private void startInForeground() { Intent notificationIntent = new Intent(this, RetrieveInfoService.class); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { - startForegroundService(notificationIntent); - } else { - startService(notificationIntent); + try { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + startForegroundService(notificationIntent); + } else { + startService(notificationIntent); + } + } catch (Exception ignored) { } }