From 1fef8c0c2b410fb54c48087dfe174ed10b0408d3 Mon Sep 17 00:00:00 2001 From: Conny Duck Date: Fri, 24 Aug 2018 19:47:27 +0200 Subject: [PATCH] fix crash in NotificationsFragment when Preferences are first accessed fixes #797 --- .../keylesspalace/tusky/adapter/NotificationsAdapter.java | 4 ++++ .../keylesspalace/tusky/fragment/NotificationsFragment.java | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java index fa71d00e..52d20555 100644 --- a/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java +++ b/app/src/main/java/com/keylesspalace/tusky/adapter/NotificationsAdapter.java @@ -233,6 +233,10 @@ public class NotificationsAdapter extends RecyclerView.Adapter { mediaPreviewEnabled = enabled; } + public boolean isMediaPreviewEnabled() { + return mediaPreviewEnabled; + } + public interface NotificationActionListener { void onViewAccount(String id); diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java index 1a76a227..d6ece229 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -522,8 +522,10 @@ public class NotificationsFragment extends SFragment implements } case "mediaPreviewEnabled": { boolean enabled = sharedPreferences.getBoolean("mediaPreviewEnabled", true); - adapter.setMediaPreviewEnabled(enabled); - fullyRefresh(); + if (enabled != adapter.isMediaPreviewEnabled()) { + adapter.setMediaPreviewEnabled(enabled); + fullyRefresh(); + } break; } }