1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-16 11:47:29 +00:00

Add merged changes missed by Gitkraken

This commit is contained in:
Ammar Githam 2021-01-08 21:50:58 +09:00
parent 039194d046
commit 404747fedc
2 changed files with 33 additions and 33 deletions

View File

@ -46,6 +46,7 @@ import awais.instagrabber.dialogs.PostsLayoutPreferencesDialogFragment;
import awais.instagrabber.fragments.PostViewV2Fragment; import awais.instagrabber.fragments.PostViewV2Fragment;
import awais.instagrabber.models.FeedStoryModel; import awais.instagrabber.models.FeedStoryModel;
import awais.instagrabber.models.PostsLayoutPreferences; import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.repositories.requests.StoryViewerOptions;
import awais.instagrabber.repositories.responses.Media; import awais.instagrabber.repositories.responses.Media;
import awais.instagrabber.utils.Constants; import awais.instagrabber.utils.Constants;
import awais.instagrabber.utils.DownloadUtils; import awais.instagrabber.utils.DownloadUtils;
@ -56,7 +57,6 @@ import awais.instagrabber.webservices.StoriesService;
import static androidx.core.content.PermissionChecker.checkSelfPermission; import static androidx.core.content.PermissionChecker.checkSelfPermission;
import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION; import static awais.instagrabber.utils.DownloadUtils.WRITE_PERMISSION;
import static awais.instagrabber.utils.Utils.settingsHelper;
public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener { public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefreshListener {
private static final String TAG = "FeedFragment"; private static final String TAG = "FeedFragment";
@ -82,7 +82,8 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
new FeedStoriesAdapter.OnFeedStoryClickListener() { new FeedStoriesAdapter.OnFeedStoryClickListener() {
@Override @Override
public void onFeedStoryClick(FeedStoryModel model, int position) { 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); NavHostFragment.findNavController(FeedFragment.this).navigate(action);
} }
@ -382,7 +383,7 @@ public class FeedFragment extends Fragment implements SwipeRefreshLayout.OnRefre
} }
private void fetchStories() { private void fetchStories() {
final String cookie = settingsHelper.getString(Constants.COOKIE); // final String cookie = settingsHelper.getString(Constants.COOKIE);
storiesFetching = true; storiesFetching = true;
updateSwipeRefreshState(); updateSwipeRefreshState();
storiesService.getFeedStories(new ServiceCallback<List<FeedStoryModel>>() { storiesService.getFeedStories(new ServiceCallback<List<FeedStoryModel>>() {

View File

@ -59,7 +59,6 @@ import awais.instagrabber.adapters.HighlightsAdapter;
import awais.instagrabber.asyncs.ProfileFetcher; import awais.instagrabber.asyncs.ProfileFetcher;
import awais.instagrabber.asyncs.ProfilePostFetchService; import awais.instagrabber.asyncs.ProfilePostFetchService;
import awais.instagrabber.asyncs.UsernameFetcher; import awais.instagrabber.asyncs.UsernameFetcher;
import awais.instagrabber.asyncs.direct_messages.CreateThreadAction;
import awais.instagrabber.customviews.PrimaryActionModeCallback; import awais.instagrabber.customviews.PrimaryActionModeCallback;
import awais.instagrabber.customviews.PrimaryActionModeCallback.CallbacksHelper; import awais.instagrabber.customviews.PrimaryActionModeCallback.CallbacksHelper;
import awais.instagrabber.databinding.FragmentProfileBinding; import awais.instagrabber.databinding.FragmentProfileBinding;
@ -80,6 +79,7 @@ import awais.instagrabber.models.PostsLayoutPreferences;
import awais.instagrabber.models.StoryModel; import awais.instagrabber.models.StoryModel;
import awais.instagrabber.models.enums.FavoriteType; import awais.instagrabber.models.enums.FavoriteType;
import awais.instagrabber.models.enums.PostItemType; import awais.instagrabber.models.enums.PostItemType;
import awais.instagrabber.repositories.requests.StoryViewerOptions;
import awais.instagrabber.repositories.responses.FriendshipChangeResponse; import awais.instagrabber.repositories.responses.FriendshipChangeResponse;
import awais.instagrabber.repositories.responses.FriendshipRestrictResponse; import awais.instagrabber.repositories.responses.FriendshipRestrictResponse;
import awais.instagrabber.repositories.responses.FriendshipStatus; import awais.instagrabber.repositories.responses.FriendshipStatus;
@ -865,25 +865,22 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
} }
private void fetchStoryAndHighlights(final long profileId) { private void fetchStoryAndHighlights(final long profileId) {
storiesService.getUserStory(String.valueOf(profileId), storiesService.getUserStory(
profileModel.getUsername(), StoryViewerOptions.forUser(profileId, profileModel.getFullName()),
false, new ServiceCallback<List<StoryModel>>() {
false, @Override
false, public void onSuccess(final List<StoryModel> storyModels) {
new ServiceCallback<List<StoryModel>>() { if (storyModels != null && !storyModels.isEmpty()) {
@Override profileDetailsBinding.mainProfileImage.setStoriesBorder(1);
public void onSuccess(final List<StoryModel> storyModels) { hasStories = true;
if (storyModels != null && !storyModels.isEmpty()) { }
profileDetailsBinding.mainProfileImage.setStoriesBorder(1); }
hasStories = true;
}
}
@Override @Override
public void onFailure(final Throwable t) { public void onFailure(final Throwable t) {
Log.e(TAG, "Error", t); Log.e(TAG, "Error", t);
} }
}); });
storiesService.fetchHighlights(profileId, storiesService.fetchHighlights(profileId,
new ServiceCallback<List<HighlightModel>>() { new ServiceCallback<List<HighlightModel>>() {
@Override @Override
@ -986,14 +983,14 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
}); });
profileDetailsBinding.btnDM.setOnClickListener(v -> { profileDetailsBinding.btnDM.setOnClickListener(v -> {
profileDetailsBinding.btnDM.setEnabled(false); profileDetailsBinding.btnDM.setEnabled(false);
new CreateThreadAction(cookie, profileModel.getPk(), threadId -> { // new CreateThreadAction(cookie, profileModel.getPk(), threadId -> {
if (isAdded()) { // if (isAdded()) {
final NavDirections action = ProfileFragmentDirections // final NavDirections action = ProfileFragmentDirections
.actionProfileFragmentToDMThreadFragment(threadId, profileModel.getUsername()); // .actionProfileFragmentToDMThreadFragment(threadId, profileModel.getUsername());
NavHostFragment.findNavController(this).navigate(action); // NavHostFragment.findNavController(this).navigate(action);
} // }
profileDetailsBinding.btnDM.setEnabled(true); // profileDetailsBinding.btnDM.setEnabled(true);
}).execute(); // }).execute();
}); });
profileDetailsBinding.mainProfileImage.setOnClickListener(v -> { profileDetailsBinding.mainProfileImage.setOnClickListener(v -> {
if (!hasStories) { if (!hasStories) {
@ -1011,7 +1008,8 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
if (which == 1) { if (which == 1) {
// show stories // show stories
final NavDirections action = ProfileFragmentDirections 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); NavHostFragment.findNavController(this).navigate(action);
return; return;
} }
@ -1071,8 +1069,9 @@ public class ProfileFragment extends Fragment implements SwipeRefreshLayout.OnRe
private void setupHighlights() { private void setupHighlights() {
highlightsViewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class); highlightsViewModel = new ViewModelProvider(fragmentActivity).get(HighlightsViewModel.class);
highlightsAdapter = new HighlightsAdapter((model, position) -> { highlightsAdapter = new HighlightsAdapter((model, position) -> {
final NavDirections action = ProfileFragmentDirections final StoryViewerOptions options = StoryViewerOptions.forHighlight(model.getTitle());
.actionProfileFragmentToStoryViewerFragment(position, model.getTitle(), false, false, 0, null, false, false); options.setCurrentFeedStoryIndex(position);
final NavDirections action = ProfileFragmentDirections.actionProfileFragmentToStoryViewerFragment(options);
NavHostFragment.findNavController(this).navigate(action); NavHostFragment.findNavController(this).navigate(action);
}); });
final Context context = getContext(); final Context context = getContext();