|
|
|
|
@ -14,6 +14,8 @@ class Patcher { |
|
|
|
|
|
|
|
|
|
fun patchAll(context: Context) { |
|
|
|
|
|
|
|
|
|
patchMissingTransactionTypes(context) |
|
|
|
|
|
|
|
|
|
Preferences.executeOnce(Preferences.Keys.PATCH_BREAK, context) { |
|
|
|
|
patchBreaks() |
|
|
|
|
} |
|
|
|
|
@ -39,6 +41,28 @@ class Patcher { |
|
|
|
|
realm.close() |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun patchMissingTransactionTypes(context: Context) { |
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
|
|
val depositType = TransactionType.Value.DEPOSIT |
|
|
|
|
val deposit = realm.where(TransactionType::class.java).equalTo("kind", depositType.uniqueIdentifier).findFirst() |
|
|
|
|
if (deposit == null) { |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
Seed.createDefaultTransactionTypes(arrayOf(depositType), context, realm) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
val withdrawalType = TransactionType.Value.WITHDRAWAL |
|
|
|
|
val withdrawal = realm.where(TransactionType::class.java).equalTo("kind", withdrawalType.uniqueIdentifier).findFirst() |
|
|
|
|
if (withdrawal == null) { |
|
|
|
|
realm.executeTransaction { |
|
|
|
|
Seed.createDefaultTransactionTypes(arrayOf(withdrawalType), context, realm) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
realm.close() |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private fun patchBreaks() { |
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|