package Ġcom . shop app . ui . address . base Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . view . View Ċ import Ġcom . shop app . R Ċ import Ġcom . shop app . gateway . entity . Address Ċ import Ġcom . shop app . ui . address . base . adapter . Address ListAdapter Ċ import Ġcom . shop app . ui . address . base . contract . Address List Presenter Ċ import Ġcom . shop app . ui . address . base . contract . Address ListView Ċ import Ġcom . shop app . ui . base . l ce . Base L ce Activity Ċ import Ġcom . shop app . ui . base . l ce . view . L ce Layout Ċ import Ġcom . shop app . ui . base . recycler . divider . Space Decoration Ċ import Ġkotlinx . android . synt hetic . main . activity _ address _ list .* Ċ import Ġjavax . inject . Inject Ċ Ċ abstract Ġclass ĠBase Address List Activity < A Ġ: ĠAddress ListAdapter , ĠV Ġ: ĠAddress ListView , ĠP Ġ: ĠAddress List Presenter < V >> Ġ: ĊĠĠĠ ĠBase L ce Activity < Pair < Address ?, ĠList < Address >>, ĠV , ĠP >(), ĊĠĠĠ ĠAddress ListView , ĊĠĠĠ ĠAddress ListAdapter . ActionButton Listener , ĊĠĠĠ ĠView . OnClickListener Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġaddress List Presenter : ĠP ĊĠĠĠ Ġprotected Ġlateinit Ġvar Ġaddress ListAdapter : ĠA ĊĠĠĠ Ġprotected Ġval Ġdata List : ĠMutable List < Address > Ġ= Ġmutable ListOf () ĊĠĠĠ Ġprotected Ġvar Ġdefault Address : ĠAddress ? Ġ= Ġnull ĊĊĠĠĠ Ġ// ANDROID ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġsetup Recycler () ĊĠĠĠĠĠĠĠ Ġload Data () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// INIT ĊĊĠĠĠ Ġoverride Ġfun Ġcreate Presenter () Ġ= Ġaddress List Presenter ĊĊĠĠĠ Ġoverride Ġfun Ġget ContentView () Ġ= ĠR . layout . activity _ address _ list ĊĊĠĠĠ Ġ// SETUP ĊĊĠĠĠ Ġprotected Ġabstract Ġfun Ġget Adapter (): ĠA ĊĊĠĠĠ Ġprivate Ġfun Ġsetup Recycler () Ġ{ ĊĠĠĠĠĠĠĠ Ġaddress ListAdapter Ġ= Ġget Adapter () ĊĠĠĠĠĠĠĠ Ġval Ġdecorator Ġ= ĠSpace Decoration ( top Space Ġ= Ġresources . get Dimension Pixel Size ( R . dim en . address _ item _ divider )) ĊĠĠĠĠĠĠĠ Ġre cyclerView . layout Manager Ġ= ĠLinearLayoutManager ( this ) ĊĠĠĠĠĠĠĠ Ġre cyclerView . adapter Ġ= Ġaddress ListAdapter ĊĠĠĠĠĠĠĠ Ġre cyclerView . addItem Decoration ( decorator ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// L CE ĊĊĠĠĠ Ġoverride Ġfun Ġload Data ( pull To Refresh : ĠBoolean ) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . load Data ( pull To Refresh ) ĊĠĠĠĠĠĠĠ Ġpresenter . getAddress List () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġshow Content ( data : ĠPair < Address ?, ĠList < Address >>) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . show Content ( data ) ĊĠĠĠĠĠĠĠ Ġdefault Address Ġ= Ġdata . first ĊĠĠĠĠĠĠĠ Ġdata List . clear () ĊĠĠĠĠĠĠĠ Ġdata List . addAll ( data . second ) ĊĠĠĠĠĠĠĠ Ġaddress ListAdapter . default Address Ġ= Ġdefault Address ĊĠĠĠĠĠĠĠ Ġaddress ListAdapter . notify DataSet Changed () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprotected Ġopen Ġfun Ġdelete Address ( address : ĠAddress ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġis Removed Ġ= Ġdata List . remove ( address ) ĊĠĠĠĠĠĠĠ Ġif Ġ( is Removed ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġaddress ListAdapter . notify DataSet Changed () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġpresenter . delete Address ( address . id ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ// CALLBACK ĊĊĠĠĠ Ġoverride Ġfun Ġon Default Button Clicked ( address : ĠAddress ) Ġ{ ĊĠĠĠĠĠĠĠ Ġchange State ( L ce Layout . L ce State . Loading State ()) ĊĠĠĠĠĠĠĠ Ġpresenter . setDefault Address ( address , Ġdata List ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonDelete Button Clicked ( address : ĠAddress ) Ġ{ ĊĠĠĠĠĠĠĠ Ġdelete Address ( address ) ĊĠĠĠ Ġ} Ċ }