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
<?xml version="1.0" encoding="utf-8"?> | |
<androidx.slidingpanelayout.widget.SlidingPaneLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
android:id="@+id/sliding_pane_layout"> | |
<androidx.fragment.app.FragmentContainerView | |
android:id="@+id/primary_nav_host_fragment" | |
android:name="androidx.navigation.fragment.NavHostFragment" | |
android:layout_width="@dimen/list_width" |
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
class TwoPaneOnBackPressedCallback( | |
private val slidingPaneLayout: SlidingPaneLayout | |
) : OnBackPressedCallback( | |
// Set the default 'enabled' state to true only if it is slidable (i.e., the panes | |
// are overlapping) and open (i.e., the detail pane is visible). | |
slidingPaneLayout.isSlideable && slidingPaneLayout.isOpen | |
), SlidingPaneLayout.PanelSlideListener { | |
init { | |
slidingPaneLayout.addPanelSlideListener(this) |
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 |
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 |
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
@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
@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) |
NewerOlder