From ec36cd4be8b07ba32055e607f9ff7e52b18bcca0 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Mon, 6 Nov 2023 15:11:28 +0100 Subject: [PATCH 1/3] refactor: simplify method --- .../com/parsely/parselyandroid/LocalStorageRepository.kt | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/parsely/src/main/java/com/parsely/parselyandroid/LocalStorageRepository.kt b/parsely/src/main/java/com/parsely/parselyandroid/LocalStorageRepository.kt index dcabe195..1f4f903b 100644 --- a/parsely/src/main/java/com/parsely/parselyandroid/LocalStorageRepository.kt +++ b/parsely/src/main/java/com/parsely/parselyandroid/LocalStorageRepository.kt @@ -73,13 +73,7 @@ internal open class LocalStorageRepository(private val context: Context) { @Synchronized open fun persistQueue(inMemoryQueue: List?>) { ParselyTracker.PLog("Persisting event queue") - val storedQueue = getStoredQueue() - val hs = HashSet?>() - hs.addAll(storedQueue) - hs.addAll(inMemoryQueue) - storedQueue.clear() - storedQueue.addAll(hs) - persistObject(storedQueue) + persistObject((inMemoryQueue + getStoredQueue()).distinct()) } companion object { From 3034d23447beb0da6f83db9467f79690198e7022 Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Mon, 6 Nov 2023 15:22:03 +0100 Subject: [PATCH 2/3] style: add deprecation annotations --- .../src/main/java/com/parsely/parselyandroid/QueueManager.kt | 2 ++ .../test/java/com/parsely/parselyandroid/QueueManagerTest.kt | 1 + 2 files changed, 3 insertions(+) diff --git a/parsely/src/main/java/com/parsely/parselyandroid/QueueManager.kt b/parsely/src/main/java/com/parsely/parselyandroid/QueueManager.kt index 6a786cc1..59d5401b 100644 --- a/parsely/src/main/java/com/parsely/parselyandroid/QueueManager.kt +++ b/parsely/src/main/java/com/parsely/parselyandroid/QueueManager.kt @@ -2,11 +2,13 @@ package com.parsely.parselyandroid import android.os.AsyncTask +@Suppress("DEPRECATION") internal class QueueManager( private val parselyTracker: ParselyTracker, private val localStorageRepository: LocalStorageRepository ) : AsyncTask() { + @Deprecated("Deprecated in Java") override fun doInBackground(vararg params: Void?): Void? { // if event queue is too big, push to persisted storage if (parselyTracker.inMemoryQueue.size > QUEUE_SIZE_LIMIT) { diff --git a/parsely/src/test/java/com/parsely/parselyandroid/QueueManagerTest.kt b/parsely/src/test/java/com/parsely/parselyandroid/QueueManagerTest.kt index 2bb00887..86613295 100644 --- a/parsely/src/test/java/com/parsely/parselyandroid/QueueManagerTest.kt +++ b/parsely/src/test/java/com/parsely/parselyandroid/QueueManagerTest.kt @@ -11,6 +11,7 @@ import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.LooperMode import org.robolectric.shadows.ShadowLooper.shadowMainLooper +@Suppress("DEPRECATION") @RunWith(RobolectricTestRunner::class) @LooperMode(LooperMode.Mode.PAUSED) internal class QueueManagerTest { From 1b8ffca4719f7eded1ba1222a9f0fade8b133b5a Mon Sep 17 00:00:00 2001 From: Wojtek Zieba Date: Mon, 6 Nov 2023 15:46:41 +0100 Subject: [PATCH 3/3] docs: update coordinates to STORAGE_SIZE_LIMIT const --- .../main/java/com/parsely/parselyandroid/ParselyTracker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/parsely/src/main/java/com/parsely/parselyandroid/ParselyTracker.java b/parsely/src/main/java/com/parsely/parselyandroid/ParselyTracker.java index e4d61c2f..609ed087 100644 --- a/parsely/src/main/java/com/parsely/parselyandroid/ParselyTracker.java +++ b/parsely/src/main/java/com/parsely/parselyandroid/ParselyTracker.java @@ -411,7 +411,7 @@ public void resetVideo() { * Place a data structure representing the event into the in-memory queue for later use. *

* **Note**: Events placed into this queue will be discarded if the size of the persistent queue - * store exceeds {@link #STORAGE_SIZE_LIMIT}. + * store exceeds {@link QueueManager#STORAGE_SIZE_LIMIT}. * * @param event The event Map to enqueue. */