SHARE
TWEET

Untitled

a guest Nov 14th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.swisscom.ngti.mycloud.apptentive
  2.  
  3.  
  4. import android.app.Activity
  5. import android.os.Bundle
  6. import androidx.annotation.Nullable
  7. import com.swisscom.ngti.mycloud.SplashActivity
  8. import com.swisscom.ngti.mycloud.utils.SimpleActivityLifecycleCallbacks
  9.  
  10. /**
  11.  * Extension of [SimpleActivityLifecycleCallbacks] that handles Apptentive related logic that should be executed on certain Activity lifecycle events
  12.  */
  13. class ApptentiveActivitiesMonitoree : SimpleActivityLifecycleCallbacks() {
  14.     private var pausedActivity: Activity? = null
  15.  
  16.     override fun onActivityCreated(activity: Activity, @Nullable savedInstanceState: Bundle?) {
  17.         if (savedInstanceState != null) return
  18.         if (activity !is IApptentiveActivity) return
  19.         ApptentiveUtils.reportEvent(activity.applicationContext, activity.getOnActivityCreateApptentiveEvent())
  20.     }
  21.  
  22.     override fun onActivityResumed(activity: Activity) {
  23.         if (pausedActivity != null && activity == pausedActivity) {
  24.             ApptentiveUtils.reportEvent(activity.applicationContext, EVENT_APP_OPENED)
  25.         }
  26.     }
  27.  
  28.     override fun onActivityPaused(activity: Activity) {
  29.         pausedActivity = activity
  30.     }
  31.  
  32.     override fun onActivityDestroyed(activity: Activity) {
  33.         if (activity is SplashActivity) {
  34.             ApptentiveUtils.reportEvent(activity.applicationContext, EVENT_APP_OPENED)
  35.         }
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top