From b5e110170977cfbea3b971e6534ccf85691889a6 Mon Sep 17 00:00:00 2001 From: Austin Huang Date: Tue, 5 Jan 2021 18:42:00 -0500 Subject: [PATCH] #532 point 2 --- .../fragments/StoryViewerFragment.java | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java index 72d6ed0c..c19d584b 100644 --- a/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/StoryViewerFragment.java @@ -132,7 +132,7 @@ public class StoryViewerFragment extends Fragment { private MenuItem menuDm; private SimpleExoPlayer player; private boolean isHashtag, isLoc; - private String highlight; + private String highlight, actionBarTitle; private boolean fetching = false, sticking = false, shouldRefresh = true; private int currentFeedStoryIndex; private double sliderValue; @@ -239,6 +239,15 @@ public class StoryViewerFragment extends Fragment { releasePlayer(); } + @Override + public void onResume() { + super.onResume(); + final ActionBar actionBar = fragmentActivity.getSupportActionBar(); + if (actionBar != null) { + actionBar.setTitle(actionBarTitle); + } + } + @Override public void onDestroy() { releasePlayer(); @@ -681,6 +690,7 @@ public class StoryViewerFragment extends Fragment { if (isHighlight) { final ActionBar actionBar = fragmentActivity.getSupportActionBar(); if (actionBar != null) { + actionBarTitle = highlight; actionBar.setTitle(highlight); } } @@ -688,6 +698,7 @@ public class StoryViewerFragment extends Fragment { currentStoryUsername = currentStoryUsername.replace("@", ""); final ActionBar actionBar = fragmentActivity.getSupportActionBar(); if (actionBar != null) { + actionBarTitle = currentStoryUsername; actionBar.setTitle(currentStoryUsername); } } @@ -729,21 +740,14 @@ public class StoryViewerFragment extends Fragment { return; } binding.storiesList.setVisibility((storyModels.size() == 1 && currentFeedStoryIndex == -1) ? View.GONE : View.VISIBLE); - binding.btnBackward.setVisibility(currentFeedStoryIndex == -1 ? View.GONE : View.VISIBLE); - binding.btnForward.setVisibility(currentFeedStoryIndex == -1 ? View.GONE : View.VISIBLE); + if (currentFeedStoryIndex == -1) { + binding.btnBackward.setVisibility(View.GONE); + binding.btnForward.setVisibility(View.GONE); + } storiesViewModel.getList().setValue(storyModels); currentStory = storyModels.get(0); refreshStory(); } - binding.storiesList.setVisibility((storyModels.size() == 1 && currentFeedStoryIndex == -1) ? View.GONE : View.VISIBLE); - if (currentFeedStoryIndex == -1) { - binding.btnBackward.setVisibility(View.GONE); - binding.btnForward.setVisibility(View.GONE); - } - storiesViewModel.getList().setValue(storyModels); - currentStory = storyModels.get(0); - refreshStory(); - } @Override public void onFailure(final Throwable t) { @@ -823,6 +827,7 @@ public class StoryViewerFragment extends Fragment { if (isHashtag || isLoc) { final ActionBar actionBar = fragmentActivity.getSupportActionBar(); if (actionBar != null) { + actionBarTitle = currentStory.getUsername(); actionBar.setTitle(currentStory.getUsername()); } }