Browse Source

Null check. Fixes https://github.com/austinhuang0131/barinsta/issues/991

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
1c1e5f0654
  1. 12
      app/src/main/java/awais/instagrabber/fragments/StoryListViewerFragment.java

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

@ -24,6 +24,7 @@ import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import awais.instagrabber.R; import awais.instagrabber.R;
@ -98,8 +99,7 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
final Context context = getContext(); final Context context = getContext();
Toast.makeText(context, R.string.empty_list, Toast.LENGTH_SHORT).show(); Toast.makeText(context, R.string.empty_list, Toast.LENGTH_SHORT).show();
} catch (Exception ignored) {} } catch (Exception ignored) {}
}
else {
} else {
endCursor = result.getNextCursor(); endCursor = result.getNextCursor();
final List<HighlightModel> models = archivesViewModel.getList().getValue(); final List<HighlightModel> models = archivesViewModel.getList().getValue();
final List<HighlightModel> modelsCopy = models == null ? new ArrayList<>() : new ArrayList<>(models); final List<HighlightModel> modelsCopy = models == null ? new ArrayList<>() : new ArrayList<>(models);
@ -198,7 +198,13 @@ public final class StoryListViewerFragment extends Fragment implements SwipeRefr
adapter = new FeedStoriesListAdapter(clickListener); adapter = new FeedStoriesListAdapter(clickListener);
binding.rvStories.setLayoutManager(layoutManager); binding.rvStories.setLayoutManager(layoutManager);
binding.rvStories.setAdapter(adapter); binding.rvStories.setAdapter(adapter);
feedStoriesViewModel.getList().observe(getViewLifecycleOwner(), adapter::submitList);
feedStoriesViewModel.getList().observe(getViewLifecycleOwner(), list -> {
if (list == null) {
adapter.submitList(Collections.emptyList());
return;
}
adapter.submitList(list);
});
} else { } else {
if (actionBar != null) actionBar.setTitle(R.string.action_archive); if (actionBar != null) actionBar.setTitle(R.string.action_archive);
final RecyclerLazyLoader lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> { final RecyclerLazyLoader lazyLoader = new RecyclerLazyLoader(layoutManager, (page, totalItemsCount) -> {

Loading…
Cancel
Save