/* Ċ Ġ* ĠCopyright Ġ 2 0 2 0 ĠM os by X Ġcontributors Ċ Ġ* Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ package Ġcom . g art es k . mos by x . m vi . integration test . lifecycle . fragment . child fragment Ċ Ċ import Ġandroid . app . Activity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Log Ċ import Ġcom . g art es k . mos by x . m vi . M vi Activity Ċ import Ġcom . g art es k . mos by x . m vi . integration test . R Ċ import Ġcom . g art es k . mos by x . m vi . integration test . lifecycle . Lifecycle Test Presenter Ċ import Ġcom . g art es k . mos by x . m vi . integration test . lifecycle . Lifecycle Test View Ċ Ċ class ĠM vi Lifecycle Child Fragment Activity Ġ: Ċ ĉ M vi Activity < Lifecycle Test View , ĠLifecycle Test Presenter >(), ĠLifecycle Test View Ġ{ ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ private Ġconst Ġval ĠTAG Ġ= Ġ" Frag me tn Tag " ĊĊĉ ĉ var Ġcreate Presenter Inv ocations Ġ= Ġ 0 ĊĊĉ ĉ private Ġlateinit Ġvar Ġcurrent Instance : ĠActivity ĊĊĉ ĉ fun Ġpress Back Button () Ġ{ Ċĉĉ ĉ current Instance . run On Ui Thread Ġ{ Ġcurrent Instance . on Back Pressed () Ġ} Ċĉ ĉ } Ċ ĉ } ĊĊĠĠĠ Ġlateinit Ġvar Ġpresenter : ĠLifecycle Test Presenter ĊĊ ĉ val Ġfragment : ĠContainer M vi Lifecycle Fragment Ċĉ ĉ get () Ġ= Ġsupport FragmentManager . find Fragment By Tag ( TAG ) Ġas ĠContainer M vi Lifecycle Fragment ĊĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ current Instance Ġ= Ġthis Ċĉ ĉ set ContentView ( R . layout . activity _ child _ m vi _ container ) Ċĉ ĉ Log . d ( java Class . simple Name , Ġ" onCreate () Ġ$ this ") Ċĉ ĉ if Ġ( savedInstanceState Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ support FragmentManager . beginTransaction () Ċĉĉĉ ĉ . replace ( Ċĉĉĉĉ ĉ R . id . fragment Container , Ċĉĉĉĉ ĉ Container M vi Lifecycle Fragment (), Ċĉĉĉĉ ĉ TAG Ċĉĉĉ ĉ ) Ċĉĉĉ ĉ . commit Now () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Destroy () Ġ{ Ċĉ ĉ super . on Destroy () Ċĉ ĉ Log . d ( java Class . simple Name , Ġ" on Destroy () Ġ$ this ") Ċ ĉ } ĊĊ ĉ override Ġfun Ġcreate Presenter (): ĠLifecycle Test Presenter Ġ{ Ċĉ ĉ create Presenter Inv ocations ++ Ċĉ ĉ presenter Ġ= ĠLifecycle Test Presenter () Ċĉ ĉ Log . d ( java Class . simple Name , Ġ" create Presenter () Ġ$ this Ġ$ presenter ") Ċĉ ĉ return Ġpresenter Ċ ĉ } Ċ }