/* Ċ Ġ* ĠCreate Ġby ĠJ acob ĠG ( Gu an De Li ang ) Ġon Ġ 2 0 2 0 . Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 0 Ġ. ĠAll Ġrights Ġreserved . Ċ Ġ* ĠLast Ġmodified Ġ 2 0 - 2 - 2 8 Ġä¸ĭåįĪ 1 0 : 0 4 Ċ Ġ* Ċ Ġ*/ Ċ package Ġcom . jacob . material . example . motion layout Ċ Ċ import Ġandroid . graphics . drawable . Animated Vector Drawable Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroidx . constraint layout . motion . widget . Motion Layout Ċ import Ġandroidx . databinding . Data Binding Util Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . lifecycle . Lifecycle Observer Ċ import Ġandroidx . navigation . Navigation Ċ import Ġcom . jacob . material . R Ċ import Ġcom . jacob . material . databinding .* Ċ import Ġkotlin . math . round ToInt Ċ Ċ class ĠMotion Layout Detail Fragment Ġ: ĠFragment (), ĠLifecycle Observer Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġbinding : ĠMotion Layout Detail Fragment Binding ĊĊĠĠĠ Ġprivate Ġvar Ġbegin Time : Long Ġ= Ġ 0 ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġthis . lifecycle . add Observer ( this ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġbinding Ġ= ĠData Binding Util . inflate ( in flater , ĠR . layout . motion _ layout _ detail _ fragment , Ġcontainer , Ġfalse ) ĊĊĠĠĠĠĠĠĠ Ġbinding . key Position Type Delta Relative Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle : Bundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Int ( Motion Layout Key Position Type Fragment . KEY _ POSITION _ TYPE , ĠMotion Layout Key Position Type Fragment . KEY _ POSITION _ TYPE _ DELTA ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( require Activity (), ĠR . id . fragment _ container _ view ). navigate ( R . id . show _ key _ position _ type , Ġbundle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . key Position Type Parent Relative Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle : Bundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Int ( Motion Layout Key Position Type Fragment . KEY _ POSITION _ TYPE , ĠMotion Layout Key Position Type Fragment . KEY _ POSITION _ TYPE _ PARENT ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( require Activity (), ĠR . id . fragment _ container _ view ). navigate ( R . id . show _ key _ position _ type , Ġbundle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . key Position Type Path Relative Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġbundle : Bundle Ġ= ĠBundle () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġbundle . put Int ( Motion Layout Key Position Type Fragment . KEY _ POSITION _ TYPE , ĠMotion Layout Key Position Type Fragment . KEY _ POSITION _ TYPE _ PATH ) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( require Activity (), ĠR . id . fragment _ container _ view ). navigate ( R . id . show _ key _ position _ type , Ġbundle ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . transition E asing Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( require Activity (), ĠR . id . fragment _ container _ view ). navigate ( R . id . show _ transition _ easing ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . attribute Pieces Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( require Activity (), ĠR . id . fragment _ container _ view ). navigate ( R . id . show _ attribute _ pieces ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbinding . attribute Rotation Button . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠNavigation . find Nav Controller ( require Activity (), ĠR . id . fragment _ container _ view ). navigate ( R . id . show _ attribute _ rotation ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġbinding . getRoot () ĊĠĠĠ Ġ} ĊĊ Ċ }