-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvements to the number of instances used and memory allocation re…
…quired for Realm DB operations: 1. Number of Realm instances was growing uncontrollably due to not explicitly being closed at the end of a series of DB Operations in some places throughout the app. 2. Instead of creating two instances of DbWrapper and configuring them for Main DB and the one used for translations and distinguishing between them using @BundleDataDb annotation, now separate DbWrapperMain and DbWrapperBundle classes are used to eliminate a possibility of using a wrong instance. 3. Removing unnecessary child coroutine scopes that was used in SyncActions. Upping versionCode to 85
- Loading branch information
1 parent
ce38c78
commit e06afc0
Showing
61 changed files
with
324 additions
and
359 deletions.
There are no files selected for viewing
12 changes: 0 additions & 12 deletions
12
app/src/main/java/org/zotero/android/api/annotations/BundleDataDb.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 0 additions & 48 deletions
48
app/src/main/java/org/zotero/android/database/DbWrapper.kt
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
app/src/main/java/org/zotero/android/database/DbWrapperBundle.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.zotero.android.database | ||
|
||
import io.realm.RealmConfiguration | ||
import org.zotero.android.files.FileStore | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class DbWrapperBundle @Inject constructor( | ||
private val fileStore: FileStore | ||
) { | ||
|
||
lateinit var realmDbStorage: RealmDbStorage | ||
lateinit var config: RealmConfiguration | ||
|
||
fun initBundleDataConfiguration() { | ||
val dbFile = fileStore.bundledDataDbFile() | ||
this.config = Database.bundledDataConfiguration(dbFile) | ||
this.realmDbStorage = RealmDbStorage(config) | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
app/src/main/java/org/zotero/android/database/DbWrapperMain.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.zotero.android.database | ||
|
||
import io.realm.Realm | ||
import io.realm.RealmConfiguration | ||
import org.zotero.android.files.FileStore | ||
import javax.inject.Inject | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
class DbWrapperMain @Inject constructor( | ||
private val fileStore: FileStore | ||
) { | ||
lateinit var realmDbStorage: RealmDbStorage | ||
lateinit var config: RealmConfiguration | ||
var isInitialized = false | ||
|
||
fun initWithMainConfiguration(userId: Long) { | ||
val dbFile = fileStore.dbFile(userId) | ||
this.config = Database.mainConfiguration(dbFile = dbFile) | ||
this.realmDbStorage = RealmDbStorage(config = config) | ||
isInitialized = true | ||
} | ||
|
||
fun clearDatabaseFiles() { | ||
val realmInstance = Realm.getInstance(config) | ||
realmInstance.removeAllChangeListeners() | ||
realmInstance.executeTransaction { | ||
realmInstance.deleteAll() | ||
} | ||
realmInstance.close() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.