package Ġcom . m ga et an 8 9 . show sr age . fragment Ċ Ċ import Ġandroid . app . Search Manager Ċ import Ġandroid . content . Component Name Ċ import Ġandroid . content . Intent Ċ import Ġandroid . content . res . Color State List Ċ import Ġandroid . graphics . Bitmap Ċ import Ġandroid . graphics . Bitmap Factory Ċ import Ġandroid . graphics . Color Ċ import Ġandroid . graphics . drawable . Drawable Ċ import Ġandroid . net . Uri Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . support . custom tabs . Custom Tabs Client Ċ import Ġandroid . support . custom tabs . Custom Tabs Intent Ċ import Ġandroid . support . custom tabs . Custom Tabs Service Connection Ċ import Ġandroid . support . custom tabs . Custom Tabs Session Ċ import Ġandroid . support . v 4 . app . Fragment Ċ import Ġandroid . support . v 4 . app . Fragment Activity Ċ import Ġandroid . support . v 4 . content . Context Compat Ċ import Ġandroid . support . v 4 . view . View Compat Ċ import Ġandroid . support . v 4 . widget . Swipe Refresh Layout Ċ import Ġandroid . support . v 7 . app . AlertDialog Ċ import Ġandroid . support . v 7 . graphics . Palette Ċ import Ġandroid . text . format . Date Utils Ċ import Ġandroid . view . LayoutInflater Ċ import Ġandroid . view . Menu Ċ import Ġandroid . view . Menu Inflater Ċ import Ġandroid . view . MenuItem Ċ import Ġandroid . view . View Ċ import Ġandroid . view . ViewGroup Ċ import Ġandroid . widget . ImageView Ċ 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 . activity . MainActivity Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . delete Show Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . get Show Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . save Show Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . toInt Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . to Relative Date Ċ import Ġcom . m ga et an 8 9 . show sr age . helper . Generic Callback Ċ import Ġcom . m ga et an 8 9 . show sr age . helper . Image Loader Ċ import Ġcom . m ga et an 8 9 . show sr age . helper . Utils Ċ 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 . ImageType Ċ import Ġcom . m ga et an 8 9 . show sr age . model . Indexer Ċ import Ġcom . m ga et an 8 9 . show sr age . model . Show Ċ import Ġcom . m ga et an 8 9 . show sr age . model . Single Show Ċ import Ġcom . m ga et an 8 9 . show sr age . network . S ick R age Api Ċ import Ġio . realm . Realm Ċ import Ġio . realm . Realm ChangeListener Ċ import Ġio . realm . Realm List Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ airs Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ banner Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ fan _ art Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ genre Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ imdb Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ language _ country Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ location Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ name Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ network Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ next _ episode _ date Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ poster Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ quality Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ status Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ subtitle s Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ the _ tv db Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . show _ web _ search Ċ import Ġkotlinx . android . synt hetic . main . fragment _ show _ overview . swipe _ refresh Ċ import Ġretrofit . Callback Ċ import Ġretrofit . Ret rofit Error Ċ import Ġretrofit . client . Response Ċ import Ġjava . lang . ref . Weak Reference Ċ Ċ class ĠShow Overview Fragment Ġ: ĠFragment (), ĠCallback < Single Show >, ĠView . OnClickListener , ĠImage Loader . On Image Result , ĠSw ipe Refresh Layout . On Refresh Listener , ĠPalette . Palette Async Listener , ĠRealm ChangeListener < Show > Ġ{ Ċ ĉ private Ġval Ġindexer Id Ġby Ġlazy Ġ{ Ġthis . arguments !!. getInt ( Constants . Bundle . INDEX ER _ ID ) Ġ} Ċ ĉ private Ġvar Ġpause Menu : ĠMenuItem ? Ġ= Ġnull Ċ ĉ private Ġlateinit Ġvar Ġrealm : ĠRealm Ċ ĉ private Ġvar Ġresume Menu : ĠMenuItem ? Ġ= Ġnull Ċ ĉ private Ġvar Ġservice Connection : ĠService Connection ? Ġ= Ġnull Ċ ĉ private Ġlateinit Ġvar Ġshow : ĠShow Ċ ĉ private Ġvar Ġtab Session : ĠCustom Tabs Session ? Ġ= Ġnull ĊĊ ĉ init Ġ{ Ċĉ ĉ this . set Has Options Menu ( true ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġfailure ( error : ĠRet rofit Error ?) Ġ{ Ċĉ ĉ this . swipe _ refresh ?. is Refresh ing Ġ= Ġfalse ĊĊĉ ĉ error ?. printStackTrace () Ċ ĉ } ĊĊ ĉ fun Ġget Set Show Quality Callback () Ġ= ĠGeneric Callback ( this . activity ) ĊĊ ĉ override Ġfun ĠonChange ( show : ĠShow ) Ġ{ Ċĉ ĉ if Ġ(! show . is Loaded Ġ|| Ġ! show . isValid ) Ġ{ Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ if Ġ( this . service Connection Ġ== Ġnull ) Ġ{ Ċĉĉ ĉ this . context ?. let Ġ{ Ċĉĉĉ ĉ this . service Connection Ġ= ĠService Connection ( this ) ĊĊĉĉĉ ĉ Custom Tabs Client . bind Custom Tabs Service ( it , Ġ" com . android . chrome ", Ġthis . service Connection ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ this . activity ?. title Ġ= Ġshow . show Name ĊĊĉ ĉ val Ġnext Episode Air Date Ġ= Ġshow . next Episode Air Date ĊĊĉ ĉ this . show Hide Pause Resume Menus ( show . paused Ġ== Ġ 0 ) ĊĊĉ ĉ val Ġair s Ġ= Ġshow . airs ĊĊĉ ĉ this . show _ airs ?. text Ġ= Ġthis . getString ( R . string . airs , Ġif Ġ( airs . isNull OrEmpty ()) Ġ" N / A " Ġelse Ġair s ) Ċĉ ĉ this . show _ airs ?. visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ Image Loader . load ( this . show _ banner , ĠS ick R age Api . instance . getImage Url ( ImageType . BAN NER , Ġshow . tv Db Id , ĠIndex er . TV DB ), Ġfalse , Ġnull , Ġthis ) Ċĉ ĉ this . show _ banner ?. content Description Ġ= Ġshow . show Name ĊĊĉ ĉ Image Loader . load ( this . show _ fan _ art , ĠS ick R age Api . instance . getImage Url ( ImageType . F AN _ ART , Ġshow . tv Db Id , ĠIndex er . TV DB ), Ġfalse , Ġnull , Ġthis ) Ċĉ ĉ this . show _ fan _ art ?. content Description Ġ= Ġshow . show Name ĊĊĉ ĉ val Ġgen res List Ġ= Ġshow . genre ĊĊĉ ĉ if Ġ( genres List ?. isNotEmpty () Ġ== Ġtrue ) Ġ{ Ċĉĉ ĉ val Ġgen res Ġ= Ġgen res List . join ToString () ĊĊĉĉ ĉ this . show _ genre ?. text Ġ= Ġthis . getString ( R . string . genre , Ġgen res ) Ċĉĉ ĉ this . show _ genre ?. visibility Ġ= ĠView . VISIBLE Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ this . show _ genre ?. visibility Ġ= ĠView . GONE Ċĉ ĉ } ĊĊĉ ĉ this . show _ imdb ?. visibility Ġ= Ġif Ġ( show . imdb Id . isNull OrEmpty ()) ĠView . GONE Ġelse ĠView . VISIBLE ĊĊĉ ĉ this . show _ language _ country ?. text Ġ= Ġthis . getString ( R . string . language _ value , Ġshow . language ) Ċĉ ĉ this . show _ language _ country ?. visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ val Ġlocation Ġ= Ġshow . location ĊĊĉ ĉ this . show _ location ?. text Ġ= Ġthis . getString ( R . string . location , Ġif Ġ( location . isNull OrEmpty ()) Ġ" N / A " Ġelse Ġlocation ) Ċĉ ĉ this . show _ location ?. visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ this . show _ name ?. text Ġ= Ġshow . show Name Ċĉ ĉ this . show _ name ?. visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ if Ġ( next Episode Air Date . isEmpty ()) Ġ{ Ċĉĉ ĉ this . show _ next _ episode _ date ?. visibility Ġ= ĠView . GONE Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ this . show _ next _ episode _ date ?. text Ġ= Ġthis . getString ( R . string . next _ episode , Ġnext Episode Air Date . to Relative Date (" yyyy - MM - dd ", ĠDate Utils . DAY _ IN _ M ILL IS )) Ċĉĉ ĉ this . show _ next _ episode _ date ?. visibility Ġ= ĠView . VISIBLE Ċĉ ĉ } ĊĊĉ ĉ this . show _ network ?. text Ġ= Ġthis . getString ( R . string . network , Ġshow . network ) Ċĉ ĉ this . show _ network ?. visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ Image Loader . load ( this . show _ poster , ĠS ick R age Api . instance . getImage Url ( ImageType . POST ER , Ġshow . tv Db Id , ĠIndex er . TV DB ), Ġfalse , Ġthis , Ġnull ) Ċĉ ĉ this . show _ poster ?. content Description Ġ= Ġshow . show Name ĊĊĉ ĉ val Ġquality Ġ= Ġshow . quality ĊĊĉ ĉ if Ġ(" custom ". equals ( quality , Ġtrue )) Ġ{ Ċĉĉ ĉ val Ġquality Details Ġ= Ġshow . quality Details Ċĉĉ ĉ val Ġallowed Ġ= Ġthis . get Translated Qual ities ( quality Details ?. initial , Ġtrue ). join ToString () Ċĉĉ ĉ val Ġpreferred Ġ= Ġthis . get Translated Qual ities ( quality Details ?. archive , Ġfalse ). join ToString () ĊĊĉĉ ĉ this . show _ quality ?. text Ġ= Ġthis . getString ( R . string . quality _ custom , Ġallowed , Ġpreferred ) Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ this . show _ quality ?. text Ġ= Ġthis . getString ( R . string . quality , Ġquality ) Ċĉ ĉ } ĊĊĉ ĉ this . show _ quality ?. visibility Ġ= ĠView . VISIBLE ĊĊĉ ĉ if Ġ( next Episode Air Date . isEmpty ()) Ġ{ Ċĉĉ ĉ val Ġstatus Ġ= Ġshow . getStatus Translation Resource () ĊĊĉĉ ĉ this . show _ status ?. text Ġ= Ġif Ġ( status Ġ!= Ġ 0 ) Ġthis . getString ( status ) Ġelse Ġshow . status Ċĉĉ ĉ this . show _ status ?. visibility Ġ= ĠView . VISIBLE Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ this . show _ status ?. visibility Ġ= ĠView . GONE Ċĉ ĉ } ĊĊĉ ĉ this . show _ subtitle s ?. text Ġ= Ġthis . getString ( R . string . subtitle s _ value , Ġthis . getString ( if Ġ( show . subtitle s Ġ== Ġ 0 ) ĠR . string . no Ġelse ĠR . string . yes )) Ċĉ ĉ this . show _ subtitle s ?. visibility Ġ= ĠView . VISIBLE Ċ ĉ } ĊĊ ĉ override Ġfun ĠonClick ( view : ĠView ?) Ġ{ Ċĉ ĉ if Ġ( view Ġ== Ġnull Ġ|| Ġ! this . show . isValid ) Ġ{ Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ val Ġactivity Ġ= Ġthis . activity Ċĉ ĉ var Ġcolor Ġ= Ġif Ġ( activity Ġ!= Ġnull ) ĠContext Compat . getColor ( activity , ĠR . color . primary ) Ġelse ĠColor . BLUE Ċĉ ĉ color Ġ= Ġ( activity Ġas ? ĠMainActivity )?. theme Colors ?. primary Ġ?: Ġcolor ĊĊĉ ĉ val Ġurl Ġ= Ġwhen Ġ( view . id ) Ġ{ Ċĉĉ ĉ R . id . show _ imdb Ġ-> Ġ" http :// www . imdb . com / title /${ this . show . imdb Id }" Ċĉĉ ĉ R . id . show _ the _ tv db Ġ-> Ġ" http :// the tv db . com /? tab = series & id =${ this . show . tv Db Id }" Ċĉĉ ĉ R . id . show _ web _ search Ġ-> Ġ{ Ċĉĉĉ ĉ val Ġintent Ġ= ĠIntent ( Intent . ACTION _ WEB _ SEARCH ) Ċĉĉĉ ĉ intent . putExtra ( Search Manager . QUERY , Ġthis . show . show Name ) ĊĊĉĉĉ ĉ this . startActivity ( intent ) ĊĊĉĉĉ ĉ return Ċĉĉ ĉ } Ċĉĉ ĉ else Ġ-> Ġreturn Ċĉ ĉ } ĊĊĉ ĉ val Ġtab Intent Ġ= ĠCustom Tabs Intent . Builder ( this . tab Session ) Ċĉĉĉ ĉ . add Default Share MenuItem () Ċĉĉĉ ĉ . enable Url Bar H iding () Ċĉĉĉ ĉ . set Close Button Icon ( Bitmap Factory . decode Resource ( this . resources , ĠR . drawable . ic _ arrow _ back _ white _ 2 4 dp )) Ċĉĉĉ ĉ . set Show Title ( true ) Ċĉĉĉ ĉ . set Toolbar Color ( color ) Ċĉĉĉ ĉ . build () Ċĉ ĉ tab Intent . launch Url ( this . activity , ĠUri . parse ( url )) Ċ ĉ } ĊĊ ĉ override Ġfun ĠonCreate Options Menu ( menu : ĠMenu ?, Ġinflater : ĠMenu Inflater ?) Ġ{ Ċĉ ĉ in flater ?. inflate ( R . menu . show _ overview , Ġmenu ) ĊĊĉ ĉ this . pause Menu Ġ= Ġmenu ?. find Item ( R . id . menu _ pause _ show ) Ċĉ ĉ this . pause Menu ?. isVisible Ġ= Ġfalse Ċĉ ĉ this . resume Menu Ġ= Ġmenu ?. find Item ( R . id . menu _ resume _ show ) Ċĉ ĉ this . resume Menu ?. isVisible Ġ= Ġfalse Ċ ĉ } ĊĊ ĉ override Ġfun ĠonCreate View ( in flater : ĠLayoutInflater , Ġcontainer : ĠViewGroup ?, ĠsavedInstanceState : ĠBundle ?): ĠView ? Ċĉĉ ĉ = Ġinflater . inflate ( R . layout . fragment _ show _ overview , Ġcontainer , Ġfalse ) ĊĊ ĉ override Ġfun Ġon Destroy () Ġ{ Ċĉ ĉ val Ġactivity Ġ= Ġthis . activity ĊĊĉ ĉ if Ġ( activity Ġis ĠMainActivity ) Ġ{ Ċĉĉ ĉ activity . reset Theme Colors () Ċĉ ĉ } ĊĊĉ ĉ if Ġ( this . service Connection Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ this . context ?. unbind Service ( this . service Connection ) Ċĉ ĉ } ĊĊĉ ĉ super . on Destroy () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Generated ( palette : ĠPalette ) Ġ{ Ċĉ ĉ val Ġcontext Ġ= Ġthis . context Ġ?: Ġreturn Ċĉ ĉ val Ġactivity Ġ= Ġthis . activity Ċĉ ĉ val Ġcolors Ġ= ĠUtils . get Theme Colors ( context , Ġpalette ) Ċĉ ĉ val Ġcolor Primary Ġ= Ġcolors . primary ĊĊĉ ĉ if Ġ( activity Ġis ĠMainActivity ) Ġ{ Ċĉĉ ĉ activity . theme Colors Ġ= Ġcolors Ċĉ ĉ } ĊĊĉ ĉ if Ġ( color Primary Ġ== Ġ 0 ) Ġ{ Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ val Ġcolor State List Ġ= ĠColor State List . valueOf ( color Primary ) Ċĉ ĉ val ĠtextColor Ġ= ĠUtils . get Contrast Color ( color Primary ) ĊĊĉ ĉ this . show _ imdb ?. let Ġ{ Ċĉĉ ĉ View Compat . setBackground Tint List ( it , Ġcolor State List ) Ċĉĉ ĉ it . setTextColor ( textColor ) Ċĉ ĉ } ĊĊĉ ĉ this . show _ the _ tv db ?. let Ġ{ Ċĉĉ ĉ View Compat . setBackground Tint List ( it , Ġcolor State List ) Ċĉĉ ĉ it . setTextColor ( textColor ) Ċĉ ĉ } ĊĊĉ ĉ this . show _ web _ search ?. let Ġ{ Ċĉĉ ĉ View Compat . setBackground Tint List ( it , Ġcolor State List ) Ċĉĉ ĉ it . setTextColor ( textColor ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Image Error ( imageView : ĠImageView , Ġerror Drawable : ĠDrawable ?) Ġ{ Ċĉ ĉ val Ġparent Ġ= ĠimageView . parent ĊĊĉ ĉ if Ġ( parent Ġis ĠView ) Ġ{ Ċĉĉ ĉ parent . visibility Ġ= ĠView . GONE Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Image Ready ( imageView : ĠImageView , Ġresource : ĠBitmap ) Ġ{ Ċĉ ĉ val Ġparent Ġ= ĠimageView . parent ĊĊĉ ĉ if Ġ( parent Ġis ĠView ) Ġ{ Ċĉĉ ĉ parent . visibility Ġ= ĠView . VISIBLE Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Options ItemSelected ( item : ĠMenuItem ?) Ġ= Ġwhen Ġ( item ?. itemId ) Ġ{ Ċĉ ĉ R . id . menu _ change _ quality Ġ-> Ġ{ Ċĉĉ ĉ this . change Quality () ĊĊĉĉ ĉ true Ċĉ ĉ } ĊĊĉ ĉ R . id . menu _ delete _ show Ġ-> Ġ{ Ċĉĉ ĉ this . delete Show () ĊĊĉĉ ĉ true Ċĉ ĉ } ĊĊĉ ĉ R . id . menu _ pause _ show Ġ-> Ġ{ Ċĉĉ ĉ this . pause Or Resume Show ( true ) ĊĊĉĉ ĉ true Ċĉ ĉ } ĊĊĉ ĉ R . id . menu _ re scan _ show Ġ-> Ġ{ Ċĉĉ ĉ this . re scan Show () ĊĊĉĉ ĉ true Ċĉ ĉ } ĊĊĉ ĉ R . id . menu _ resume _ show Ġ-> Ġ{ Ċĉĉ ĉ this . pause Or Resume Show ( false ) ĊĊĉĉ ĉ true Ċĉ ĉ } ĊĊĉ ĉ R . id . menu _ update _ show Ġ-> Ġ{ Ċĉĉ ĉ this . update Show () ĊĊĉĉ ĉ true Ċĉ ĉ } ĊĊĉ ĉ else Ġ-> Ġsuper . on Options ItemSelected ( item ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Refresh () Ġ{ Ċĉ ĉ this . swipe _ refresh ?. is Refresh ing Ġ= Ġtrue ĊĊĉ ĉ val Ġindexer Id Ġ= Ġthis . arguments ?. getInt ( Constants . Bundle . INDEX ER _ ID ) Ġ?: Ġreturn ĊĊĉ ĉ S ick R age Api . instance . services ?. get Show ( indexer Id , Ġthis ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Resume () Ġ{ Ċĉ ĉ super . on Resume () ĊĊĉ ĉ this . on Refresh () Ċ ĉ } ĊĊ ĉ override Ġfun ĠonStart () Ġ{ Ċĉ ĉ super . onStart () ĊĊĉ ĉ this . realm Ġ= ĠRealm . getDefaultInstance () Ċĉ ĉ this . show Ġ= Ġthis . realm . get Show ( this . indexer Id , Ġthis ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Stop () Ġ{ Ċĉ ĉ if Ġ( this . show . isValid ) Ġ{ Ċĉĉ ĉ this . show . removeAll Change Listeners () Ċĉ ĉ } ĊĊĉ ĉ this . realm . close () ĊĊĉ ĉ super . on Stop () Ċ ĉ } ĊĊ ĉ override Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ this . show _ imdb ?. setOnClickListener ( this ) Ċĉ ĉ this . show _ the _ tv db ?. setOnClickListener ( this ) Ċĉ ĉ this . show _ web _ search ?. setOnClickListener ( this ) ĊĊĉ ĉ this . swipe _ refresh ?. setColor Scheme Resources ( R . color . accent ) Ċĉ ĉ this . swipe _ refresh ?. setOn Refresh Listener ( this ) ĊĊĉ ĉ this . check Support Web Search () Ċ ĉ } ĊĊ ĉ override Ġfun Ġsuccess ( single Show : ĠSingle Show ?, Ġresponse : ĠResponse ?) Ġ{ Ċĉ ĉ this . swipe _ refresh ?. is Refresh ing Ġ= Ġfalse ĊĊĉ ĉ val Ġshow Ġ= Ġsingle Show ?. data Ġ?: Ġreturn ĊĊĉ ĉ Realm . getDefaultInstance (). use Ġ{ Ċĉĉ ĉ it . save Show ( show ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġchange Quality () Ġ{ Ċĉ ĉ Change Quality Fragment . newInstance ( this . indexer Id ) Ċĉĉĉ ĉ . show ( this . child FragmentManager , Ġ" change _ quality ") Ċ ĉ } ĊĊ ĉ private Ġfun Ġcheck Support Web Search () Ġ{ Ċĉ ĉ val Ġweb Search Intent Ġ= ĠIntent ( Intent . ACTION _ WEB _ SEARCH ) Ċĉ ĉ val Ġmanager Ġ= Ġthis . context ?. package Manager Ċĉ ĉ val Ġactivities Ġ= Ġmanager ?. query Intent Activities ( web Search Intent , Ġ 0 ). or Empty () ĊĊĉ ĉ this . show _ web _ search ?. visibility Ġ= Ġif Ġ( activities . isNotEmpty ()) ĠView . VISIBLE Ġelse ĠView . GONE Ċ ĉ } ĊĊ ĉ private Ġfun Ġdelete Show () Ġ{ Ċĉ ĉ val Ġactivity Ġ= Ġthis . activity Ċĉ ĉ if Ġ( activity Ġ== Ġnull Ġ|| Ġ! this . show . is Loaded ) Ġ{ Ċĉĉ ĉ return Ċĉ ĉ } ĊĊĉ ĉ val Ġindexer Id Ġ= Ġthis . indexer Id Ċĉ ĉ val Ġcallback Ġ= ĠDelete Show Callback ( activity , Ġindexer Id ) ĊĊĉ ĉ AlertDialog . Builder ( activity ) Ċĉĉĉ ĉ . setTitle ( this . getString ( R . string . delete _ show _ title , Ġthis . show . show Name )) Ċĉĉĉ ĉ . setMessage ( R . string . delete _ show _ message ) Ċĉĉĉ ĉ . set Positive Button ( R . string . keep ) Ġ{ Ġ_, Ġ_ Ġ-> Ċĉĉĉĉ ĉ S ick R age Api . instance . services ?. delete Show ( indexer Id , Ġ 0 , Ġcallback ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ . set Negative Button ( R . string . delete ) Ġ{ Ġ_, Ġ_ Ġ-> Ċĉĉĉĉ ĉ S ick R age Api . instance . services ?. delete Show ( indexer Id , Ġ 1 , Ġcallback ) Ċĉĉĉ ĉ } Ċĉĉĉ ĉ . set Neutral Button ( R . string . cancel , Ġnull ) Ċĉĉĉ ĉ . show () Ċ ĉ } ĊĊ ĉ private Ġfun Ġget Translated Qual ities ( qual ities : ĠRealm List < String > ?, Ġallowed : ĠBoolean ): ĠList < String > Ġ{ Ċĉ ĉ val Ġtranslated Qual ities Ġ= Ġmutable ListOf < String >() ĊĊĉ ĉ if Ġ( qual ities Ġ== Ġnull Ġ|| Ġqual ities . isEmpty ()) Ġ{ Ċĉĉ ĉ return Ġtranslated Qual ities Ċĉ ĉ } ĊĊĉ ĉ val Ġkeys Ġ= Ġif Ġ( allowed ) Ġ{ Ċĉĉ ĉ resources . getString Array ( R . array . allowed _ qual ities _ keys ). toList () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ resources . getString Array ( R . array . allowed _ qual ities _ keys ). toList () Ċĉ ĉ } Ċĉ ĉ val Ġvalues Ġ= Ġif Ġ( allowed ) Ġ{ Ċĉĉ ĉ resources . getString Array ( R . array . allowed _ qual ities _ values ). toList () Ċĉ ĉ } Ġelse Ġ{ Ċĉĉ ĉ resources . getString Array ( R . array . allowed _ qual ities _ values ). toList () Ċĉ ĉ } ĊĊĉ ĉ qual ities . forEach Ġ{ Ċĉĉ ĉ val Ġposition Ġ= Ġkeys . indexOf ( it ) ĊĊĉĉ ĉ if Ġ( position Ġ!= Ġ- 1 ) Ġ{ Ċĉĉĉ ĉ // ĠSkip Ġthe Ġ" Ignore " Ġfirst Ġitem Ċĉĉĉ ĉ translated Qual ities . add ( values [ position Ġ+ Ġ 1 ]) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ return Ġtranslated Qual ities Ċ ĉ } ĊĊ ĉ private Ġfun Ġpause Or Resume Show ( pause : ĠBoolean ) Ġ{ Ċĉ ĉ this . show Hide Pause Resume Menus (! pause ) ĊĊĉ ĉ S ick R age Api . instance . services ?. pause Show ( this . indexer Id , Ġpause . toInt (), Ġobject Ġ: ĠGeneric Callback ( this . activity ) Ġ{ Ċĉĉ ĉ override Ġfun Ġfailure ( error : ĠRet rofit Error ?) Ġ{ Ċĉĉĉ ĉ super . failure ( error ) ĊĊĉĉĉ ĉ show Hide Pause Resume Menus ( pause ) Ċĉĉ ĉ } Ċĉ ĉ }) Ċ ĉ } ĊĊ ĉ private Ġfun Ġre scan Show () Ġ{ Ċĉ ĉ S ick R age Api . instance . services ?. re scan Show ( this . indexer Id , ĠGeneric Callback ( this . activity )) Ċ ĉ } ĊĊ ĉ private Ġfun Ġshow Hide Pause Resume Menus ( is Pause : ĠBoolean ) Ġ{ Ċĉ ĉ this . pause Menu ?. isVisible Ġ= Ġis Pause Ċĉ ĉ this . resume Menu ?. isVisible Ġ= Ġ! is Pause Ċ ĉ } ĊĊ ĉ private Ġfun Ġupdate Show () Ġ{ Ċĉ ĉ S ick R age Api . instance . services ?. update Show ( this . indexer Id , ĠGeneric Callback ( this . activity )) Ċ ĉ } ĊĊ ĉ private Ġclass ĠDelete Show Callback ( activity : ĠFragment Activity , Ġval Ġindexer Id : ĠInt ) Ġ: ĠGeneric Callback ( activity ) Ġ{ Ċĉ ĉ override Ġfun Ġsuccess ( generic Response : ĠGeneric Response ?, Ġresponse : ĠResponse ?) Ġ{ Ċĉĉ ĉ super . success ( generic Response , Ġresponse ) ĊĊĉĉ ĉ Realm . getDefaultInstance (). use Ġ{ Ċĉĉĉ ĉ it . delete Show ( this . indexer Id ) Ċĉĉ ĉ } ĊĊĉĉ ĉ val Ġactivity Ġ= Ġthis . getActivity () Ġ?: Ġreturn Ċĉĉ ĉ val Ġintent Ġ= ĠIntent ( activity , ĠMainActivity :: class . java ) ĊĊĉĉ ĉ activity . startActivity ( intent ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġclass ĠService Connection ( fragment : ĠShow Overview Fragment ) Ġ: ĠCustom Tabs Service Connection () Ġ{ Ċĉ ĉ private Ġval Ġfragment Reference Ġ= ĠWeak Reference ( fragment ) ĊĊĉ ĉ override Ġfun Ġon Custom Tabs Service Connected ( component Name : ĠComponent Name ?, Ġcustom Tabs Client : ĠCustom Tabs Client ?) Ġ{ Ċĉĉ ĉ custom Tabs Client ?. warm up ( 0 L ) ĊĊĉĉ ĉ val Ġfragment Ġ= Ġthis . fragment Reference . get () Ġ?: Ġreturn Ċĉĉ ĉ fragment . tab Session Ġ= Ġcustom Tabs Client ?. new Session ( null ) ĊĊĉĉ ĉ if Ġ( fragment . show . isValid ) Ġ{ Ċĉĉĉ ĉ fragment . tab Session ?. may Launch Url ( Uri . parse (" http :// www . imdb . com / title /${ fragment . show . imdb Id } "), Ġnull , Ġnull ) Ċĉĉĉ ĉ fragment . tab Session ?. may Launch Url ( Uri . parse (" http :// the tv db . com /? tab = series & id =${ fragment . show . tv Db Id } "), Ġnull , Ġnull ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ override Ġfun Ġon Service Disconnected ( name : ĠComponent Name ?) Ġ{ Ċĉĉ ĉ this . fragment Reference . clear () Ċĉ ĉ } Ċ ĉ } Ċ } Ċ