Closed imlutr closed 5 years ago
Thanks for reporting :) I'll check that, and I'll let you know.
It may be some gdxfireapp API<>KOTLIN related problem because Long value reading should work fine
Hello, I've checked that and that method causes the problem in your case:
public static boolean isJavaCoreClass(Class<?> type) {
return type.getName().startsWith("java");
}
It looks like it returns false for Long ... and API thinks that you put some POJO class (not java core class) as wanted data type - readValue method argument.
So, it looks like something is wrong with Kotlin->Java transformation, I also checked if read Long value works on Java - and it works.
Could you check how the compiled Java code looks like?
oookay :) I think I found the problem, take a look here: https://pl.kotl.in/Wur_3CkLd
Long::class.java.getName() returns "long" in Kotlin, without package name String::class.java.getName() returns "java.lang.String" - same as Java
okay, so I've pushed FIX for that, please looking forward to version 2.1.3
Yup! That was it! Sorry for not replying about the compiled Java code, I just got home :).
The following code now works:
GdxFIRDatabase.inst()
.inReference("number")
.readValue(java.lang.Long::class.java)
.then(
Consumer {
println("$it")
}
)
(replacing readValue(Long::class.java)
with readValue(java.lang.Long::class.java)
)
Thanks! ❤️
💪 💪 💪 great :)
anyway, I've adopted API to recognize kotlin names as well - but it is still building ... high traffic at Travis :)
Describe the bug I am trying to read a number (Long) from my Firebase Realtime Database on Android in my Kotlin+libGDX game, but I get always an exception.
To Reproduce Here is how the database looks like:
Here is the code:
The following exception is thrown:
If I replace the
Long
with any other class, such asString
(so.readValue(Long::class.java)
would become.readValue(String::class.java)
), while still reading the same number, without modifying the database, I'll get the following exception:Which would mean that what I am getting from the database really is a
Long
(I guess).However, the following (reading a
String
) works just fine:Expected behavior I'd expect to be able to read both
Strings
andLongs
, not onlyStrings
.Platform:
Smartphone: