Fix reloading

This commit is contained in:
J-Jamet
2021-03-10 13:46:15 +01:00
parent 383437a3c7
commit a3a517ff89
3 changed files with 18 additions and 3 deletions

View File

@@ -346,9 +346,7 @@ class GroupActivity : LockingActivity(),
ACTION_DATABASE_RELOAD_TASK -> {
// Reload the current activity
if (result.isSuccess) {
startActivity(intent)
finish()
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
reload()
} else {
this.showActionErrorIfNeeded(result)
finish()
@@ -367,6 +365,14 @@ class GroupActivity : LockingActivity(),
Log.i(TAG, "Finished creating tree")
}
private fun reload() {
// Reload the current activity
startActivity(intent)
finish()
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
mDatabase?.wasReloaded = false
}
override fun onNewIntent(intent: Intent?) {
super.onNewIntent(intent)
@@ -891,6 +897,9 @@ class GroupActivity : LockingActivity(),
override fun onResume() {
super.onResume()
if (mDatabase?.wasReloaded == true) {
reload()
}
// Show the lock button
lockView?.visibility = if (PreferencesUtil.showLockDatabaseButton(this)) {
View.VISIBLE

View File

@@ -39,6 +39,7 @@ class ReloadDatabaseRunnable(private val context: Context,
tempCipherKey = mDatabase.loadedCipherKey
// Clear before we load
mDatabase.clear(UriUtil.getBinaryDir(context))
mDatabase.wasReloaded = true
}
override fun onActionRun() {

View File

@@ -77,6 +77,11 @@ class Database {
loadTimestamp = if (field) System.currentTimeMillis() else null
}
/**
* To reload the main activity
*/
var wasReloaded = true
var loadTimestamp: Long? = null
private set