package Ġru . ale shi . let sp lay cities . ui . theme Ċ Ċ import Ġandroid . os . Bundle Ċ import Ġandroid . view . View Ċ import Ġandroidx . fragment . app . Fragment Ċ import Ġandroidx . recyclerview . widget . Linear LayoutManager Ċ import Ġdagger . android . support . Android Support Injection Ċ import Ġkotlinx . android . synt hetic . main . fragment _ blacklist .* Ċ import Ġru . ale shi . let sp lay cities . Bad Token Exception Ċ import Ġru . ale shi . let sp lay cities . R Ċ import Ġru . ale shi . let sp lay cities . base . Game Preferences Ċ import Ġru . ale shi . let sp lay cities . base . Theme Manager Ċ import Ġru . ale shi . let sp lay cities . base . Theme Manager . test 2 Ċ import Ġru . ale shi . let sp lay cities . billing . In App Purchase Manager Ċ import Ġru . ale shi . let sp lay cities . billing . Purchase Listener Ċ import Ġru . ale shi . let sp lay cities . social . Ach ievement Ċ import Ġru . ale shi . let sp lay cities . social . Ach ievement Service Ċ import Ġru . ale shi . let sp lay cities . utils . Utils . apply Theme Ċ import Ġjavax . inject . Inject Ċ Ċ /** Ċ Ġ* ĠFragment Ġthat Ġshows Ġlist Ġof Ġgame Ġthemes Ġand Ġprovides Ġfunctions Ġfor Ġswitching Ġand Ġpurch asing Ġthemes . Ċ Ġ*/ Ċ class ĠTheme Fragment Ġ: ĠFragment ( R . layout . fragment _ theme ), ĠTheme ItemClickListener , ĠPurchase Listener Ġ{ ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġprefs : ĠGame Preferences ĊĊĠĠĠ Ġ@ Inject ĊĠĠĠ Ġlateinit Ġvar Ġach ievement Service : ĠA ch ievement Service ĊĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm Theme ListAdapter : ĠTheme ListAdapter ĊĠĠĠ Ġprivate Ġlateinit Ġvar Ġm In App Purchase Manager : ĠIn App Purchase Manager ĊĊĠĠĠ Ġoverride Ġfun ĠonCreate ( savedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ ĠAndroid Support Injection . inject ( this ) ĊĠĠĠĠĠĠĠ Ġsuper . onCreate ( savedInstanceState ) ĊĠĠĠĠĠĠĠ Ġm In App Purchase Manager Ġ= ĠIn App Purchase Manager ( require Activity (), Ġthis ) ĊĠĠĠĠĠĠĠ Ġm In App Purchase Manager . start Connection () ĊĊĠĠĠĠĠĠĠ Ġ// Test Ġfor Ġcr ack ing Ġthemes ĊĠĠĠĠĠĠĠ Ġif Ġ( test 2 ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġthrow ĠBad Token Exception () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠBad Token Exception ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġe . printStackTrace () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġandroid . os . Process . kill Process ( android . os . Process . my Pid ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠTheme Manager . check Available ( prefs ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon View Created ( view : ĠView , ĠsavedInstanceState : ĠBundle ?) Ġ{ ĊĠĠĠĠĠĠĠ Ġm Theme ListAdapter Ġ= ĠTheme ListAdapter ( get Themes List (), Ġthis ) ĊĠĠĠĠĠĠĠ Ġre cyclerView . apply Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġlayout Manager Ġ= ĠLinearLayoutManager ( require Context ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġadapter Ġ= Ġm Theme ListAdapter ĊĠĠĠĠĠĠĠĠĠĠĠ Ġset Has Fixed Size ( true ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Destroy () Ġ{ ĊĠĠĠĠĠĠĠ Ġsuper . on Destroy () ĊĠĠĠĠĠĠĠ Ġm In App Purchase Manager . destroy () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Unlock ( theme : ĠTheme ListAdapter . Named Theme ) Ġ{ ĊĠĠĠĠĠĠĠ Ġm In App Purchase Manager . launch Billing Flow ( theme . theme . sku !! ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġon Purchase d ( productId : ĠString , Ġpurchase Token : ĠString , Ġsignature : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ ĠTheme Manager . put Theme ( prefs , ĠproductId , Ġpurchase Token , Ġsignature ) ĊĠĠĠĠĠĠĠ Ġapply Theme () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun ĠonSelect Theme ( named Theme : ĠTheme ListAdapter . Named Theme ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( named Theme . theme . is Free Or Available ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠTheme Manager . save Current Theme ( prefs , Ġnamed Theme . theme ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġapply Theme () ĊĠĠĠĠĠĠĠ Ġ} Ġelse ĊĠĠĠĠĠĠĠĠĠĠĠ Ġon Unlock ( named Theme ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġapply Theme () Ġ{ ĊĠĠĠĠĠĠĠ Ġach ievement Service . unlock Ach ievement ( Ach ievement . Change Theme ) ĊĠĠĠĠĠĠĠ Ġapply Theme ( prefs , Ġrequire Context ()) ĊĠĠĠĠĠĠĠ Ġrequire Activity (). re create () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġget Themes List (): ĠArray < Theme ListAdapter . Named Theme > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġtheme Names Ġ= Ġresources . getString Array ( R . array . themes ) ĊĠĠĠĠĠĠĠ Ġval Ġthemes Ġ= ĠTheme Manager . themes ĊĠĠĠĠĠĠĠ Ġreturn ĠArray ( themes . size ) Ġ{ ĠTheme ListAdapter . Named Theme ( theme Names [ it ], Ġthemes [ it ]) Ġ} ĊĠĠĠ Ġ} Ċ Ċ }