From 101525ae334b55cfcad887a64811c3b31ac8753a Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Fri, 4 Feb 2022 11:26:45 +0800 Subject: Minor bugs fixed. --- .../infinityforreddit/fragments/ViewPostDetailFragment.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'app/src/main/java') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java index d9e9f452..700a6a84 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/fragments/ViewPostDetailFragment.java @@ -1216,9 +1216,12 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic sortType, APIUtils.getOAuthHeader(mAccessToken)); } } - postAndComments.enqueue(new Callback() { + postAndComments.enqueue(new Callback<>() { @Override public void onResponse(@NonNull Call call, @NonNull Response response) { + if (!isAdded()) { + return; + } mSwipeRefreshLayout.setRefreshing(false); if (response.isSuccessful()) { @@ -1344,7 +1347,9 @@ public class ViewPostDetailFragment extends Fragment implements FragmentCommunic @Override public void onFailure(@NonNull Call call, @NonNull Throwable t) { - showErrorView(subredditId); + if (isAdded()) { + showErrorView(subredditId); + } } }); } -- cgit v1.2.3