Home | History | Annotate | Download | only in navigation
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 /**
     18  * Navigation is a framework for navigating between 'destinations' within an Android
     19  * application that provides a consistent API whether destinations are implemented as
     20  * {@link android.support.v4.app.Fragment Fragments}, {@link android.app.Activity Activities}, or
     21  * other components.
     22  * <p>
     23  * There are 3 major components in Navigation.
     24  * <ul>
     25  *     <li>{@link androidx.navigation.NavGraph}: A navigation graph encapsulates a set
     26  *     of {@link androidx.navigation.NavDestination destinations}. It can be created by
     27  *     inflating a navigation XML file, by constructing it programmatically,
     28  *     or a combination of the two.
     29  *     </li>
     30  *     <li>{@link androidx.navigation.NavController}: This is the main entry
     31  *     point for interacting with the Navigation Graph, translating calls to
     32  *     {@link androidx.navigation.NavController#navigate(int)},
     33  *     {@link androidx.navigation.NavController#popBackStack()}, and
     34  *     {@link androidx.navigation.NavController#navigateUp()} into the appropriate operations.
     35  *     </li>
     36  *     <li>{@link androidx.navigation.NavHost}: The container that hosts a
     37  *     {@link androidx.navigation.NavController} and provides support for one or more specific
     38  *     types of {@link androidx.navigation.NavDestination destinations}. For example,
     39  *     {@link androidx.navigation.fragment.NavHostFragment} allows you to use
     40  *     {@link androidx.navigation.fragment.FragmentNavigator.Destination fragment destinations}.
     41  *     </li>
     42  * </ul>
     43  * Below is an example of working with a NavController.
     44  * <pre class="prettyprint">
     45  * // File: HomeFragment.java
     46  * public void onViewCreated(View view, {@literal @}Nullable Bundle savedInstanceState) {
     47  *   // For example purposes, assume our layout created in onCreateView has a Button
     48  *   // that should navigate the user to a destination
     49  *   Button b = view.findViewById(R.id.view_details);
     50  *
     51  *   b.setOnClickListener(v -> {
     52  *       // Retrieve the NavController from any View within a NavHost
     53  *       NavController navController = Navigation.findNavController(v);
     54  *       navController.navigate(R.id.details));
     55  *   }
     56  *
     57  *   // Or use the convenience method in Navigation to combine the previous steps
     58  *   b.setOnClickListener(Navigation.createNavigateOnClickListener(R.id.details));
     59  * }
     60  * </pre>
     61  * <p>
     62  * Please see the documentation of individual classes for details.
     63  */
     64 package androidx.navigation;
     65