From 08c1bbd25340269fdb173bb61ca4416a9d931eef Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Wed, 13 Mar 2019 09:32:59 +0100 Subject: [PATCH] fix crash in NotificationsFragment (#1119) * fix crash in NotificationsFragment * don't reload notifications * add updateAdapter() --- .../com/keylesspalace/tusky/TabPreferenceActivity.kt | 7 ++++++- .../tusky/fragment/NotificationsFragment.java | 11 ++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt index d8d07c05..10429c6d 100644 --- a/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/TabPreferenceActivity.kt @@ -47,6 +47,8 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene private lateinit var touchHelper: ItemTouchHelper private lateinit var addTabAdapter: TabAdapter + private var tabsChanged = false + private val selectedItemElevation by lazy { resources.getDimension(R.dimen.selected_drag_item_elevation) } override fun onCreate(savedInstanceState: Bundle?) { @@ -188,6 +190,7 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene .subscribe() } + tabsChanged = true } override fun onBackPressed() { @@ -208,7 +211,9 @@ class TabPreferenceActivity : BaseActivity(), Injectable, ItemInteractionListene override fun onPause() { super.onPause() - eventHub.dispatch(MainTabsChangedEvent(currentTabs)) + if(tabsChanged) { + eventHub.dispatch(MainTabsChangedEvent(currentTabs)) + } } companion object { 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 6401928f..43a6cc6e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/NotificationsFragment.java @@ -207,14 +207,19 @@ public class NotificationsFragment extends SFragment implements adapter.setUseAbsoluteTime(useAbsoluteTime); recyclerView.setAdapter(adapter); - notifications.clear(); topLoading = false; bottomLoading = false; bottomId = null; - ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false); + updateAdapter(); - sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1); + if (notifications.isEmpty()) { + sendFetchNotificationsRequest(null, null, FetchEnd.BOTTOM, -1); + } else { + progressBar.setVisibility(View.GONE); + } + + ((SimpleItemAnimator) recyclerView.getItemAnimator()).setSupportsChangeAnimations(false); return rootView; }