From afa520a68aacb1b5dccf591b8fe1c39424513f19 Mon Sep 17 00:00:00 2001 From: malteish Date: Fri, 12 Sep 2025 11:26:39 +0200 Subject: [PATCH] enable large collections through larger cursor window --- .../main/java/com/anthonyla/paperize/App.kt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/src/main/java/com/anthonyla/paperize/App.kt b/app/src/main/java/com/anthonyla/paperize/App.kt index 0d68e12..3dda95f 100644 --- a/app/src/main/java/com/anthonyla/paperize/App.kt +++ b/app/src/main/java/com/anthonyla/paperize/App.kt @@ -16,6 +16,24 @@ import java.lang.reflect.Field class App: Application() { override fun onCreate() { super.onCreate() + + // Increase CursorWindow size to handle large datasets + // Default is usually 2MB, increasing to 10MB + try { + val field: Field = CursorWindow::class.java.getDeclaredField("sCursorWindowSize") + field.isAccessible = true + field.set(null, 10 * 1024 * 1024) // 10MB + } catch (e: Exception) { + // Fallback for newer Android versions where field might be different + try { + val field: Field = CursorWindow::class.java.getDeclaredField("CURSOR_WINDOW_SIZE") + field.isAccessible = true + field.set(null, 10 * 1024 * 1024) // 10MB + } catch (e2: Exception) { + e2.printStackTrace() + } + } + val channel = NotificationChannel("wallpaper_service_channel", "Paperize", NotificationManager.IMPORTANCE_LOW) val notificationManager = getSystemService(NOTIFICATION_SERVICE) as NotificationManager notificationManager.createNotificationChannel(channel)