1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-12-22 21:16:57 +00:00

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

This commit is contained in:
Ammar Githam 2021-05-03 16:52:08 +09:00
parent a6e9a34024
commit ac3f8b9bfd

View File

@ -192,7 +192,12 @@ public class PostsRecyclerView extends RecyclerView {
}
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 -> {
if (list.size() <= 0) return;
feedAdapter.submitList(list, () -> {