package Ġcom . m ga et an 8 9 . show sr age . fragment Ċ Ċ import Ġandroid . os . Bundle Ċ 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 . adapter . Episode Pager Adapter Ċ import Ġcom . m ga et an 8 9 . show sr age . extension . get Episode Sort Ċ 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 . Sort Ċ Ċ class ĠEp isode Fragment Ġ: ĠTab bed Fragment () Ġ{ Ċ ĉ private Ġval Ġepisode s Ġ= Ġmutable ListOf < Int >() ĊĊ ĉ override Ġfun Ġon Activity Created ( savedInstanceState : ĠBundle ?) Ġ{ Ċĉ ĉ super . on Activity Created ( savedInstanceState ) ĊĊĉ ĉ val Ġactivity Ġ= Ġthis . activity Ċĉ ĉ val Ġarguments Ġ= Ġthis . arguments ĊĊĉ ĉ if Ġ( activity Ġis ĠMainActivity ) Ġ{ Ċĉĉ ĉ activity . display Home As Up ( true ) Ċĉĉ ĉ activity . setTitle ( R . string . episode ) Ċĉ ĉ } ĊĊĉ ĉ if Ġ( arguments Ġ!= Ġnull ) Ġ{ Ċĉĉ ĉ val Ġepisode Number Ġ= Ġarguments . getInt ( Constants . Bundle . E PI SO DE _ NUMBER ) Ċĉĉ ĉ val Ġepisode s Count Ġ= Ġarguments . getInt ( Constants . Bundle . E PI SO DES _ COUNT ) ĊĊĉĉ ĉ for Ġ( i Ġin Ġepisode s Count Ġdown To Ġ 1 ) Ġ{ Ċĉĉĉ ĉ this . episodes . add ( i ) Ċĉĉ ĉ } ĊĊĉĉ ĉ val Ġascending Order Ġ= ĠSort . ASC ENDING Ġ== Ġactivity ?. get Preferences ()?. get Episode Sort () ĊĊĉĉ ĉ if Ġ( ascending Order ) Ġ{ Ċĉĉĉ ĉ this . episodes . reverse () Ċĉĉ ĉ } ĊĊĉĉ ĉ this . update State ( false ) Ċĉĉ ĉ this . select Tab ( if Ġ( ascending Order ) Ġepisode Number Ġ- Ġ 1 Ġelse Ġepisode s Count Ġ- Ġepisode Number ) Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ override Ġfun Ġon Destroy () Ġ{ Ċĉ ĉ this . episodes . clear () ĊĊĉ ĉ super . on Destroy () Ċ ĉ } ĊĊ ĉ override Ġfun Ġget Adapter () Ġ= ĠEp isode Pager Adapter ( this . child FragmentManager , Ġthis , Ġthis . episodes ) ĊĊ ĉ override Ġfun Ġuse Swipe To Refresh () Ġ= Ġfalse ĊĊ ĉ comp anion Ġobject Ġ{ Ċĉ ĉ fun Ġnew Instance ( episode Id : ĠString , Ġepisode Number : ĠInt , Ġepisode s Count : ĠInt , Ġseason Number : ĠInt , Ġindexer Id : ĠInt ) Ġ= ĠEp isode Fragment (). apply Ġ{ Ċĉĉ ĉ this . arguments Ġ= ĠBundle (). apply Ġ{ Ċĉĉĉ ĉ this . putString ( Constants . Bundle . E PI SO DE _ ID , Ġepisode Id ) Ċĉĉĉ ĉ this . put Int ( Constants . Bundle . E PI SO DE _ NUMBER , Ġepisode Number ) Ċĉĉĉ ĉ this . put Int ( Constants . Bundle . E PI SO DES _ COUNT , Ġepisode s Count ) Ċĉĉĉ ĉ this . put Int ( Constants . Bundle . SE ASON _ NUMBER , Ġseason Number ) Ċĉĉĉ ĉ this . put Int ( Constants . Bundle . INDEX ER _ ID , Ġindexer Id ) Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ } Ċ