mirror of
https://github.com/KokaKiwi/BarInsta
synced 2024-11-08 07:57:28 +00:00
Check currentFeedStoryIndex every time before accessing models list. Fixes: https://github.com/austinhuang0131/barinsta/issues/819
This commit is contained in:
parent
863a06f3af
commit
1cd75356c7
@ -684,47 +684,45 @@ public class StoryViewerFragment extends Fragment {
|
|||||||
String currentStoryMediaId = null;
|
String currentStoryMediaId = null;
|
||||||
final Type type = options.getType();
|
final Type type = options.getType();
|
||||||
StoryViewerOptions fetchOptions = null;
|
StoryViewerOptions fetchOptions = null;
|
||||||
if (currentFeedStoryIndex >= 0) {
|
switch (type) {
|
||||||
switch (type) {
|
case HIGHLIGHT: {
|
||||||
case HIGHLIGHT: {
|
final HighlightsViewModel highlightsViewModel = (HighlightsViewModel) viewModel;
|
||||||
final HighlightsViewModel highlightsViewModel = (HighlightsViewModel) viewModel;
|
final List<HighlightModel> models = highlightsViewModel.getList().getValue();
|
||||||
final List<HighlightModel> models = highlightsViewModel.getList().getValue();
|
if (models == null || models.isEmpty() || currentFeedStoryIndex >= models.size() || currentFeedStoryIndex < 0) {
|
||||||
if (models == null || models.isEmpty() || currentFeedStoryIndex >= models.size()) {
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
final HighlightModel model = models.get(currentFeedStoryIndex);
|
|
||||||
currentStoryMediaId = model.getId();
|
|
||||||
fetchOptions = StoryViewerOptions.forHighlight(model.getId());
|
|
||||||
currentStoryUsername = model.getTitle();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case FEED_STORY_POSITION: {
|
final HighlightModel model = models.get(currentFeedStoryIndex);
|
||||||
final FeedStoriesViewModel feedStoriesViewModel = (FeedStoriesViewModel) viewModel;
|
currentStoryMediaId = model.getId();
|
||||||
final List<FeedStoryModel> models = feedStoriesViewModel.getList().getValue();
|
fetchOptions = StoryViewerOptions.forHighlight(model.getId());
|
||||||
if (models == null) return;
|
currentStoryUsername = model.getTitle();
|
||||||
final FeedStoryModel model = models.get(currentFeedStoryIndex);
|
break;
|
||||||
currentStoryMediaId = model.getStoryMediaId();
|
}
|
||||||
currentStoryUsername = model.getProfileModel().getUsername();
|
case FEED_STORY_POSITION: {
|
||||||
fetchOptions = StoryViewerOptions.forUser(Long.parseLong(currentStoryMediaId), currentStoryUsername);
|
final FeedStoriesViewModel feedStoriesViewModel = (FeedStoriesViewModel) viewModel;
|
||||||
if (model.isLive()) {
|
final List<FeedStoryModel> models = feedStoriesViewModel.getList().getValue();
|
||||||
live = model.getFirstStoryModel();
|
if (models == null || currentFeedStoryIndex >= models.size() || currentFeedStoryIndex < 0) return;
|
||||||
}
|
final FeedStoryModel model = models.get(currentFeedStoryIndex);
|
||||||
break;
|
currentStoryMediaId = model.getStoryMediaId();
|
||||||
|
currentStoryUsername = model.getProfileModel().getUsername();
|
||||||
|
fetchOptions = StoryViewerOptions.forUser(Long.parseLong(currentStoryMediaId), currentStoryUsername);
|
||||||
|
if (model.isLive()) {
|
||||||
|
live = model.getFirstStoryModel();
|
||||||
}
|
}
|
||||||
case STORY_ARCHIVE: {
|
break;
|
||||||
final ArchivesViewModel archivesViewModel = (ArchivesViewModel) viewModel;
|
}
|
||||||
final List<HighlightModel> models = archivesViewModel.getList().getValue();
|
case STORY_ARCHIVE: {
|
||||||
if (models == null || models.isEmpty() || currentFeedStoryIndex >= models.size()) {
|
final ArchivesViewModel archivesViewModel = (ArchivesViewModel) viewModel;
|
||||||
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
final List<HighlightModel> models = archivesViewModel.getList().getValue();
|
||||||
return;
|
if (models == null || models.isEmpty() || currentFeedStoryIndex >= models.size() || currentFeedStoryIndex < 0) {
|
||||||
}
|
Toast.makeText(context, R.string.downloader_unknown_error, Toast.LENGTH_SHORT).show();
|
||||||
final HighlightModel model = models.get(currentFeedStoryIndex);
|
return;
|
||||||
currentStoryMediaId = model.getId();
|
|
||||||
currentStoryUsername = model.getTitle();
|
|
||||||
fetchOptions = StoryViewerOptions.forUser(Long.parseLong(currentStoryMediaId), currentStoryUsername);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
final HighlightModel model = models.get(currentFeedStoryIndex);
|
||||||
|
currentStoryMediaId = model.getId();
|
||||||
|
currentStoryUsername = model.getTitle();
|
||||||
|
fetchOptions = StoryViewerOptions.forUser(Long.parseLong(currentStoryMediaId), currentStoryUsername);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (type == Type.USER) {
|
if (type == Type.USER) {
|
||||||
|
Loading…
Reference in New Issue
Block a user