diff --git a/app/src/main/kotlin/jackall/moncalc/db/MonstDataRealmHelper.kt b/app/src/main/kotlin/jackall/moncalc/db/MonstDataRealmHelper.kt index c8ec1af..a996476 100644 --- a/app/src/main/kotlin/jackall/moncalc/db/MonstDataRealmHelper.kt +++ b/app/src/main/kotlin/jackall/moncalc/db/MonstDataRealmHelper.kt @@ -52,6 +52,36 @@ return results } + fun findIdByRank(realmModel: Class, rank: Int): Int { + when (realmModel) { + Temple::class.java -> { + return realm.where(realmModel).equalTo("rank", rank).findFirst().id + } + Fruit::class.java -> { + return realm.where(Temple::class.java).equalTo("rank", rank).findFirst().id + } + Grade::class.java -> { + return realm.where(Temple::class.java).equalTo("rank", rank).findFirst().id + } + } + return -1 + } + + fun findNameById(realmModel: Class, id: Int): String { + when (realmModel) { + Temple::class.java -> { + return realm.where(realmModel).equalTo("id", id).findFirst().name + } + Fruit::class.java -> { + return realm.where(Temple::class.java).equalTo("id", id).findFirst().name + } + Grade::class.java -> { + return realm.where(Temple::class.java).equalTo("id", id).findFirst().name + } + } + return "unknown" + } + fun close() { templeRealmHelper.close() fruitRealmHelper.close()