-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Android API and Kotlin syntax #11
Comments
Hi @TobseF, thank you for the compliments! :) That conversion you did was quite a feat! :o I'm not much of an Android or Kotlin programmer myself, so no, I have not had any plans to support either of them... I'm too fond of the Java 8 streams and Optionals to go back to Java 6 style of code. ;) Is there anything else I could do for you regarding the library? |
The library worked like a charm. The only confusing thing was, that I have to choose a style of setting a light. So if I set a light by color, I'm not able to also set the brightness. E.g. it's not possible to call: As a Kotlin fanboy I can only advice you to give it a try. I bet you will never switch back 馃槈 E.g. your loved Stream API: # Java
return Collections.unmodifiableCollection(this.sensors.values().stream()
.filter(s -> type.equals(s.getType()))
.map(sensorClass::cast)
.collect(toList())); VS # Kotlin
return this.sensors.values.filter { type == it.type }.map (sensorClass::cast) It's also complete typesafe. You will also receive e a unmodifiableCollection. And the "==" check also calls the And in Kotlin Optionals are completely obsolete, because you have to specify on every type, if it's nullable or not. You can never set a KOTLIN FANBLOCK END 馃榿 |
Yeah, well, how would setting both color and brightness even work? What should happen if you set a very dark color, such as The StateBuilder has been designed to protect the user from setting options that are contradictory, such as setting both the color (RGB value) and the hue (a value from 0 to 65280). It does still need some work, as I've previously noted here: #9 (comment) I suppose I do need to try Kotlin some day, maybe the next time I come up with a new project. ;) |
Hi @ZeroOne3010,
I needed a Philips HUE API lib for my Android App. Your
yetanotherhueapi
seemed to be a very good match. It's up to date, has a very good API, it's tested and it's available in the Maven central, Great 馃憤But to use it on Android it has the problem, that it uses
java.awt.Color
which is not available there. Although the Java 8 API seems to be improper in the point of a Kotlin program - e.G. usingOptionals
. And you are forced to use Androidapi level 26
to get Optionals to work - instead of6
.So I forked it and did a total to Kotlin conversation: yetanotherhueapi-kotlin
Do you have also plans to support Android or to migrate to Kotlin?
Best wishes,
Tobse
The text was updated successfully, but these errors were encountered: