Skip to content

Commit

Permalink
refactor: Migrate MPLifecycleCallbackDelegate and MPLocationListener …
Browse files Browse the repository at this point in the history
…class to Kotlin (#506)
  • Loading branch information
Mansi-mParticle authored Sep 18, 2024
1 parent 0d59318 commit 687e623
Show file tree
Hide file tree
Showing 7 changed files with 65 additions and 98 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.mparticle.internal

import android.annotation.TargetApi
import android.app.Activity
import android.app.Application.ActivityLifecycleCallbacks
import android.os.Build
import android.os.Bundle

/**
* This class is used by the AppStateManager to determine when the app is visible or in the background.
*
* Separated into its own class to avoid annoying logcat messages on pre-ICS devices.
*/
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
internal class MPLifecycleCallbackDelegate(private val mStateManager: AppStateManager) :
ActivityLifecycleCallbacks {
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
mStateManager.onActivityCreated(activity, savedInstanceState)
}

override fun onActivityStarted(activity: Activity) {
mStateManager.onActivityStarted(activity)
}

override fun onActivityResumed(activity: Activity) {
mStateManager.onActivityResumed(activity)
}

override fun onActivityPaused(activity: Activity) {
mStateManager.onActivityPaused(activity)
}

override fun onActivityStopped(activity: Activity) {
mStateManager.onActivityStopped(activity)
}

override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
mStateManager.onActivitySaveInstanceState(activity, outState)
}

override fun onActivityDestroyed(activity: Activity) {
mStateManager.onActivityDestroyed(activity)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.mparticle.internal

import android.location.Location
import android.location.LocationListener
import android.os.Bundle
import com.mparticle.MParticle

class MPLocationListener(private val mParticle: MParticle) : LocationListener {
override fun onLocationChanged(location: Location) {
mParticle.setLocation(location)
}

override fun onStatusChanged(provider: String, status: Int, extras: Bundle) {
}

override fun onProviderEnabled(provider: String) {
}

override fun onProviderDisabled(provider: String) {
}
}

0 comments on commit 687e623

Please sign in to comment.