package Ġuk . co . j ake lee . ret rofit experiments . medium Ċ Ċ import Ġandroid . app . Progress Dialog Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġuk . co . j ake lee . ret rofit experiments . MainActivity Ċ import Ġandroid . support . v 7 . widget . Linear LayoutManager Ċ import Ġandroid . support . v 7 . widget . RecyclerView Ċ import Ġuk . co . j ake lee . ret rofit experiments . medium . model . Ret ro Photo Ċ import Ġandroid . widget . Toast Ċ import Ġretrofit 2 . Call Ċ import Ġretrofit 2 . Callback Ċ import Ġretrofit 2 . Response Ċ import Ġuk . co . j ake lee . ret rofit experiments . R Ċ import Ġuk . co . j ake lee . ret rofit experiments . medium . network . Ret rofit Client Instance ĊĊĊ Ċ class ĠMedium Activity Ġ: ĠAppCompatActivity () Ġ{ ĊĠĠĠ Ġprivate Ġvar Ġadapter : ĠCustom Adapter ? Ġ= Ġnull ĊĠĠĠ Ġprivate Ġvar Ġre cyclerView : ĠRecyclerView ? Ġ= Ġnull ĊĠĠĠ Ġlateinit Ġvar Ġprogress Dialog : ĠProgress Dialog ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ ĠsetContentView ( R . layout . activity _ medium ) ĊĊĠĠĠĠĠĠĠ Ġprogress Dialog Ġ= ĠProgress Dialog ( this @ Medium Activity ) ĊĠĠĠĠĠĠĠ Ġprogress Dialog . setMessage (" Loading .... ") ĊĠĠĠĠĠĠĠ Ġprogress Dialog . show () ĊĊĠĠĠĠĠĠĠ Ġ/* Create Ġhandle Ġfor Ġthe ĠRet rofit Instance Ġinterface */ ĊĠĠĠĠĠĠĠ Ġval Ġservice Ġ= ĠRet rofit Client Instance . ret rofit Instance . create ( GetData Service :: class . java ) ĊĠĠĠĠĠĠĠ Ġval Ġcall Ġ= Ġservice . all Photos ĊĠĠĠĠĠĠĠ Ġcall . enqueue ( object Ġ: ĠCallback < List < Ret ro Photo >> Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Response ( call : ĠCall < List < Ret ro Photo >>, Ġresponse : ĠResponse < List < Ret ro Photo >>) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprogress Dialog . dismiss () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġgenerate DataList ( response . body () !! ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġoverride Ġfun Ġon Failure ( call : ĠCall < List < Ret ro Photo >>, Ġt : ĠThrowable ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġprogress Dialog . dismiss () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( this @ Medium Activity , Ġ" Something Ġwent Ġwrong ... Please Ġtry Ġlater !", ĠToast . LENGTH _ SHORT ). show () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ}) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġ/* Method Ġto Ġgenerate ĠList Ġof Ġdata Ġusing ĠRecyclerView Ġwith Ġcustom Ġadapter */ ĊĠĠĠ Ġprivate Ġfun Ġgenerate DataList ( photo List : ĠList < Ret ro Photo >) Ġ{ ĊĠĠĠĠĠĠĠ Ġre cyclerView Ġ= ĠfindViewById ( R . id . custom RecyclerView ) ĊĠĠĠĠĠĠĠ Ġadapter Ġ= ĠCustom Adapter ( this , Ġphoto List ) ĊĠĠĠĠĠĠĠ Ġval Ġlayout Manager Ġ= ĠLinearLayoutManager ( this @ Medium Activity ) ĊĠĠĠĠĠĠĠ Ġre cyclerView !!. layout Manager Ġ= Ġlayout Manager ĊĠĠĠĠĠĠĠ Ġre cyclerView !!. adapter Ġ= Ġadapter ĊĠĠĠ Ġ} Ċ } Ċ