package Ġio . github . fe elf re el inux . wy kop mob il ny . ui . modules . pm . con versations list Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 4 . app . Fragment Ċ import Ġandroid . support . v 4 . widget . Swipe Refresh Layout Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . R Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . base . Base Activity Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . base . Base Fragment Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . models . dataclass . Conversation Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . models . fragments . Data Fragment Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . models . fragments . getData Fragment Instance Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . models . fragments . remove Data Fragment Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . ui . adapters . Con versations ListAdapter Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . utils . isVisible Ċ import Ġio . github . fe elf re el inux . wy kop mob il ny . utils . prepare Ċ import Ġkotlinx . android . synt hetic . main . activity _ con versations _ list .* Ċ import Ġjavax . inject . Inject Ċ Ċ class ĠCon versations List Fragment Ġ: ĠBase Fragment (), ĠCon versations ListView , ĠSw ipe Refresh Layout . On Refresh Listener Ġ{ ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġconversations Data Fragment Ġ: ĠData Fragment < List < Conversation >> ĊĠĠĠ Ġ@ Inject Ġlateinit Ġvar Ġpresenter Ġ: ĠCon versations List Presenter ĊĠĠĠ Ġprivate Ġval Ġconversations Adapter Ġby Ġlazy Ġ{ ĠCon versations ListAdapter () Ġ} ĊĊĠĠĠ Ġcompanion Ġobject Ġ{ ĊĠĠĠĠĠĠĠ Ġval ĠDATA _ FRAGMENT _ TAG Ġ= Ġ" CONVER S ATIONS _ LIST " ĊĠĠĠĠĠĠĠ Ġfun Ġnew Instance (): ĠFragment Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĠCon versations List Fragment () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġinflater . inflate ( R . layout . activity _ con versations _ list , Ġcontainer , Ġfalse ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Activity Created ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġconversations Data Fragment Ġ= Ġsupport FragmentManager . getData Fragment Instance ( DATA _ FRAGMENT _ TAG ) ĊĠĠĠĠĠĠĠ Ġ( activity Ġas ĠBase Activity ). support ActionBar ?. setTitle ( R . string . messages ) ĊĠĠĠĠĠĠĠ Ġsw iper ef resh . setOn Refresh Listener ( this ) ĊĊĠĠĠĠĠĠĠ Ġre cyclerView . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġprepare () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġconversations Adapter ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġsw iper ef resh . is Refresh ing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġpresenter . subscribe ( this ) ĊĊĠĠĠĠĠĠĠ Ġif Ġ( con versations Data Fragment . data Ġ== Ġnull ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġloading View . isVisible Ġ= Ġtrue ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Refresh () ĊĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġconversations Adapter . dataset . addAll ( con versations Data Fragment . data !! ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġloading View . isVisible Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Con versations ( items Ġ: ĠList < Conversation >) Ġ{ ĊĠĠĠĠĠĠĠ Ġloading View . isVisible Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġsw iper ef resh . is Refresh ing Ġ= Ġfalse ĊĠĠĠĠĠĠĠ Ġconversations Adapter . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdataset . clear () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdataset . addAll ( items ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġnotify DataSet Changed () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Refresh () Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . load Con versations () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Save InstanceState ( out State : ĠBundle ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Save InstanceState ( out State ) ĊĠĠĠĠĠĠĠ Ġconversations Data Fragment . data Ġ= Ġconversations Adapter . dataset ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġpresenter . unsubscribe () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Pause () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Pause () ĊĠĠĠĠĠĠĠ Ġif Ġ( is Removing ) Ġsupport FragmentManager . remove Data Fragment ( con versations Data Fragment ) ĊĠĠĠ Ġ} Ċ }