From 291a923d51b73f0ee337fd5675150c2099cbcb83 Mon Sep 17 00:00:00 2001 From: Konrad Pozniak Date: Mon, 25 Mar 2019 20:35:36 +0100 Subject: [PATCH] fix crash when filter request returns an error (#1150) --- .../tusky/fragment/TimelineFragment.java | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java index edc415c0b..20c1a330e 100644 --- a/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java +++ b/app/src/main/java/com/keylesspalace/tusky/fragment/TimelineFragment.java @@ -319,13 +319,18 @@ public class TimelineFragment extends SFragment implements private void reloadFilters(boolean refresh) { mastodonApi.getFilters().enqueue(new Callback>() { @Override - public void onResponse(Call> call, Response> response) { - applyFilters(response.body(), refresh); + public void onResponse(@NonNull Call> call, @NonNull Response> response) { + List filterList = response.body(); + if(response.isSuccessful() && filterList != null) { + applyFilters(filterList, refresh); + } else { + Log.e(TAG, "Error getting filters from server"); + } } @Override - public void onFailure(Call> call, Throwable t) { - Log.e(TAG, "Error getting filters from server"); + public void onFailure(@NonNull Call> call, @NonNull Throwable t) { + Log.e(TAG, "Error getting filters from server", t); } }); }