Browse Source

Maybe fix #469. Not sure how the list adapter can not be set, but let's work from here by not crashing first.

pull/471/head
Eric Kok 6 years ago
parent
commit
22adee57c4
  1. 7
      app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java

7
app/src/main/java/org/transdroid/core/gui/TorrentsFragment.java

@ -102,6 +102,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
protected SwipeRefreshLayout swipeRefreshLayout; protected SwipeRefreshLayout swipeRefreshLayout;
@ViewById @ViewById
protected ListView torrentsList; protected ListView torrentsList;
protected ListView torrentsList;
@ViewById @ViewById
protected TextView emptyText; protected TextView emptyText;
@ViewById @ViewById
@ -251,7 +252,9 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
// Sort the list of filtered torrents // Sort the list of filtered torrents
Collections.sort(filteredTorrents, new TorrentsComparator(daemonType, this.currentSortOrder, this.currentSortDescending)); 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(); updateViewVisibility();
} }
@ -464,7 +467,7 @@ public class TorrentsFragment extends Fragment implements OnLabelPickedListener
if (!hasAConnection) { if (!hasAConnection) {
return; return;
} }
boolean isEmpty = torrents == null || torrentsList.getAdapter().isEmpty(); boolean isEmpty = torrents == null || torrentsList.getAdapter() != null && torrentsList.getAdapter().isEmpty();
boolean hasError = connectionErrorMessage != null; boolean hasError = connectionErrorMessage != null;
nosettingsText.setVisibility(View.GONE); nosettingsText.setVisibility(View.GONE);
errorText.setVisibility(hasError ? View.VISIBLE : View.GONE); errorText.setVisibility(hasError ? View.VISIBLE : View.GONE);

Loading…
Cancel
Save