mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Refactor CommonsApplicationModule to utilize application context
* Initialize and use application context directly * Utilize lateinit for application context
This commit is contained in:
parent
57078d670a
commit
7830bf2862
1 changed files with 9 additions and 1 deletions
|
|
@ -52,6 +52,11 @@ import javax.inject.Singleton
|
|||
@Module
|
||||
@Suppress("unused")
|
||||
open class CommonsApplicationModule(private val applicationContext: Context) {
|
||||
|
||||
init {
|
||||
appContext = applicationContext
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesImageFileLoader(context: Context): ImageFileLoader =
|
||||
ImageFileLoader(context)
|
||||
|
|
@ -244,6 +249,9 @@ open class CommonsApplicationModule(private val applicationContext: Context) {
|
|||
const val IO_THREAD: String = "io_thread"
|
||||
const val MAIN_THREAD: String = "main_thread"
|
||||
|
||||
lateinit var appContext: Context
|
||||
private set
|
||||
|
||||
val MIGRATION_1_2: Migration = object : Migration(1, 2) {
|
||||
override fun migrate(db: SupportSQLiteDatabase) {
|
||||
db.execSQL(
|
||||
|
|
@ -275,7 +283,7 @@ open class CommonsApplicationModule(private val applicationContext: Context) {
|
|||
"""
|
||||
)
|
||||
|
||||
val oldDbPath = "/data/user/0/fr.free.nrw.commons.beta/databases/commons.db"
|
||||
val oldDbPath = appContext.getDatabasePath("commons.db").path
|
||||
val oldDb = SQLiteDatabase.openDatabase(oldDbPath, null, SQLiteDatabase.OPEN_READONLY)
|
||||
|
||||
val cursor = oldDb.rawQuery("SELECT * FROM bookmarksLocations", null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue