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) {
mastodonApi.getFilters().enqueue(new Callback<List<Filter>>() {
@Override
public void onResponse(Call<List<Filter>> call, Response<List<Filter>> response) {
applyFilters(response.body(), refresh);
public void onResponse(@NonNull Call<List<Filter>> call, @NonNull Response<List<Filter>> response) {
List<Filter> 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<List<Filter>> call, Throwable t) {
Log.e(TAG, "Error getting filters from server");
public void onFailure(@NonNull Call<List<Filter>> call, @NonNull Throwable t) {
Log.e(TAG, "Error getting filters from server", t);
}
});
}