-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Migrate MPLifecycleCallbackDelegate and MPLocationListener …
…class to Kotlin (#506)
- Loading branch information
1 parent
0d59318
commit 687e623
Showing
7 changed files
with
65 additions
and
98 deletions.
There are no files selected for viewing
56 changes: 0 additions & 56 deletions
56
android-core/src/main/java/com/mparticle/internal/MPLifecycleCallbackDelegate.java
This file was deleted.
Oops, something went wrong.
42 changes: 0 additions & 42 deletions
42
android-core/src/main/java/com/mparticle/internal/MPLocationListener.java
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
44 changes: 44 additions & 0 deletions
44
android-core/src/main/kotlin/com/mparticle/internal/MPLifecycleCallbackDelegate.kt
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
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) | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
android-core/src/main/kotlin/com/mparticle/internal/MPLocationListener.kt
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
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) { | ||
} | ||
} |