mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-11-02 15:53:55 +01:00
use lateinit instead of nullable types
Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parent
d85a4269c5
commit
8d629b4305
2 changed files with 23 additions and 26 deletions
|
|
@ -68,33 +68,29 @@ import javax.inject.Named
|
||||||
)
|
)
|
||||||
|
|
||||||
class CommonsApplication : MultiDexApplication() {
|
class CommonsApplication : MultiDexApplication() {
|
||||||
@JvmField
|
|
||||||
@Inject
|
|
||||||
var sessionManager: SessionManager? = null
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Inject
|
@Inject
|
||||||
var dbOpenHelper: DBOpenHelper? = null
|
lateinit var sessionManager: SessionManager
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Inject
|
@Inject
|
||||||
@Named("default_preferences")
|
lateinit var dbOpenHelper: DBOpenHelper
|
||||||
var defaultPrefs: JsonKvStore? = null
|
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Inject
|
@Inject
|
||||||
var cookieJar: CommonsCookieJar? = null
|
@field:Named("default_preferences")
|
||||||
|
lateinit var defaultPrefs: JsonKvStore
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Inject
|
@Inject
|
||||||
var customOkHttpNetworkFetcher: CustomOkHttpNetworkFetcher? = null
|
lateinit var cookieJar: CommonsCookieJar
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
lateinit var customOkHttpNetworkFetcher: CustomOkHttpNetworkFetcher
|
||||||
|
|
||||||
|
//TODO [parry] not being used anywhere, remove after checking
|
||||||
var languageLookUpTable: AppLanguageLookUpTable? = null
|
var languageLookUpTable: AppLanguageLookUpTable? = null
|
||||||
private set
|
private set
|
||||||
|
|
||||||
@JvmField
|
|
||||||
@Inject
|
@Inject
|
||||||
var contributionDao: ContributionDao? = null
|
lateinit var contributionDao: ContributionDao
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to declare and initialize various components and dependencies
|
* Used to declare and initialize various components and dependencies
|
||||||
|
|
@ -112,13 +108,13 @@ class CommonsApplication : MultiDexApplication() {
|
||||||
|
|
||||||
initTimber()
|
initTimber()
|
||||||
|
|
||||||
if (!defaultPrefs!!.getBoolean("has_user_manually_removed_location")) {
|
if (!defaultPrefs.getBoolean("has_user_manually_removed_location")) {
|
||||||
var defaultExifTagsSet = defaultPrefs!!.getStringSet(Prefs.MANAGED_EXIF_TAGS)
|
var defaultExifTagsSet = defaultPrefs.getStringSet(Prefs.MANAGED_EXIF_TAGS)
|
||||||
if (null == defaultExifTagsSet) {
|
if (null == defaultExifTagsSet) {
|
||||||
defaultExifTagsSet = HashSet()
|
defaultExifTagsSet = HashSet()
|
||||||
}
|
}
|
||||||
defaultExifTagsSet.add(getString(R.string.exif_tag_location))
|
defaultExifTagsSet.add(getString(R.string.exif_tag_location))
|
||||||
defaultPrefs!!.putStringSet(Prefs.MANAGED_EXIF_TAGS, defaultExifTagsSet)
|
defaultPrefs.putStringSet(Prefs.MANAGED_EXIF_TAGS, defaultExifTagsSet)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set DownsampleEnabled to True to downsample the image in case it's heavy
|
// Set DownsampleEnabled to True to downsample the image in case it's heavy
|
||||||
|
|
@ -216,14 +212,14 @@ class CommonsApplication : MultiDexApplication() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionManager!!.logout()
|
sessionManager.logout()
|
||||||
.andThen(Completable.fromAction { cookieJar!!.clear() })
|
.andThen(Completable.fromAction { cookieJar.clear() })
|
||||||
.andThen(Completable.fromAction {
|
.andThen(Completable.fromAction {
|
||||||
Timber.d("All accounts have been removed")
|
Timber.d("All accounts have been removed")
|
||||||
clearImageCache()
|
clearImageCache()
|
||||||
//TODO: fix preference manager
|
//TODO: fix preference manager
|
||||||
defaultPrefs!!.clearAll()
|
defaultPrefs.clearAll()
|
||||||
defaultPrefs!!.putBoolean("firstrun", false)
|
defaultPrefs.putBoolean("firstrun", false)
|
||||||
updateAllDatabases()
|
updateAllDatabases()
|
||||||
})
|
})
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
|
|
@ -243,17 +239,17 @@ class CommonsApplication : MultiDexApplication() {
|
||||||
* Deletes all tables and re-creates them.
|
* Deletes all tables and re-creates them.
|
||||||
*/
|
*/
|
||||||
private fun updateAllDatabases() {
|
private fun updateAllDatabases() {
|
||||||
dbOpenHelper!!.readableDatabase.close()
|
dbOpenHelper.readableDatabase.close()
|
||||||
val db = dbOpenHelper!!.writableDatabase
|
val db = dbOpenHelper.writableDatabase
|
||||||
|
|
||||||
CategoryDao.Table.onDelete(db)
|
CategoryDao.Table.onDelete(db)
|
||||||
dbOpenHelper!!.deleteTable(
|
dbOpenHelper.deleteTable(
|
||||||
db,
|
db,
|
||||||
DBOpenHelper.CONTRIBUTIONS_TABLE
|
DBOpenHelper.CONTRIBUTIONS_TABLE
|
||||||
) //Delete the contributions table in the existing db on older versions
|
) //Delete the contributions table in the existing db on older versions
|
||||||
|
|
||||||
try {
|
try {
|
||||||
contributionDao!!.deleteAll()
|
contributionDao.deleteAll()
|
||||||
} catch (e: SQLiteException) {
|
} catch (e: SQLiteException) {
|
||||||
Timber.e(e)
|
Timber.e(e)
|
||||||
}
|
}
|
||||||
|
|
@ -361,6 +357,7 @@ class CommonsApplication : MultiDexApplication() {
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
//TODO should be uppercase
|
||||||
const val loginMessageIntentKey: String = "loginMessage"
|
const val loginMessageIntentKey: String = "loginMessage"
|
||||||
const val loginUsernameIntentKey: String = "loginUsername"
|
const val loginUsernameIntentKey: String = "loginUsername"
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -438,7 +438,7 @@ class UploadWorker(
|
||||||
username,
|
username,
|
||||||
)
|
)
|
||||||
CommonsApplication
|
CommonsApplication
|
||||||
.getInstance()
|
.instance!!
|
||||||
.clearApplicationData(appContext, logoutListener)
|
.clearApplicationData(appContext, logoutListener)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue