package Ġcom . g ou jer . barcode k ano jo . adapter Ċ Ċ import Ġandroid . content . Context Ċ import Ġandroid . os . Handler Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ import Ġandroid . widget . TextView Ċ import Ġcom . g ou jer . barcode k ano jo . core . util . Dynamic Image Cache Ċ import Ġjp . co . cy bird . barcode k ano jo For G AM . R Ċ import Ġjp . co . cy bird . barcode k ano jo For G AM . adapter . base . Base Activity Model Adapter Ċ import Ġjp . co . cy bird . barcode k ano jo For G AM . adapter . base . Observable Adapter Ċ import Ġjp . co . cy bird . barcode k ano jo For G AM . core . model . Activity Model Ċ import Ġjp . co . cy bird . barcode k ano jo For G AM . core . model . K ano jo Ċ import Ġjp . co . cy bird . barcode k ano jo For G AM . core . model . Model List Ċ import Ġkotlinx . coroutines .* Ċ import Ġjava . lang . Runnable Ċ import Ġjava . util .* Ċ Ċ class ĠDashboard Adapter ( context : ĠContext ?, Ġprivate Ġval Ġm Dic : ĠDynamic Image Cache , Ġobserver : ĠObserver ?) Ġ: ĠBase Activity Model Adapter ( context ), ĠObservable Adapter Ġ{ Ċ ĉ private Ġval Ġis First Ġ= Ġfalse Ċ ĉ private Ġval Ġm Handler Ġ= ĠHandler () Ċ ĉ private Ġval Ġm Inflater Ġ= ĠLayoutInflater . from ( context ) Ċ ĉ private Ġvar Ġm Listener : ĠOn K ano jo ClickListener ? Ġ= Ġnull Ċ ĉ private Ġvar Ġm Loaded Photo Index Ġ= Ġ 0 Ċ ĉ private Ġval Ġm Notify Thread Ġ= ĠRunnable Ġ{ Ġsuper Notify DataSet Changed () Ġ} Ċ ĉ private Ġval Ġm Resources Observer Ġ= ĠRemote ResourceManager Observer ( this , Ġnull Ġas ĠRemote ResourceManager Observer ?) Ċ ĉ private Ġval Ġm Runnable Load Photos : ĠRunnable Ġ= Ġobject Ġ: ĠRunnable Ġ{ Ċĉ ĉ override Ġfun Ġrun () Ġ{ Ċĉĉ ĉ if Ġ( m Loaded Photo Index Ġ< Ġthis @ Dashboard Adapter . count ) Ġ{ Ċĉĉĉ ĉ val Ġdashboard Adapter Ġ= Ġthis @ Dashboard Adapter Ċĉĉĉ ĉ val Ġdashboard Adapter 2 Ġ= Ġthis @ Dashboard Adapter Ċĉĉĉ ĉ val Ġaccess 0 Ġ= Ġdashboard Adapter 2 . m Loaded Photo Index Ċĉĉĉ ĉ dashboard Adapter 2 . m Loaded Photo Index Ġ= Ġaccess 0 Ġ+ Ġ 1 Ċĉĉĉ ĉ val Ġa Ġ= Ġdashboard Adapter . getItem ( access 0 ) Ġas ĠActivity Model Ċĉĉĉ ĉ m Dic . request Bitmap ( a . left Img Url ) Ċĉĉĉ ĉ m Dic . request Bitmap ( a . right Img Url ) Ċĉĉĉ ĉ m Handler . post Delayed ( this , Ġ 2 0 0 ) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ ĉ private Ġval Ġm Scope Ġ= ĠMain Scope () ĊĊ ĉ fun Ġdestroy () Ġ{ Ċĉ ĉ m Scope . cancel () Ċ ĉ } ĊĊ ĉ interface ĠOn K ano jo ClickListener Ġ{ Ċĉ ĉ fun Ġon K ano jo Click ( k ano jo : ĠK ano jo ?) Ċ ĉ } ĊĊ ĉ override Ġfun Ġget View ( position : ĠInt , ĠconvertView : ĠView ?, Ġparent : ĠViewGroup ): ĠView ? Ġ{ Ċĉ ĉ val Ġholder : ĠViewHolder Ċĉ ĉ var Ġview Ġ= ĠconvertView Ċĉ ĉ if Ġ( view Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ view Ġ= Ġm Inflater . inflate ( R . layout . row _ activities , Ġnull ) Ċĉĉ ĉ holder Ġ= ĠViewHolder () Ċĉĉ ĉ holder . img Left Ġ= Ġview . findViewById ( R . id . row _ activities _ left _ img ) Ċĉĉ ĉ holder . img Right Ġ= Ġview . findViewById ( R . id . row _ activities _ right _ img ) Ċĉĉ ĉ holder . img Right Cover Ġ= Ġview . findViewById ( R . id . row _ activities _ right _ img _ cover ) Ċĉĉ ĉ holder . txt Activity Ġ= Ġview . findViewById ( R . id . row _ activities _ txt ) Ċĉĉ ĉ view . tag Ġ= Ġholder Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ holder Ġ= Ġview . tag Ġas ĠViewHolder Ċĉĉ ĉ holder . reset () Ċĉ ĉ } Ċĉ ĉ val Ġact Ġ= ĠgetItem ( position ) Ġas ĠActivity Model Ċĉ ĉ if Ġ( act Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ holder . left Image Job Ġ= Ġm Scope . launch Ġ{ Ġm Dic . load Bitmap ( holder . img Left !! , Ġact . left Img Url , ĠR . drawable . common _ no image _ product , Ġnull ) Ġ} Ċĉĉ ĉ holder . right Image Job Ġ= Ġm Scope . launch Ġ{ Ġm Dic . load Bitmap ( holder . img Right !! , Ġact . right Img Url , ĠR . drawable . common _ no image _ product , Ġnull ) Ġ} Ċĉĉ ĉ if Ġ( holder . txt Activity Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ holder . txt Activity !!. text Ġ= Ġact . activity Ċĉĉ ĉ } Ċĉĉ ĉ val Ġk ano jo Ġ= Ġact . k ano jo Ċĉĉ ĉ holder . img Left !!. setOnClickListener ( null ) Ċĉĉ ĉ holder . img Right !!. setOnClickListener ( null ) Ċĉĉ ĉ holder . img Right !!. visibility Ġ= ĠView . VISIBLE Ċĉĉ ĉ holder . img Right Cover !!. visibility Ġ= ĠView . VISIBLE Ċĉĉ ĉ when Ġ( act . activity _ type ) Ġ{ Ċĉĉĉĉ 2 , Ġ 9 Ġ-> Ġholder . img Left !!. setOnClickListener Ġ{ Ċĉĉĉĉ ĉ if Ġ( m Listener Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ m Listener !!. on K ano jo Click ( k ano jo ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉĉ 5 , Ġ 7 , Ġ 8 , Ġ 1 0 Ġ-> Ġholder . img Right !!. setOnClickListener Ġ{ Ċĉĉĉĉ ĉ if Ġ( m Listener Ġ!= Ġnull ) Ġ{ Ċĉĉĉĉĉ ĉ m Listener !!. on K ano jo Click ( k ano jo ) Ċĉĉĉĉ ĉ } Ċĉĉĉ ĉ } Ċĉĉĉĉ 1 1 Ġ-> Ġ{ Ċĉĉĉĉ ĉ holder . img Right !!. visibility Ġ= ĠView . GONE Ċĉĉĉĉ ĉ holder . img Right Cover !!. visibility Ġ= ĠView . GONE Ċĉĉĉ ĉ } Ċĉĉ ĉ } Ċĉ ĉ } Ċĉ ĉ return Ġview Ċ ĉ } ĊĊ ĉ fun Ġset On K ano jo ClickListener ( l : ĠOn K ano jo ClickListener ?) Ġ{ Ċĉ ĉ m Listener Ġ= Ġl Ċ ĉ } ĊĊ ĉ override Ġfun Ġset Model List ( l : ĠModel List < Activity Model >) Ġ{ Ċĉ ĉ super . setModel List ( l ) Ċĉ ĉ m Handler . remove Callbacks ( m Runnable Load Photos ) Ċĉ ĉ m Handler . post Delayed ( m Runnable Load Photos , Ġ 1 0 0 ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġadd Model List ( l : ĠModel List < Activity Model >) Ġ{ Ċĉ ĉ super . add Model List ( l ) Ċĉ ĉ for Ġ( a Ġin Ġl ) Ġ{ Ċĉĉ ĉ m Dic . request Bitmap ( a . left Img Url ) Ċĉĉ ĉ m Dic . request Bitmap ( a . right Img Url ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġremove Observer () Ġ{ Ċĉ ĉ m Handler . remove Callbacks ( m Notify Thread ) Ċĉ ĉ m Handler . remove Callbacks ( m Runnable Load Photos ) Ċĉ ĉ m Dic . delete Observer ( m Resources Observer ) Ċ ĉ } ĊĊ ĉ private Ġinner Ġclass ĠRemote ResourceManager Observer Ġprivate Ġconstructor () Ġ: ĠObserver Ġ{ Ċĉ ĉ /* Ġsynthetic Ġ*/ Ċĉ ĉ internal Ġconstructor ( dashboard Adapter : ĠDashboard Adapter ?, Ġremote ResourceManager Observer : ĠRemote ResourceManager Observer ?) Ġ: Ġthis () Ġ{} ĊĊĉ ĉ override Ġfun Ġupdate ( observable : ĠObservable , Ġdata : ĠAny ) Ġ{ Ċĉĉ ĉ if Ġ( data Ġ!= Ġnull ) Ġ{ Ċĉĉĉ ĉ m Handler . remove Callbacks ( m Notify Thread ) Ċĉĉĉ ĉ m Handler . post Delayed ( m Notify Thread , Ġ 4 0 0 ) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġnotify DataSet Changed () Ġ{ Ċĉ ĉ super . notify DataSet Changed () Ċĉ ĉ m Handler . remove Callbacks ( m Notify Thread ) Ċĉ ĉ m Handler . post Delayed ( m Notify Thread , Ġ 4 0 0 ) Ċ ĉ } ĊĊ ĉ fun Ġsuper Notify DataSet Changed () Ġ{ Ċĉ ĉ if Ġ( is First ) Ġ{ Ċĉĉ ĉ super . notify DataSet Invalid ated () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ super . notify DataSet Changed () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġclass ĠViewHolder Ġ{ Ċĉ ĉ var Ġimg Left : ĠImageView ? Ġ= Ġnull Ċĉ ĉ var Ġimg Right : ĠImageView ? Ġ= Ġnull Ċĉ ĉ var Ġimg Right Cover : ĠImageView ? Ġ= Ġnull Ċĉ ĉ var Ġtxt Activity : ĠTextView ? Ġ= Ġnull Ċĉ ĉ var Ġright Image Job : ĠJob ? Ġ= Ġnull Ċĉ ĉ var Ġleft Image Job : ĠJob ? Ġ= Ġnull Ċĉ ĉ fun Ġreset () Ġ{ Ċĉĉ ĉ if Ġ( left Image Job Ġ!= Ġnull Ġ&& Ġ! left Image Job !!. is Completed ) Ġ{ Ċĉĉĉ ĉ left Image Job !!. cancel ( null ) Ċĉĉ ĉ } Ċĉĉ ĉ if Ġ( right Image Job Ġ!= Ġnull Ġ&& Ġ! right Image Job !!. is Completed ) Ġ{ Ċĉĉĉ ĉ right Image Job !!. cancel ( null ) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ private Ġconst Ġval ĠTAG Ġ= Ġ" Dashboard Adapter " Ċ ĉ } ĊĊ ĉ init Ġ{ Ċĉ ĉ m Dic . add Observer ( m Resources Observer ) Ċ ĉ } Ċ }