From e1c46cf1dc9669c4a2ddd373a284b9d0444377c7 Mon Sep 17 00:00:00 2001 From: Mansi Pandya Date: Wed, 30 Oct 2024 17:07:19 -0400 Subject: [PATCH] Address review comments --- .../com/mparticle/internal/AppStateManager.kt | 8 ++------ .../internal/ApplicationContextWrapper.kt | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/android-core/src/main/kotlin/com/mparticle/internal/AppStateManager.kt b/android-core/src/main/kotlin/com/mparticle/internal/AppStateManager.kt index f49c9e721..eba0118f6 100644 --- a/android-core/src/main/kotlin/com/mparticle/internal/AppStateManager.kt +++ b/android-core/src/main/kotlin/com/mparticle/internal/AppStateManager.kt @@ -125,9 +125,7 @@ open class AppStateManager @JvmOverloads constructor( if (launchAction == null) { launchAction = activity.intent.action } - if (activity.intent.extras != null && activity.intent.extras!! - .getBundle(Constants.External.APPLINK_KEY) != null - ) { + if (activity.intent.extras?.getBundle(Constants.External.APPLINK_KEY) != null) { val parameters = JSONObject() try { parameters.put( @@ -238,7 +236,6 @@ open class AppStateManager @JvmOverloads constructor( if (!mInitialized) { initialize(null, null, null, null) } - val session = session session.mLastEventTime = System.currentTimeMillis() if (!session.isActive) { newSession() @@ -301,7 +298,6 @@ open class AppStateManager @JvmOverloads constructor( } fun shouldEndSession(): Boolean { - val session = session val instance = MParticle.getInstance() return ( 0L != session?.mSessionStartTime && @@ -428,7 +424,7 @@ open class AppStateManager @JvmOverloads constructor( MPUtility.getAdIdInfo(MParticle.getInstance()?.Internal()?.appStateManager?.mContext) val currentAdId = (if (adIdInfo == null) null else (if (adIdInfo.isLimitAdTrackingEnabled) null else adIdInfo.id)) - val previousAdId = configManager!!.previousAdId + val previousAdId = configManager?.previousAdId if (currentAdId != null && currentAdId != previousAdId) { val instance = MParticle.getInstance() if (instance != null) { diff --git a/android-core/src/main/kotlin/com/mparticle/internal/ApplicationContextWrapper.kt b/android-core/src/main/kotlin/com/mparticle/internal/ApplicationContextWrapper.kt index 33f43c4aa..906200147 100644 --- a/android-core/src/main/kotlin/com/mparticle/internal/ApplicationContextWrapper.kt +++ b/android-core/src/main/kotlin/com/mparticle/internal/ApplicationContextWrapper.kt @@ -278,19 +278,18 @@ open class ApplicationContextWrapper(private val mBaseApplication: Application) @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) override fun run() { if (callback != null && mActivityLifecycleCallbackRecorder != null && isReplayActivityLifecycle) { - val reference = if (MParticle.getInstance()!! - .Internal().kitManager == null + val reference = if (MParticle.getInstance()?.Internal()?.kitManager == null ) { null } else { - MParticle.getInstance()!! - .Internal().kitManager.currentActivity + MParticle.getInstance()?.Internal()?.kitManager?.currentActivity } if (reference != null) { val currentActivity = reference.get() if (currentActivity != null) { val recordedLifecycleList: LinkedList = - mActivityLifecycleCallbackRecorder!!.recordedLifecycleListCopy + mActivityLifecycleCallbackRecorder?.recordedLifecycleListCopy + ?: LinkedList() while (recordedLifecycleList.size > 0) { val lifeCycleEvent = recordedLifecycleList.removeFirst() if (lifeCycleEvent.activityRef != null) { @@ -323,10 +322,12 @@ open class ApplicationContextWrapper(private val mBaseApplication: Application) MethodType.ON_SAVE_INSTANCE_STATE -> { Logger.debug("Forwarding OnSaveInstance") - callback.onActivitySaveInstanceState( - recordedActivity, - lifeCycleEvent.bundle!! - ) + lifeCycleEvent.bundle?.let { + callback.onActivitySaveInstanceState( + recordedActivity, + it + ) + } } MethodType.ON_STOPPED -> {