From a1f3c73365408635e8bbd2d2d1681f4c0f4caa8f Mon Sep 17 00:00:00 2001 From: Thomas Horta Date: Wed, 29 May 2024 17:48:12 -0300 Subject: [PATCH] Increase Cursor Window Size to 20mb to load larger posts --- .../org/wordpress/android/WellSqlInitializer.kt | 0 .../java/org/wordpress/android/WPWellSqlConfig.kt | 14 ++++++++++++++ .../org/wordpress/android/WellSqlInitializer.kt | 15 --------------- 3 files changed, 14 insertions(+), 15 deletions(-) rename WordPress/src/{debug => main}/java/org/wordpress/android/WellSqlInitializer.kt (100%) create mode 100644 WordPress/src/release/java/org/wordpress/android/WPWellSqlConfig.kt delete mode 100644 WordPress/src/release/java/org/wordpress/android/WellSqlInitializer.kt diff --git a/WordPress/src/debug/java/org/wordpress/android/WellSqlInitializer.kt b/WordPress/src/main/java/org/wordpress/android/WellSqlInitializer.kt similarity index 100% rename from WordPress/src/debug/java/org/wordpress/android/WellSqlInitializer.kt rename to WordPress/src/main/java/org/wordpress/android/WellSqlInitializer.kt diff --git a/WordPress/src/release/java/org/wordpress/android/WPWellSqlConfig.kt b/WordPress/src/release/java/org/wordpress/android/WPWellSqlConfig.kt new file mode 100644 index 000000000000..0c9b384f50b2 --- /dev/null +++ b/WordPress/src/release/java/org/wordpress/android/WPWellSqlConfig.kt @@ -0,0 +1,14 @@ +package org.wordpress.android + +import android.content.Context +import org.wordpress.android.fluxc.persistence.WellSqlConfig + +class WPWellSqlConfig(context: Context) : WellSqlConfig(context) { + /** + * Increase the cursor window size to 20MB for devices running API 28 and above. This should reduce the + * number of SQLiteBlobTooBigExceptions. Note that this is only called on API 28 and + * above since earlier versions don't allow adjusting the cursor window size. + */ + @Suppress("MagicNumber") + override fun getCursorWindowSize() = (1024L * 1024L * 20L) +} diff --git a/WordPress/src/release/java/org/wordpress/android/WellSqlInitializer.kt b/WordPress/src/release/java/org/wordpress/android/WellSqlInitializer.kt deleted file mode 100644 index d33fcb9d1de3..000000000000 --- a/WordPress/src/release/java/org/wordpress/android/WellSqlInitializer.kt +++ /dev/null @@ -1,15 +0,0 @@ -package org.wordpress.android - -import android.content.Context -import com.yarolegovich.wellsql.WellSql -import org.wordpress.android.fluxc.persistence.WellSqlConfig -import javax.inject.Inject -import javax.inject.Singleton - -@Singleton -class WellSqlInitializer @Inject constructor(private val context: Context) { - fun init() { - val wellSqlConfig = WellSqlConfig(context) - WellSql.init(wellSqlConfig) - } -}