Skip to content

Commit

Permalink
refactor: rewrite SdkInit to simple function
Browse files Browse the repository at this point in the history
  • Loading branch information
wzieba committed Nov 17, 2023
1 parent dbc73e1 commit 366dae5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,11 @@ protected ParselyTracker(String siteId, int flushInterval, Context c) {
timer = new Timer();
isDebug = false;

final SdkInit sdkInit = new SdkInit(ParselyCoroutineScopeKt.getSdkScope(), localStorageRepository, flushManager);
sdkInit.initialize();
SdkInitKt.initialize(
ParselyCoroutineScopeKt.getSdkScope(),
localStorageRepository,
flushManager
);

ProcessLifecycleOwner.get().getLifecycle().addObserver(
(LifecycleEventObserver) (lifecycleOwner, event) -> {
Expand Down
16 changes: 7 additions & 9 deletions parsely/src/main/java/com/parsely/parselyandroid/SdkInit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@ package com.parsely.parselyandroid
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch

internal class SdkInit(
private val scope: CoroutineScope,
private val localStorageRepository: LocalStorageRepository,
private val flushManager: FlushManager,
internal fun initialize(
scope: CoroutineScope,
localStorageRepository: LocalStorageRepository,
flushManager: FlushManager,
) {
fun initialize() {
scope.launch {
if (localStorageRepository.getStoredQueue().isNotEmpty()) {
flushManager.start()
}
scope.launch {
if (localStorageRepository.getStoredQueue().isNotEmpty()) {
flushManager.start()
}
}
}

0 comments on commit 366dae5

Please sign in to comment.