From 22adee57c40b5a2150492fda4542b2eadb1713b3 Mon Sep 17 00:00:00 2001 From: Eric Kok Date: Wed, 7 Nov 2018 16:30:57 +0100 Subject: [PATCH] Maybe fix #469. Not sure how the list adapter can not be set, but let's work from here by not crashing first. --- .../java/org/transdroid/core/gui/TorrentsFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java b/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java index 767d6908..f3b0aac3 100644 --- a/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java @@ -102,6 +102,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener protected SwipeRefreshLayout swipeRefreshLayout; @ViewById protected ListView torrentsList; + protected ListView torrentsList; @ViewById protected TextView emptyText; @ViewById @@ -251,7 +252,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener // Sort the list of filtered torrents Collections.sort(filteredTorrents, new TorrentsComparator(daemonType, this.currentSortOrder, this.currentSortDescending)); - ((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents); + if (torrentsList.getAdapter() != null) { + ((TorrentsAdapter) torrentsList.getAdapter()).update(filteredTorrents); + } updateViewVisibility(); } @@ -464,7 +467,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener if (!hasAConnection) { return; } - boolean isEmpty = torrents == null || torrentsList.getAdapter().isEmpty(); + boolean isEmpty = torrents == null || torrentsList.getAdapter() != null && torrentsList.getAdapter().isEmpty(); boolean hasError = connectionErrorMessage != null; nosettingsText.setVisibility(View.GONE); errorText.setVisibility(hasError ? View.VISIBLE : View.GONE);