From 404747fedccbb0ee4764b756d65979662a6cf395 Mon Sep 17 00:00:00 2001 From: Ammar Githam Date: Fri, 8 Jan 2021 21:50:58 +0900 Subject: [PATCH] Add merged changes missed by Gitkraken --- .../fragments/main/FeedFragment.java | 7 ++- .../fragments/main/ProfileFragment.java | 59 +++++++++---------- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java index 2ad2d831..197e4a46 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/FeedFragment.java @@ -46,6 +46,7 @@ import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment; import awais.instagrabber.fragments.PostViewV2Fragment; import awais.instagrabber.models.FeedStoryModel; import awais.instagrabber.models.PostsLayoutPreferences; +import awais.instagrabber.repositories.requests.StoryViewerOptions; import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.DownloadUtils; @@ -56,7 +57,6 @@ import awais.instagrabber.webservices.StoriesService; import static androidx.core.content.PermissionChecker.checkSelfPermission; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; -import static awais.instagrabber.utils.Utils.settingsHelper; public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { private static final String TAG = "FeedFragment"; @@ -82,7 +82,8 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre new FeedStoriesAdapter.OnFeedStoryClickListener() { @Override public void onFeedStoryClick(FeedStoryModel model, int position) { - final NavDirections action = FeedFragmentDirections.actionFeedFragmentToStoryViewerFragment(position, null, false, false, null, null, false, false); + final NavDirections action = FeedFragmentDirections + .actionFeedFragmentToStoryViewerFragment(StoryViewerOptions.forFeedStoryPosition(position)); NavHostFragment.findNavController(FeedFragment.this).navigate(action); } @@ -382,7 +383,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre } private void fetchStories() { - final String cookie = settingsHelper.getString(Constants.COOKIE); + // final String cookie = settingsHelper.getString(Constants.COOKIE); storiesFetching = true; updateSwipeRefreshState(); storiesService.getFeedStories(new ServiceCallback>() { diff --git a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java index 4dff529a..0f2413e3 100644 --- a/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java +++ b/app/src/main/java/awais/instagrabber/fragments/main/ProfileFragment.java @@ -59,7 +59,6 @@ import awais.instagrabber.adapters.HighlightsAdapter; import awais.instagrabber.asyncs.ProfileFetcher; import awais.instagrabber.asyncs.ProfilePostFetchService; import awais.instagrabber.asyncs.UsernameFetcher; -import awais.instagrabber.asyncs.direct_messages.CreateThreadAction; import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback.CallbacksHelper; import awais.instagrabber.databinding.FragmentProfileBinding; @@ -80,6 +79,7 @@ import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.PostItemType; +import awais.instagrabber.repositories.requests.StoryViewerOptions; import awais.instagrabber.repositories.responses.FriendshipChangeResponse; import awais.instagrabber.repositories.responses.FriendshipRestrictResponse; import awais.instagrabber.repositories.responses.FriendshipStatus; @@ -865,25 +865,22 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe } private void fetchStoryAndHighlights(final long profileId) { - storiesService.getUserStory(String.valueOf(profileId), - profileModel.getUsername(), - false, - false, - false, - new ServiceCallback>() { - @Override - public void onSuccess(final List storyModels) { - if (storyModels != null && !storyModels.isEmpty()) { - profileDetailsBinding.mainProfileImage.setStoriesBorder(1); - hasStories = true; - } - } + storiesService.getUserStory( + StoryViewerOptions.forUser(profileId, profileModel.getFullName()), + new ServiceCallback>() { + @Override + public void onSuccess(final List storyModels) { + if (storyModels != null && !storyModels.isEmpty()) { + profileDetailsBinding.mainProfileImage.setStoriesBorder(1); + hasStories = true; + } + } - @Override - public void onFailure(final Throwable t) { - Log.e(TAG, "Error", t); - } - }); + @Override + public void onFailure(final Throwable t) { + Log.e(TAG, "Error", t); + } + }); storiesService.fetchHighlights(profileId, new ServiceCallback>() { @Override @@ -986,14 +983,14 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe }); profileDetailsBinding.btnDM.setOnClickListener(v -> { profileDetailsBinding.btnDM.setEnabled(false); - new CreateThreadAction(cookie, profileModel.getPk(), threadId -> { - if (isAdded()) { - final NavDirections action = ProfileFragmentDirections - .actionProfileFragmentToDMThreadFragment(threadId, profileModel.getUsername()); - NavHostFragment.findNavController(this).navigate(action); - } - profileDetailsBinding.btnDM.setEnabled(true); - }).execute(); + // new CreateThreadAction(cookie, profileModel.getPk(), threadId -> { + // if (isAdded()) { + // final NavDirections action = ProfileFragmentDirections + // .actionProfileFragmentToDMThreadFragment(threadId, profileModel.getUsername()); + // NavHostFragment.findNavController(this).navigate(action); + // } + // profileDetailsBinding.btnDM.setEnabled(true); + // }).execute(); }); profileDetailsBinding.mainProfileImage.setOnClickListener(v -> { if (!hasStories) { @@ -1011,7 +1008,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe if (which == 1) { // show stories final NavDirections action = ProfileFragmentDirections - .actionProfileFragmentToStoryViewerFragment(-1, null, false, false, profileModel.getPk(), username, false, false); + .actionProfileFragmentToStoryViewerFragment(StoryViewerOptions.forUser(profileModel.getPk(), + profileModel.getFullName())); NavHostFragment.findNavController(this).navigate(action); return; } @@ -1071,8 +1069,9 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe private void setupHighlights() { highlightsViewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class); highlightsAdapter = new HighlightsAdapter((model, position) -> { - final NavDirections action = ProfileFragmentDirections - .actionProfileFragmentToStoryViewerFragment(position, model.getTitle(), false, false, 0, null, false, false); + final StoryViewerOptions options = StoryViewerOptions.forHighlight(model.getTitle()); + options.setCurrentFeedStoryIndex(position); + final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToStoryViewerFragment(options); NavHostFragment.findNavController(this).navigate(action); }); final Context context = getContext();