Created
February 16, 2020 16:04
-
-
Save jraska/39997a1ce0bab07b9e89499a390b8baa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PushCallbacks( | |
val pushStream: PushStream | |
) : Application.ActivityLifecycleCallbacks, PushStream.OnPush { | |
private var foregroundActivity: Activity? = null | |
override fun onActivityResumed(activity: Activity) { | |
foregroundActivity = activity | |
pushStream.register(this) | |
} | |
override fun onActivityPaused(activity: Activity) { | |
pushStream.unregister(this) | |
foregroundActivity = null | |
} | |
override fun onPush(push: PushMessage) { | |
foregroundActivity?.let { showMessage(it, push) } | |
} | |
private fun showMessage(activity: Activity, pushMessage: PushMessage) { ... } | |
// Other methods are empty | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment