This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bundle args = launchingFragment.getArguments(); | |
if (args == null) { | |
args = new Bundle(); | |
} | |
if (mMyObject != null) { | |
args.putSerializable(Constants.Args.MY_OBJECT, mMyObject); | |
} | |
Fragment myNiceFragment = MyNiceFragment.instantiate(mContext, MyNiceFragment.class.getName(), args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface OnBackPressed { | |
void onBackPressed(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class BaseFragment extends Fragment implements OnBackPressed { | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
} | |
@Override | |
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { | |
return super.onCreateView(inflater, container, savedInstanceState); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onBackPressed() { | |
tellFragments(); | |
super.onBackPressed(); | |
} | |
private void tellFragments(){ | |
List<Fragment> fragments = getSupportFragmentManager().getFragments(); | |
for(Fragment f : fragments){ | |
if(f != null && f instanceof BaseFragment) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onBackPressed(){ | |
getActivity().getSupportFragmentManager().popBackStack(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
primaryViewModel.selection.observe(viewLifecycleOwner) { | |
val directions = | |
DetailNavGraphDirections.openDetail(args.tabNumber, "Selection observed: $it") | |
detailNavHostFragment.navController.navigate(directions) | |
binding.root.open() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
binding.slidingPaneLayout.lockMode = SlidingPaneLayout.LOCK_MODE_LOCKED |
OlderNewer