mirror of
https://github.com/KokaKiwi/BarInsta
synced 2026-03-05 20:11:36 +00:00
Nested navigation using global actions
Using a workaround for including global actions. This may change in the future releases of Navigation lib
This commit is contained in:
parent
649115a665
commit
8f1a158b92
8 changed files with 159 additions and 98 deletions
|
|
@ -289,7 +289,7 @@ public class HashTagFragment extends Fragment {
|
|||
private void setTitle() {
|
||||
final ActionBar actionBar = fragmentActivity.getSupportActionBar();
|
||||
if (actionBar != null) {
|
||||
actionBar.setTitle(hashtag.substring(1));
|
||||
actionBar.setTitle(hashtag);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -434,7 +434,7 @@ public class DirectMessageThreadFragment extends Fragment {
|
|||
|
||||
private void searchUsername(final String text) {
|
||||
// startActivity(new Intent(requireContext(), ProfileViewer.class).putExtra(Constants.EXTRAS_USERNAME, text));
|
||||
final NavDirections action = DirectMessageThreadFragmentDirections.actionDirectMessagesThreadFragmentToProfileFragment("@" + text);
|
||||
final NavDirections action = DirectMessageThreadFragmentDirections.actionGlobalProfileFragment("@" + text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -152,55 +152,9 @@ public class FeedFragment extends Fragment {
|
|||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
storiesService = StoriesService.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
if (root != null) {
|
||||
shouldRefresh = false;
|
||||
return root;
|
||||
}
|
||||
binding = FragmentFeedBinding.inflate(inflater, container, false);
|
||||
root = binding.getRoot();
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||
if (!shouldRefresh) return;
|
||||
// setupActionBar();
|
||||
setupFeedStories();
|
||||
setupFeed();
|
||||
shouldRefresh = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (videoAwareRecyclerScroller != null) {
|
||||
videoAwareRecyclerScroller.stopPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (videoAwareRecyclerScroller != null && SHOULD_AUTO_PLAY) {
|
||||
videoAwareRecyclerScroller.startPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> {
|
||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> {
|
||||
if (isHashtag) {
|
||||
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToHashTagFragment(text);
|
||||
final NavDirections action = FeedFragmentDirections.actionGlobalHashTagFragment(text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
return;
|
||||
}
|
||||
|
|
@ -209,10 +163,9 @@ public class FeedFragment extends Fragment {
|
|||
NavHostFragment.findNavController(this).navigate(action);
|
||||
return;
|
||||
}
|
||||
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToProfileFragment("@" + text);
|
||||
final NavDirections action = FeedFragmentDirections.actionGlobalProfileFragment("@" + text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
};
|
||||
|
||||
private final View.OnClickListener postViewClickListener = v -> {
|
||||
final Object tag = v.getTag();
|
||||
if (!(tag instanceof FeedModel)) return;
|
||||
|
|
@ -293,6 +246,51 @@ public class FeedFragment extends Fragment {
|
|||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
fragmentActivity = (MainActivity) requireActivity();
|
||||
storiesService = StoriesService.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater,
|
||||
final ViewGroup container,
|
||||
final Bundle savedInstanceState) {
|
||||
if (root != null) {
|
||||
shouldRefresh = false;
|
||||
return root;
|
||||
}
|
||||
binding = FragmentFeedBinding.inflate(inflater, container, false);
|
||||
root = binding.getRoot();
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull final View view, @Nullable final Bundle savedInstanceState) {
|
||||
if (!shouldRefresh) return;
|
||||
// setupActionBar();
|
||||
setupFeedStories();
|
||||
setupFeed();
|
||||
shouldRefresh = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
if (videoAwareRecyclerScroller != null) {
|
||||
videoAwareRecyclerScroller.stopPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (videoAwareRecyclerScroller != null && SHOULD_AUTO_PLAY) {
|
||||
videoAwareRecyclerScroller.startPlaying();
|
||||
}
|
||||
}
|
||||
|
||||
private void setupFeed() {
|
||||
feedViewModel = new ViewModelProvider(fragmentActivity).get(FeedViewModel.class);
|
||||
final LinearLayoutManager layoutManager = new LinearLayoutManager(requireContext());
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ import androidx.core.content.ContextCompat;
|
|||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.navigation.NavDirections;
|
||||
import androidx.navigation.fragment.NavHostFragment;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
|
@ -54,6 +56,7 @@ import awais.instagrabber.customviews.helpers.RecyclerLazyLoader;
|
|||
import awais.instagrabber.databinding.FragmentProfileBinding;
|
||||
import awais.instagrabber.fragments.main.viewmodels.PostsViewModel;
|
||||
import awais.instagrabber.interfaces.FetchListener;
|
||||
import awais.instagrabber.interfaces.MentionClickListener;
|
||||
import awais.instagrabber.models.PostModel;
|
||||
import awais.instagrabber.models.ProfileModel;
|
||||
import awais.instagrabber.models.StoryModel;
|
||||
|
|
@ -109,9 +112,7 @@ public class ProfileFragment extends Fragment {
|
|||
remove();
|
||||
}
|
||||
};
|
||||
private final PrimaryActionModeCallback multiSelectAction = new PrimaryActionModeCallback(
|
||||
R.menu.multi_select_download_menu,
|
||||
new CallbacksHelper() {
|
||||
private final PrimaryActionModeCallback multiSelectAction = new PrimaryActionModeCallback(R.menu.multi_select_download_menu, new CallbacksHelper() {
|
||||
@Override
|
||||
public void onDestroy(final ActionMode mode) {
|
||||
onBackPressedCallback.handleOnBackPressed();
|
||||
|
|
@ -159,6 +160,21 @@ public class ProfileFragment extends Fragment {
|
|||
binding.privatePage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
};
|
||||
private final MentionClickListener mentionClickListener = (view, text, isHashtag, isLocation) -> {
|
||||
Log.d(TAG, "action...");
|
||||
if (isHashtag) {
|
||||
final NavDirections action = ProfileFragmentDirections.actionGlobalHashTagFragment(text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
return;
|
||||
}
|
||||
if (isLocation) {
|
||||
final NavDirections action = FeedFragmentDirections.actionFeedFragmentToLocationFragment(text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
return;
|
||||
}
|
||||
final NavDirections action = ProfileFragmentDirections.actionGlobalProfileFragment("@" + text);
|
||||
NavHostFragment.findNavController(this).navigate(action);
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable final Bundle savedInstanceState) {
|
||||
|
|
@ -409,7 +425,7 @@ public class ProfileFragment extends Fragment {
|
|||
if (Utils.hasMentions(biography)) {
|
||||
biography = Utils.getMentionText(biography);
|
||||
binding.mainBiography.setText(biography, TextView.BufferType.SPANNABLE);
|
||||
// binding.mainBiography.setMentionClickListener(mentionClickListener);
|
||||
binding.mainBiography.setMentionClickListener(mentionClickListener);
|
||||
} else {
|
||||
binding.mainBiography.setText(biography);
|
||||
binding.mainBiography.setMentionClickListener(null);
|
||||
|
|
@ -596,7 +612,6 @@ public class ProfileFragment extends Fragment {
|
|||
.putExtra(Constants.EXTRAS_INDEX, "%" + profileModel.getId())
|
||||
.putExtra(Constants.EXTRAS_USER, "@" + profileModel.getUsername())
|
||||
));
|
||||
// binding.btnFollowTag.setOnClickListener(profileActionListener);
|
||||
}
|
||||
|
||||
private void setUsernameDelayed() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue