Browse Source

Null check and fragment manager check. Fixes https://github.com/austinhuang0131/barinsta/issues/1116

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
627b1bfe76
  1. 5
      .codebeatsettings
  2. 12
      app/src/main/java/awais/instagrabber/fragments/StoryListViewerFragment.java
  3. 4
      app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java

5
.codebeatsettings

@ -0,0 +1,5 @@
{
"JAVA": {
"TOO_MANY_IVARS": [8, 10, 20, 30]
}
}

12
app/src/main/java/awais/instagrabber/fragments/StoryListViewerFragment.java

@ -51,12 +51,15 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
private AppCompatActivity fragmentActivity;
private FragmentStoryListViewerBinding binding;
private SwipeRefreshLayout root;
private boolean shouldRefresh = true, firstRefresh = true;
private boolean shouldRefresh = true;
private boolean firstRefresh = true;
private FeedStoriesViewModel feedStoriesViewModel;
private ArchivesViewModel archivesViewModel;
private StoriesService storiesService;
private Context context;
private String type, currentQuery, endCursor = null;
private String type;
private String currentQuery;
private String endCursor = null;
private FeedStoriesListAdapter adapter;
private MenuItem menuSearch;
@ -226,7 +229,10 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
binding.swipeRefreshLayout.setRefreshing(true);
if (type.equals("feed") && firstRefresh) {
binding.swipeRefreshLayout.setRefreshing(false);
adapter.submitList(feedStoriesViewModel.getList().getValue());
final List<FeedStoryModel> value = feedStoriesViewModel.getList().getValue();
if (value != null) {
adapter.submitList(value);
}
firstRefresh = false;
} else if (type.equals("feed")) {
storiesService.getFeedStories(new ServiceCallback<List<FeedStoryModel>>() {

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

@ -264,7 +264,9 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
postViewV2Fragment.dismiss();
binding.postsRecyclerView.refresh();
});
postViewV2Fragment.show(getChildFragmentManager(), "post_view");
final FragmentManager fragmentManager = getChildFragmentManager();
if (fragmentManager.isDestroyed() || fragmentManager.isStateSaved()) return;
postViewV2Fragment.show(fragmentManager, "post_view");
}
};
private final FeedAdapterV2.SelectionModeCallback selectionModeCallback = new FeedAdapterV2.SelectionModeCallback() {

Loading…
Cancel
Save