1 // Copyright 2015-present 650 Industries. All rights reserved. 2 package host.exp.exponent.kernel.services 3 4 import android.content.Context 5 import de.greenrobot.event.EventBus 6 import host.exp.exponent.experience.BaseExperienceActivity.ExperienceBackgroundedEvent 7 import host.exp.exponent.experience.BaseExperienceActivity.ExperienceForegroundedEvent 8 import host.exp.exponent.kernel.ExperienceKey 9 10 abstract class BaseKernelService(protected val context: Context) { 11 protected var currentExperienceKey: ExperienceKey? = null 12 private set 13 onExperienceForegroundednull14 abstract fun onExperienceForegrounded(experienceKey: ExperienceKey) 15 abstract fun onExperienceBackgrounded(experienceKey: ExperienceKey) 16 17 fun onEvent(event: ExperienceBackgroundedEvent) { 18 currentExperienceKey = null 19 onExperienceBackgrounded(event.experienceKey) 20 } 21 onEventnull22 fun onEvent(event: ExperienceForegroundedEvent) { 23 currentExperienceKey = event.experienceKey 24 onExperienceForegrounded(event.experienceKey) 25 } 26 27 init { 28 EventBus.getDefault().register(this) 29 } 30 } 31