package Ġcom . think devs . crypt om ark et . controller Ċ Ċ import Ġandroidx . appcompat . app . AppCompatActivity Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . util . Log Ċ import Ġandroid . view . View Ċ import Ġandroid . widget . Adapter View Ċ import Ġandroid . widget . Array Adapter Ċ import Ġcom . think devs . crypt om ark et . R Ċ import Ġcom . think devs . crypt om ark et . model . Crypto Model Ċ import Ġcom . think devs . crypt om ark et . model . Helper Ċ import Ġio . reactivex . android . schedul ers . Android Schedulers Ċ import Ġio . reactivex . dis pos ables . Composite Disposable Ċ import Ġio . reactivex . schedul ers . Schedulers Ċ import Ġkotlinx . android . synt hetic . main . activity _ converter .* Ċ Ċ class ĠConverter Activity Ġ: ĠAppCompatActivity () Ġ{ Ċĉ Ġvar Ġcomposite Ġ: Composite Disposable ? Ġ= Ġnull ĊĉĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) Ċĉ ĉ set ContentView ( R . layout . activity _ converter ) ĊĉĉĊĉ ĉ composite Ġ= ĠComposite Disposable () ĊĉĉĊĉ ĉ getC rypto () Ċ ĉ } ĊĉĊ ĉ /** Ċĉ Ġ* ĠGet ĠCrypto ĠDetails Ċĉ Ġ*/ ĊĉĊ ĉ fun Ġget Crypto (){ Ċĉ ĉ val Ġservice Ġ= Helper . main Url () Ċĉ ĉ composite !!. add ( service . get bitcoin () Ċĉĉĉ ĉ . observe On ( Android Schedulers . main Thread ()) Ċĉĉĉ ĉ . subscribe On ( Schedulers . io ()) Ċĉĉĉ ĉ . subscribe ( Ċĉĉĉĉĉ ĉ { Ċĉĉĉĉĉĉ ĉ result -> Ċĉĉĉĉĉĉ ĉ all Details ( result ) Ċĉĉĉĉĉĉĉ Ċĉĉĉĉĉ ĉ },{ Ċĉĉĉĉ ĉ error -> Ċĉĉĉ ĉ } Ċĉĉĉ ĉ )) Ċ ĉ } Ċ ĉ private Ġfun Ġall Details ( result : ĠArrayList < Crypto Model > ?) Ġ{ Ċĉ ĉ for ( i Ġin Ġ 0 .. 0 ){ Ċĉĉ ĉ result !!. add ( Crypto Model ("$ i ", Ġ"")) Ċĉ ĉ } ĊĉĉĊĉĉĊĉ ĉ val Ġadapter : Array Adapter < Crypto Model > Ġ= ĠArray Adapter ( application Context , Ġandroid . R . layout . simple _ spinner _ dropdown _ item , Ġresult ) Ċĉ ĉ adapter . set DropDown View Resource ( android . R . layout . simple _ spinner _ dropdown _ item ) Ċĉ ĉ spinner Coin Name . adapter Ġ= Ġadapter Ċĉ ĉ coin Cal . adapter Ġ= Ġadapter ĊĉĉĊĉ ĉ spinner Coin Name . on ItemSelected Listener Ġ= Ġobject Ġ: Adapter View . On ItemSelected Listener { Ċĉĉ ĉ override Ġfun Ġon Nothing Selected ( parent : ĠAdapter View < *> ?) Ġ{ ĊĉĉĉĊĉĉ ĉ } ĊĉĉĉĊĉĉ ĉ override Ġfun Ġon ItemSelected ( parent : ĠAdapter View < *> ?, Ġview : ĠView ?, Ġposition : ĠInt , Ġid : ĠLong ) Ġ{ Ċĉĉĉ ĉ val Ġcurrency : String Ġ= Ġspinner Coin Name . getItem At Position ( position ). toString () Ċĉĉĉ ĉ log (" Item ĠSelected Ġ$ currency ") Ċĉĉĉ ĉ getC urrency ( currency ) Ċĉĉ ĉ } ĊĉĉĉĊĉ ĉ } ĊĉĉĊĉĉ Ċĉĉ ĊĉĉĊ ĉ } ĊĉĊ ĉ private Ġfun Ġget Currency ( currency : ĠString ) Ġ{ ĊĉĉĊĉĉĊĉ ĉ val Ġservice Ġ= ĠHelper . main Url () Ċĉ ĉ composite !!. add ( service . get _ ticket () Ċĉĉĉ ĉ . observe On ( Android Schedulers . main Thread ()) Ċĉĉĉ ĉ . subscribe On ( Schedulers . io ()) Ċĉĉĉ ĉ . subscribe ({ Ċĉĉĉĉ ĉ result Ġ-> Ċĉĉĉ ĉ },{ Ċĉĉĉĉ ĉ error Ġ-> Ċĉĉĉ ĉ })) Ċĉĉ ĊĉĊ ĉ } ĊĉĊ ĉ private Ġfun Ġlog ( msg : ĠString ) Ġ{ Ċĉ ĉ Log . e ( java Class . simple Name , Ġmsg ) Ċ ĉ } Ċ } Ċ