{"id":317116,"date":"2021-01-28T15:02:44","date_gmt":"2021-01-28T15:02:44","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=317116"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=317116","title":{"rendered":"\u041b\u0438\u043a\u0431\u0435\u0437 \u043f\u043e Navigation Component: \u0442\u0435\u043c, \u043a\u0442\u043e \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u043b \u0432\u0441\u0435 \u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u0440\u043e Navigation Component. \u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442.<\/p>\n<p>\u0412\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u0440\u043e Navigation Component \u0432 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0430\u0437\u0430\u043c\u0438, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043a \u0447\u0430\u0441\u0442\u044f\u043c:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/539688\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043b\u0430\u0433\u0438\u043d Safe Args \u0438 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442<\/a>.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/538592\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Navigation Component \u0432 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 SafeArgs<\/a>.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/539684\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f iOS-like multistack-\u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<p>TL;DR.:<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Navigation Component, \u043d\u0430\u0434\u043e:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0433\u0440\u0430\u0444;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u044b, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0435\u0441\u0447\u0438\u043d\u0441\u0442\u0432\u043e \u0432 NavHost;<\/p>\n<\/li>\n<li>\n<p>\u0423\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<\/li>\n<\/ol>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/h4>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/a5d\/c37\/376\/a5dc373766f14be1ea807f6574d63b0a\" width=\"549\" height=\"537\"><figcaption><\/figcaption><\/figure>\n<p>1. Navigation Graph\u200a\u2014\u200a\u043e\u0441\u043d\u043e\u0432\u043e\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0430\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. \u042d\u0442\u043e \u0433\u0440\u0430\u0444, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u044b\u200a\u2014\u200a\u044d\u043a\u0440\u0430\u043d\u044b, \u0430 \u0440\u0435\u0431\u0440\u0430\u200a\u2014\u200a\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0413\u0440\u0430\u0444 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c xml-\u0444\u0430\u0439\u043b\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 res\/navigation. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c navController \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u0433\u0440\u0430\u0444\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 (startDestination)<\/p>\n<p>2. Destination \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 UI-\u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043d\u0430 \u0433\u0440\u0430\u0444\u0435 (Fragment\/Activity\/Dialog\/NestedGraph).<\/p>\n<p>3. Action \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 destination-\u0430\u043c\u0438 \u0433\u0440\u0430\u0444\u0430. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c (\u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443), \u0442\u0430\u043a \u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c (\u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434).<\/p>\n<p>4. Nested Graph\u200a\u2014\u200a\u044d\u0442\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444. \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u043b\u043e \u0438\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0433\u0440\u0430\u0444 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 &lt;include&gt;.<\/p>\n<p>5. NavHost\u200a\u2014\u200a\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f. \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443, \u0447\u0442\u043e \u043e\u043d \u0438\u043c\u0435\u043d\u043d\u043e NavHostFragment, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0433\u0440\u0430\u0444 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>&lt;androidx.fragment.app.FragmentContainerView     android:id=\"@+id\/navHost\"     android:name=\"androidx.navigation.fragment.NavHostFragment\"     android:layout_width=\"match_parent\"     android:layout_height=\"match_parent\"     app:defaultNavHost=\"true\"     app:navGraph=\"@navigation\/nav_main\" \/&gt;<\/code><\/pre>\n<p><em>6. NavController\u200a\u2014\u200a\u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e. \u041e\u043d \u0435\u0449\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 \u043f\u0440\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 NavController\u200a\u2014\u200a\u044d\u0442\u043e \u0440\u043e\u0443\u0442\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, shared-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u0440.<\/em><\/p>\n<h4>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443&nbsp;\u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438<\/h4>\n<p><em>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Action \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 DeepLink.<\/em><\/p>\n<p><em>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e&nbsp;Action<\/em><\/p>\n<p><em>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/em><\/p>\n<pre><code>&lt;action     android:id=\u201d@+id\/action_to_user_details\u201d     app:destination=\u201d@id\/userDetailsFragment\u201d     app:enterAnim=\u201d@anim\/add_fragment_animation\u201d     app:exitAnim=\u201d@anim\/pop_fragment_animation\u201d     app:popEnterAnim=\u201d@anim\/pop_enter_animation\u201d     app:popExitAnim=\u201d@anim\/pop_exit_animation\u201d&gt;<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430:<\/p>\n<pre><code>navController.navigate(     R.id.action_to_user_details,     Bundle().apply {putString(USER_ID, userId)} )<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u00ab\u0442\u043e\u043c \u043a\u043e\u043d\u0446\u0435\u00bb:<\/p>\n<pre><code>private val userID by lazy {     arguments!![USER_ID] }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e deep&nbsp;link<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code>&lt;deepLink      app:uri=\u201dapp:\/\/customUri?parameter={parameterName}\u201d \/&gt;<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430:<\/p>\n<pre><code>navController.navigate(     Uri.parse(\u201capp:\/\/customUri?parameter=$reason\u201d) )<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u00ab\u0442\u043e\u043c \u043a\u043e\u043d\u0446\u0435\u00bb:<\/p>\n<pre><code>private val refundId by lazy {     arguments?.getString(\u201cparameter\u201d, null) }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451! \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u200a\u2014\u200a\u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438\u043c \u0438 \u043f\u043e\u0434\u043a\u0443\u043f\u0430\u0435\u0442 Navigation Component. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0442\u043e, <a href=\"https:\/\/habr.com\/ru\/post\/539688\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043b\u0430\u0433\u0438\u043d Safe Args \u0438 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442<\/a> \u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u0443\u0436\u0435 \u043a <a href=\"https:\/\/habr.com\/ru\/post\/538592\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Navigation Component \u0432 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 SafeArgs<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/539684\/\" rel=\"noopener noreferrer nofollow\">iOS-like multistack-\u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/539692\/\"> https:\/\/habr.com\/ru\/post\/539692\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>\u042d\u0442\u0430 \u0438\u0441\u0442\u043e\u0440\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0434\u043e \u0441\u0438\u0445 \u043f\u043e\u0440 \u043d\u0435 \u0432 \u043a\u0443\u0440\u0441\u0435 \u043f\u0440\u043e Navigation Component. \u0422\u0443\u0442 \u043c\u044b \u043f\u0440\u043e\u0431\u0435\u0436\u0438\u043c\u0441\u044f \u043f\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u043c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442.<\/p>\n<p>\u0412\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u0432 \u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438 \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u043c\u0430\u0442\u0435\u0440\u0438\u0430\u043b\u0430 \u043f\u0440\u043e Navigation Component \u0432 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b \u0441 \u0430\u0437\u0430\u043c\u0438, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u0438\u0434\u0442\u0438 \u0434\u0430\u043b\u044c\u0448\u0435 \u043a \u0447\u0430\u0441\u0442\u044f\u043c:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/539688\/\" rel=\"noopener noreferrer nofollow\">\u041a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043b\u0430\u0433\u0438\u043d Safe Args \u0438 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442<\/a>.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/538592\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 Navigation Component \u0432 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 SafeArgs<\/a>.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/539684\/\" rel=\"noopener noreferrer nofollow\">\u0420\u0435\u0448\u0435\u043d\u0438\u0435 \u0434\u043b\u044f iOS-like multistack-\u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<\/ul>\n<p>TL;DR.:<\/p>\n<p>\u0427\u0442\u043e\u0431\u044b \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Navigation Component, \u043d\u0430\u0434\u043e:<\/p>\n<ol>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0442\u044c \u0433\u0440\u0430\u0444;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u043d\u0435\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u044b;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438;<\/p>\n<\/li>\n<li>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0435 \u0433\u0440\u0430\u0444\u044b, \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e;<\/p>\n<\/li>\n<li>\n<p>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0432\u0441\u0435 \u044d\u0442\u043e \u0431\u0435\u0441\u0447\u0438\u043d\u0441\u0442\u0432\u043e \u0432 NavHost;<\/p>\n<\/li>\n<li>\n<p>\u0423\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<\/li>\n<\/ol>\n<h4>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/h4>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>1. Navigation Graph\u200a\u2014\u200a\u043e\u0441\u043d\u043e\u0432\u043e\u043f\u043e\u043b\u0430\u0433\u0430\u044e\u0449\u0430\u044f \u0435\u0434\u0438\u043d\u0438\u0446\u0430 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. \u042d\u0442\u043e \u0433\u0440\u0430\u0444, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0432\u0435\u0440\u0448\u0438\u043d\u044b\u200a\u2014\u200a\u044d\u043a\u0440\u0430\u043d\u044b, \u0430 \u0440\u0435\u0431\u0440\u0430\u200a\u2014\u200a\u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438. \u0413\u0440\u0430\u0444 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c xml-\u0444\u0430\u0439\u043b\u0435 \u0432 \u043f\u0430\u043f\u043a\u0435 res\/navigation. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442\u044c navController \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u0433\u0440\u0430\u0444\u0435 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0435\u0433\u043e \u0441\u0442\u0430\u0440\u0442\u043e\u0432\u0443\u044e \u0442\u043e\u0447\u043a\u0443 (startDestination)<\/p>\n<p>2. Destination \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 UI-\u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u043d\u0430 \u0433\u0440\u0430\u0444\u0435 (Fragment\/Activity\/Dialog\/NestedGraph).<\/p>\n<p>3. Action \u043e\u0431\u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 destination-\u0430\u043c\u0438 \u0433\u0440\u0430\u0444\u0430. \u041c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u043c (\u043e\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u044d\u043a\u0440\u0430\u043d\u0430 \u043a \u0434\u0440\u0443\u0433\u043e\u043c\u0443), \u0442\u0430\u043a \u0438 \u0433\u043b\u043e\u0431\u0430\u043b\u044c\u043d\u044b\u043c (\u043d\u0435 \u0438\u043c\u0435\u0442\u044c \u0432\u0435\u0440\u0448\u0438\u043d\u044b, \u043e\u0442 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0445\u043e\u0434).<\/p>\n<p>4. Nested Graph\u200a\u2014\u200a\u044d\u0442\u043e \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0433\u0440\u0430\u0444. \u0415\u0441\u043b\u0438 \u043e\u0434\u043d\u043e\u0433\u043e \u0433\u0440\u0430\u0444\u0430 \u0431\u0443\u0434\u0435\u0442 \u043c\u0430\u043b\u043e \u0438\u043b\u0438 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0439, \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u0431\u0438\u0442\u044c \u0438\u0445 \u043d\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0433\u0440\u0430\u0444 \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0435\u0433\u0430 &lt;include&gt;.<\/p>\n<p>5. NavHost\u200a\u2014\u200a\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044f. \u0414\u043b\u044f \u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b \u043d\u0430\u0434\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0443, \u0447\u0442\u043e \u043e\u043d \u0438\u043c\u0435\u043d\u043d\u043e NavHostFragment, \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0442\u044c \u0433\u0440\u0430\u0444 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438. \u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u044d\u0442\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>&lt;androidx.fragment.app.FragmentContainerView     android:id=\"@+id\/navHost\"     android:name=\"androidx.navigation.fragment.NavHostFragment\"     android:layout_width=\"match_parent\"     android:layout_height=\"match_parent\"     app:defaultNavHost=\"true\"     app:navGraph=\"@navigation\/nav_main\" \/&gt;<\/code><\/pre>\n<p><em>6. NavController\u200a\u2014\u200a\u043e\u0431\u044a\u0435\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0437\u0430 \u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u044e. \u041e\u043d \u0435\u0449\u0435 \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0434\u0430\u043b\u044c\u0448\u0435 \u0432 \u043f\u0443\u043d\u043a\u0442\u0435 \u043f\u0440\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u044b. \u041f\u043e \u0444\u0430\u043a\u0442\u0443 NavController\u200a\u2014\u200a\u044d\u0442\u043e \u0440\u043e\u0443\u0442\u0435\u0440, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u043e\u043f\u0446\u0438\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430, \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u0438, shared-\u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438 \u043f\u0440.<\/em><\/p>\n<h4>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443&nbsp;\u044d\u043a\u0440\u0430\u043d\u0430\u043c\u0438<\/h4>\n<p><em>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u044b \u043c\u0435\u0436\u0434\u0443 \u044d\u043a\u0440\u0430\u043d\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0447\u0435\u0440\u0435\u0437 Action \u0438\u043b\u0438 \u0447\u0435\u0440\u0435\u0437 DeepLink.<\/em><\/p>\n<p><em>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e&nbsp;Action<\/em><\/p>\n<p><em>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/em><\/p>\n<pre><code>&lt;action     android:id=\u201d@+id\/action_to_user_details\u201d     app:destination=\u201d@id\/userDetailsFragment\u201d     app:enterAnim=\u201d@anim\/add_fragment_animation\u201d     app:exitAnim=\u201d@anim\/pop_fragment_animation\u201d     app:popEnterAnim=\u201d@anim\/pop_enter_animation\u201d     app:popExitAnim=\u201d@anim\/pop_exit_animation\u201d&gt;<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430:<\/p>\n<pre><code>navController.navigate(     R.id.action_to_user_details,     Bundle().apply {putString(USER_ID, userId)} )<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u00ab\u0442\u043e\u043c \u043a\u043e\u043d\u0446\u0435\u00bb:<\/p>\n<pre><code>private val userID by lazy {     arguments!![USER_ID] }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e deep&nbsp;link<\/p>\n<p>\u041a\u0430\u043a \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442:<\/p>\n<pre><code>&lt;deepLink      app:uri=\u201dapp:\/\/customUri?parameter={parameterName}\u201d \/&gt;<\/code><\/pre>\n<p>\u0412\u044b\u0437\u043e\u0432 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0430:<\/p>\n<pre><code>navController.navigate(     Uri.parse(\u201capp:\/\/customUri?parameter=$reason\u201d) )<\/code><\/pre>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043d\u0430 \u00ab\u0442\u043e\u043c \u043a\u043e\u043d\u0446\u0435\u00bb:<\/p>\n<pre><code>private val refundId by lazy {     arguments?.getString(\u201cparameter\u201d, null) }<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451! \u0414\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u043e\u200a\u2014\u200a\u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u0438\u043c \u0438 \u043f\u043e\u0434\u043a\u0443\u043f\u0430\u0435\u0442 Navigation Component. \u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0443\u0433\u043b\u0443\u0431\u0438\u043c\u0441\u044f \u0432 \u0442\u043e, <a href=\"https:\/\/habr.com\/ru\/post\/539688\/\" rel=\"noopener noreferrer nofollow\">\u043a\u0430\u043a \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043b\u0430\u0433\u0438\u043d Safe Args \u0438 \u0447\u0442\u043e \u043e\u043d \u0434\u0435\u043b\u0430\u0435\u0442<\/a> \u0438 \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c \u0443\u0436\u0435 \u043a <a href=\"https:\/\/habr.com\/ru\/post\/538592\/\" rel=\"noopener noreferrer nofollow\">\u0440\u0430\u0431\u043e\u0442\u0435 \u0441 Navigation Component \u0432 \u043c\u043d\u043e\u0433\u043e\u043c\u043e\u0434\u0443\u043b\u044c\u043d\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 SafeArgs<\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/post\/539684\/\" rel=\"noopener noreferrer nofollow\">iOS-like multistack-\u043d\u0430\u0432\u0438\u0433\u0430\u0446\u0438\u0438<\/a>.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/539692\/\"> https:\/\/habr.com\/ru\/post\/539692\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-317116","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317116","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=317116"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/317116\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=317116"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=317116"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=317116"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}