fix crash when filter request returns an error (#1150)

This commit is contained in:
Konrad Pozniak 2019-03-25 20:35:36 +01:00 committed by GitHub
parent 2e52457b32
commit 291a923d51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 4 deletions

View File

@ -319,13 +319,18 @@ public class TimelineFragment extends SFragment implements
private void reloadFilters(boolean refresh) { private void reloadFilters(boolean refresh) {
mastodonApi.getFilters().enqueue(new Callback<List<Filter>>() { mastodonApi.getFilters().enqueue(new Callback<List<Filter>>() {
@Override @Override
public void onResponse(Call<List<Filter>> call, Response<List<Filter>> response) { public void onResponse(@NonNull Call<List<Filter>> call, @NonNull Response<List<Filter>> response) {
applyFilters(response.body(), refresh); List<Filter> filterList = response.body();
if(response.isSuccessful() && filterList != null) {
applyFilters(filterList, refresh);
} else {
Log.e(TAG, "Error getting filters from server");
}
} }
@Override @Override
public void onFailure(Call<List<Filter>> call, Throwable t) { public void onFailure(@NonNull Call<List<Filter>> call, @NonNull Throwable t) {
Log.e(TAG, "Error getting filters from server"); Log.e(TAG, "Error getting filters from server", t);
} }
}); });
} }