package Ġcom . m ga et an 8 9 . show sr age . activity Ċ Ċ import Ġandroid . content . DialogInterface Ċ import Ġandroid . content . Intent Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . v 7 . app . AlertDialog Ċ import Ġandroid . support . v 7 . app . AppCompatActivity Ċ import Ġandroid . widget . Toast Ċ import Ġcom . m ga et an 8 9 . show sr age . Constants Ċ import Ġcom . m ga et an 8 9 . show sr age . R Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . get Preferences Ċ import Ġcom . m ga et an 8 9 . show sr age . model . Generic Response Ċ import Ġcom . m ga et an 8 9 . show sr age . model . Update Response Ċ import Ġcom . m ga et an 8 9 . show sr age . network . S ick R age Api Ċ import Ġcom . m ga et an 8 9 . show sr age . service . Update Service Ċ import Ġretrofit . Callback Ċ import Ġretrofit . Ret rofit Error Ċ import Ġretrofit . client . Response Ċ Ċ class ĠUpdate Activity Ġ: ĠAppCompatActivity (), ĠCallback < Generic Response >, ĠDialog Interface . OnClickListener Ġ{ Ċ ĉ override Ġfun Ġfailure ( error : ĠRet rofit Error ?) Ġ{ Ċĉ ĉ error ?. printStackTrace () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Back Pressed () Ġ{ Ċĉ ĉ super . on Back Pressed () ĊĊĉ ĉ this . finish () Ċ ĉ } ĊĊ ĉ override Ġfun ĠonClick ( dialog : ĠDialog Interface ?, Ġwhich : ĠInt ) Ġ{ Ċĉ ĉ when Ġ( which ) Ġ{ Ċĉĉ ĉ DialogInterface . BUTTON _ POSITIVE Ġ-> Ġthis . update S ick R age () Ċĉĉ ĉ DialogInterface . BUTTON _ NEGATIVE Ġ-> Ġthis . finish () Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġsuccess ( generic Response : ĠGeneric Response ?, Ġresponse : ĠResponse ?) Ġ{ Ċĉ ĉ val Ġmessage Ġ= Ġgeneric Response ?. message . or Empty () Ċĉ ĉ if Ġ( message . isNotBlank ()) Ġ{ Ċĉĉ ĉ Toast . makeText ( this , Ġmessage , ĠToast . LENGTH _ SHORT ). show () Ċĉ ĉ } ĊĊĉ ĉ this . finish () Ċ ĉ } ĊĊ ĉ override Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . onCreate ( savedInstanceState ) ĊĊĉ ĉ S ick R age Api . instance . init ( this . get Preferences ()) ĊĊĉ ĉ val Ġupdate Ġ= Ġthis . intent ?. extras ?. get Parcelable < Update Response >( Constants . Bundle . UPDATE _ MODEL ) Ċĉ ĉ val Ġbuilder Ġ= ĠAlertDialog . Builder ( this ) Ċĉĉĉ ĉ . setTitle ( R . string . update _ s ick r age ) ĊĊĉ ĉ update ?. let Ġ{ Ċĉĉ ĉ builder . setMessage ( this . getString ( R . string . update _ available _ detailed , Ġit . current Version ?. version , Ġit . latest Version ?. version , Ġit . commits Offset )) Ċĉ ĉ } ĊĊĉ ĉ builder . set Positive Button ( R . string . update , Ġthis ) Ċĉĉĉ ĉ . set Negative Button ( R . string . ignore , Ġthis ) Ċĉĉĉ ĉ . show () Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate S ick R age () Ġ{ Ċĉ ĉ S ick R age Api . instance . services ?. update S ick R age ( this ) ĊĊĉ ĉ this . start Service ( Intent ( this , ĠUpdate Service :: class . java )) ĊĊĉ ĉ Toast . makeText ( this , ĠR . string . updating _ s ick r age , ĠToast . LENGTH _ SHORT ). show () ĊĊĉ ĉ this . finish () Ċ ĉ } Ċ } Ċ