Optimization change

- Spawning a new thread only when actually purging the database
This commit is contained in:
Nelson R. Perez 2019-11-07 15:37:32 -05:00
parent 5e4a82a7f6
commit 2ef589526d

View file

@ -179,12 +179,13 @@ abstract class ConnectedActivity : AppCompatActivity(), ServiceConnection {
})
mCompositeDisposable.add(disposable)
thread {
val info = this.packageManager.getPackageInfo(this.packageName, PackageManager.GET_ACTIVITIES)
val versionCode = PackageInfoCompat.getLongVersionCode(info)
val hasPurgedEquivalentValues = PreferenceManager.getDefaultSharedPreferences(this)
.getBoolean(Constants.KEY_HAS_PURGED_EQUIVALENT_VALUES, false)
if(versionCode > 11 && !hasPurgedEquivalentValues) {
thread {
mConnectedActivityViewModel.purgeEquivalentValues()
PreferenceManager.getDefaultSharedPreferences(this)
.edit()