Browse Source

Handle null context! Need to add this check in all async listeners.

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
d4a28d6aa1
  1. 4
      app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java
  2. 1
      app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java

4
app/src/main/java/awais/instagrabber/fragments/HashTagFragment.java

@ -1,5 +1,6 @@
package awais.instagrabber.fragments;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Typeface;
import android.os.AsyncTask;
@ -223,7 +224,7 @@ public class HashTagFragment extends Fragment {
postsViewModel.getList().observe(fragmentActivity, postsAdapter::submitList);
binding.mainPosts.setAdapter(postsAdapter);
final RecyclerLazyLoader lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {
if (!hasNextPage) return;
if (!hasNextPage || getContext() == null) return;
binding.swipeRefreshLayout.setRefreshing(true);
fetchPosts();
endCursor = null;
@ -235,6 +236,7 @@ public class HashTagFragment extends Fragment {
stopCurrentExecutor();
binding.swipeRefreshLayout.setRefreshing(true);
currentlyExecuting = new HashtagFetcher(hashtag.substring(1), result -> {
if (getContext() == null) return;
hashtagModel = result;
binding.swipeRefreshLayout.setRefreshing(false);
if (hashtagModel == null) {

1
app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java

@ -327,6 +327,7 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private void fetchProfileDetails() {
new ProfileFetcher(username.substring(1), profileModel -> {
if (getContext() == null) return;
this.profileModel = profileModel;
final String userIdFromCookie = Utils.getUserIdFromCookie(cookie);
final boolean isSelf = isLoggedIn

Loading…
Cancel
Save