Fix StackOverflowError in SyncWorker chunked() extension
The custom chunked() extension function recursively called itself instead of using Kotlin's standard library chunked() method, causing StackOverflowError. Removed the buggy custom extension - Kotlin's List<T>.chunked() is already available in the standard library.
This commit is contained in:
@@ -91,7 +91,10 @@ class SyncWorker(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update last sync date
|
// Update last sync date
|
||||||
syncScheduler.pref s.edit()
|
applicationContext.getSharedPreferences(
|
||||||
|
SyncConfiguration.PREFS_NAME,
|
||||||
|
Context.MODE_PRIVATE
|
||||||
|
).edit()
|
||||||
.putLong(SyncConfiguration.PREF_LAST_SYNC_DATE, System.currentTimeMillis())
|
.putLong(SyncConfiguration.PREF_LAST_SYNC_DATE, System.currentTimeMillis())
|
||||||
.apply()
|
.apply()
|
||||||
|
|
||||||
@@ -262,10 +265,4 @@ data class Article(
|
|||||||
val content: String?
|
val content: String?
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* Extension function to chunk a list into batches
|
|
||||||
*/
|
|
||||||
fun <T> List<T>.chunked(size: Int): List<List<T>> {
|
|
||||||
require(size > 0) { "Chunk size must be positive, was: $size"}
|
|
||||||
return this.chunked(size)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user