package Ġcom . p avel rek un . rek ado . services . dialogs Ċ Ċ import Ġandroid . widget . Array Adapter Ċ import Ġandroid . widget . Toast Ċ import Ġandroidx . appcompat . app . AlertDialog Ċ import Ġcom . google . android . material . dialog . Material AlertDialog Builder Ċ import Ġcom . p avel rek un . mag ta . design . getString Ċ import Ġcom . p avel rek un . mag ta . design . isEmpty Ċ import Ġcom . p avel rek un . mag ta . restart App Ċ import Ġcom . p avel rek un . mag ta . services . constants . Links Ċ import Ġcom . p avel rek un . pen za . services . helpers . Settings Dialog s Helper Ċ import Ġcom . p avel rek un . rek ado . R Ċ import Ġcom . p avel rek un . rek ado . base . Base Activity Ċ import Ġcom . p avel rek un . rek ado . containers . Primary Container Activity Ċ import Ġcom . p avel rek un . rek ado . data . Config Ċ import Ġcom . p avel rek un . rek ado . databinding . Dialog Don ate Binding Ċ import Ġcom . p avel rek un . rek ado . databinding . Dialog Payload Download Binding Ċ import Ġcom . p avel rek un . rek ado . screens . payload _ fragment . Payload s ViewModel Ċ import Ġcom . p avel rek un . rek ado . services . Constants Ċ import Ġcom . p avel rek un . rek ado . services . Events Ċ import Ġcom . p avel rek un . rek ado . services . payload s . Payload Helper Ċ import Ġcom . p avel rek un . rek ado . services . utils . Preferences Utils Ċ import Ġcom . p avel rek un . rek ado . services . utils . Utils Ċ import Ġorg . green robot . event bus . EventBus Ċ Ċ object ĠDialog s Sh ower Ġ{ ĊĊĠĠĠ Ġfun Ġshow Payload s Dialog ( activity : ĠBase Activity ): ĠAlertDialog Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġadapter Ġ= ĠArray Adapter ( activity , ĠR . layout . item _ dialog _ payload , ĠPayload Helper . getTitle s ()) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠMaterial AlertDialog Builder ( activity ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . setTitle ( R . string . dialog _ loader _ title ) ĊĠĠĠĠĠĠĠ Ġbuilder . setAdapter ( adapter ) Ġ{ Ġdialog , Ġwhich Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġselected Payload Ġ= Ġadapter . getItem ( which ) Ġas ĠString ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPreferences Utils . put Ch osen ( Payload Helper . find ( selected Payload )) ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent Bus . getDefault (). post ( Events . Payload Selected ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdialog . cancel () ĊĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbuilder . setOn Dismiss Listener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent Bus . getDefault (). post ( Events . Payload Not Selected ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġbuilder . create (). apply Ġ{ Ġshow () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow No Payload s Dialog ( activity : ĠBase Activity ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠMaterial AlertDialog Builder ( activity ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . setTitle ( R . string . dialog _ loader _ no _ payload s _ title ) ĊĠĠĠĠĠĠĠ Ġbuilder . setMessage ( R . string . dialog _ loader _ no _ payload s _ description ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . set Negative Button ( R . string . dialog _ button _ negative ) Ġ{ Ġ_, Ġ_ Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠEvent Bus . getDefault (). post ( Events . Payload Not Selected ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbuilder . create (). apply Ġ{ Ġshow () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow Payload s Reset Dialog ( activity : ĠBase Activity ): ĠAlertDialog Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠMaterial AlertDialog Builder ( activity ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . setTitle ( R . string . dialog _ reset _ payload s _ title ) ĊĠĠĠĠĠĠĠ Ġbuilder . setMessage ( R . string . dialog _ reset _ payload s _ summary ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . set Negative Button ( R . string . dialog _ button _ negative ) Ġ{ Ġ_, Ġ_ Ġ-> Ġ} ĊĠĠĠĠĠĠĠ Ġbuilder . set Positive Button ( R . string . dialog _ button _ positive ) Ġ{ Ġ_, Ġ_ Ġ-> Ġ} ĊĊĠĠĠĠĠĠĠ Ġreturn Ġbuilder . create (). apply Ġ{ Ġshow () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow Payload s Download Dialog ( activity : ĠBase Activity , ĠviewModel : ĠPayload s ViewModel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠDialog Payload Download Binding . inflate ( activity . layout Inflater ) ĊĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠMaterial AlertDialog Builder ( activity ) ĊĠĠĠĠĠĠĠ Ġbuilder . setTitle ( R . string . dialog _ payload _ download _ title ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . create (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset View ( binding . root ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġbinding . dialog Download Payload Download . setOnClickListener Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ(! binding . dialog Download Payload Name . isEmpty () Ġ&& Ġ! binding . dialog Download Payload URL . isEmpty ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . download Payload ( binding . dialog Download Payload Name . getString (), Ġbinding . dialog Download Payload URL . getString ()) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthis . dismiss () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠToast . makeText ( activity , ĠR . string . payload s _ download _ status _ empty , ĠToast . LENGTH _ SHORT ). show () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow Payload s Updates Dialog ( activity : ĠBase Activity , Ġupdated Config : ĠConfig , ĠviewModel : ĠPayload s ViewModel ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠMaterial AlertDialog Builder ( activity ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . setTitle ( R . string . dialog _ payload _ update _ title ) ĊĠĠĠĠĠĠĠ Ġbuilder . setMessage ( R . string . dialog _ payload _ update _ message ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . set Negative Button ( R . string . dialog _ button _ negative ) Ġ{ Ġ_, Ġ_ Ġ-> Ġ} ĊĠĠĠĠĠĠĠ Ġbuilder . set Positive Button ( R . string . dialog _ button _ update ) Ġ{ Ġ_, Ġ_ Ġ-> ĊĠĠĠĠĠĠĠĠĠĠĠ ĠviewModel . update Payload s ( updated Config ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġbuilder . create (). apply Ġ{ Ġshow () Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow Don ate Dialog ( activity : ĠBase Activity ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġbinding Ġ= ĠDialog Don ate Binding . inflate ( activity . layout Inflater ) ĊĠĠĠĠĠĠĠ Ġval Ġbuilder Ġ= ĠMaterial AlertDialog Builder ( activity ) ĊĊĠĠĠĠĠĠĠ Ġbinding . don ate Button . setOnClickListener Ġ{ ĠUtils . open Link ( activity , ĠLinks . BU Y _ ME _ CO FF EE _ LINK ) Ġ} ĊĊĠĠĠĠĠĠĠ Ġbuilder . setTitle ( R . string . navigation _ don ate ) ĊĊĠĠĠĠĠĠĠ Ġbuilder . create (). apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset View ( binding . root ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġshow () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġshow Settings Restart Dialog ( activity : ĠBase Activity ) Ġ{ ĊĠĠĠĠĠĠĠ ĠSettings Dialog s Helper . show Settings Restart Dialog ( activity ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġactivity . restart App ( Primary Container Activity :: class ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ Ċ }