From 622363c2c67cc11ebf31dd2b5a0431632d4c8b1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pablo=20Rodr=C3=ADguez=20Caballero?= Date: Sun, 21 Mar 2021 20:38:34 +0100 Subject: [PATCH] fix(StoryViewerFragment): wrong viewModel superclass assigned on init --- .../fragments/StoryViewerFragment.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 4b2108a8..bfdeaaf3 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -304,11 +304,18 @@ public class StoryViewerFragment extends Fragment { // isNotification = fragmentArgs.getIsNotification(); final Type type = options.getType(); if (currentFeedStoryIndex >= 0) { - viewModel = type == Type.HIGHLIGHT - ? type == Type.STORY_ARCHIVE - ? new ViewModelProvider(fragmentActivity).get(ArchivesViewModel.class) - : new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class) - : new ViewModelProvider(fragmentActivity).get(FeedStoriesViewModel.class); + switch (type) { + case HIGHLIGHT: + viewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class); + break; + case STORY_ARCHIVE: + viewModel = new ViewModelProvider(fragmentActivity).get(ArchivesViewModel.class); + break; + default: + case FEED_STORY_POSITION: + viewModel = new ViewModelProvider(fragmentActivity).get(FeedStoriesViewModel.class); + break; + } } setupStories(); }