|
|
|
@ -7,7 +7,9 @@ import io.realm.RealmResults |
|
|
|
import io.realm.kotlin.where |
|
|
|
import io.realm.kotlin.where |
|
|
|
import net.pokeranalytics.android.model.Limit |
|
|
|
import net.pokeranalytics.android.model.Limit |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
import net.pokeranalytics.android.model.realm.* |
|
|
|
|
|
|
|
import net.pokeranalytics.android.model.realm.Currency |
|
|
|
import net.pokeranalytics.android.util.PokerAnalyticsLogs |
|
|
|
import net.pokeranalytics.android.util.PokerAnalyticsLogs |
|
|
|
|
|
|
|
import net.pokeranalytics.android.util.Preferences |
|
|
|
import timber.log.Timber |
|
|
|
import timber.log.Timber |
|
|
|
import java.util.* |
|
|
|
import java.util.* |
|
|
|
|
|
|
|
|
|
|
|
@ -72,6 +74,7 @@ class PokerAnalyticsApplication : Application() { |
|
|
|
|
|
|
|
|
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
val realm = Realm.getDefaultInstance() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Games |
|
|
|
val gamesName = resources.getStringArray(R.array.game_name) |
|
|
|
val gamesName = resources.getStringArray(R.array.game_name) |
|
|
|
val gamesShortName = resources.getStringArray(R.array.game_short_name) |
|
|
|
val gamesShortName = resources.getStringArray(R.array.game_short_name) |
|
|
|
if (realm.where<Game>().findAll().isEmpty()) { |
|
|
|
if (realm.where<Game>().findAll().isEmpty()) { |
|
|
|
@ -86,6 +89,7 @@ class PokerAnalyticsApplication : Application() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Tournament types |
|
|
|
val tournamentType = resources.getStringArray(R.array.tournament_type) |
|
|
|
val tournamentType = resources.getStringArray(R.array.tournament_type) |
|
|
|
if (realm.where<TournamentType>().findAll().isEmpty()) { |
|
|
|
if (realm.where<TournamentType>().findAll().isEmpty()) { |
|
|
|
realm.executeTransaction { |
|
|
|
realm.executeTransaction { |
|
|
|
@ -98,6 +102,29 @@ class PokerAnalyticsApplication : Application() { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Currency |
|
|
|
|
|
|
|
if (realm.where<Currency>().findAll().isEmpty()) { |
|
|
|
|
|
|
|
realm.executeTransaction { |
|
|
|
|
|
|
|
val localeCurrency = java.util.Currency.getInstance(Locale.getDefault()) |
|
|
|
|
|
|
|
val defaultCurrency = Currency() |
|
|
|
|
|
|
|
defaultCurrency.code = localeCurrency.currencyCode |
|
|
|
|
|
|
|
realm.copyToRealmOrUpdate(defaultCurrency) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Bankroll |
|
|
|
|
|
|
|
if (realm.where<Bankroll>().findAll().isEmpty()) { |
|
|
|
|
|
|
|
realm.executeTransaction { |
|
|
|
|
|
|
|
val localeCurrency = java.util.Currency.getInstance(Preferences.getCurrencyLocale(this)) |
|
|
|
|
|
|
|
val bankroll = Bankroll() |
|
|
|
|
|
|
|
bankroll.name = "Live" |
|
|
|
|
|
|
|
bankroll.live = true |
|
|
|
|
|
|
|
bankroll.currency = realm.where<Currency>().equalTo("code", localeCurrency.currencyCode).findFirst() |
|
|
|
|
|
|
|
realm.copyToRealmOrUpdate(bankroll) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test sessions |
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
if (BuildConfig.DEBUG) { |
|
|
|
val sessions = realm.where<Session>().findAll() |
|
|
|
val sessions = realm.where<Session>().findAll() |
|
|
|
if (sessions.size < 10) { |
|
|
|
if (sessions.size < 10) { |
|
|
|
|