Browse Source

Wrapping ViewModelProvider constructor with try-catch to prevent crashes. Addresses austinhuang0131/barinsta#903.

renovate/org.robolectric-robolectric-4.x
Ammar Githam 4 years ago
parent
commit
ac3f8b9bfd
  1. 7
      app/src/main/java/awais/instagrabber/customviews/PostsRecyclerView.java

7
app/src/main/java/awais/instagrabber/customviews/PostsRecyclerView.java

@ -192,7 +192,12 @@ public class PostsRecyclerView extends RecyclerView {
} }
private void initSelf() { private void initSelf() {
mediaViewModel = new ViewModelProvider(viewModelStoreOwner).get(MediaViewModel.class);
try {
mediaViewModel = new ViewModelProvider(viewModelStoreOwner).get(MediaViewModel.class);
} catch (Exception e) {
Log.e(TAG, "initSelf: ", e);
}
if (mediaViewModel == null) return;
mediaViewModel.getList().observe(lifeCycleOwner, list -> { mediaViewModel.getList().observe(lifeCycleOwner, list -> {
if (list.size() <= 0) return; if (list.size() <= 0) return;
feedAdapter.submitList(list, () -> { feedAdapter.submitList(list, () -> {

Loading…
Cancel
Save