amanda.hinchman-dominguez
11/07/2017, 2:41 AMamanda.hinchman-dominguez
11/07/2017, 2:41 AMScreen Shot 2017-11-06 at 9.41.32 PM.png▾
amanda.hinchman-dominguez
11/07/2017, 2:42 AMkastork
11/07/2017, 2:42 AMamanda.hinchman-dominguez
11/07/2017, 2:43 AMamanda.hinchman-dominguez
11/07/2017, 2:45 AMkastork
11/07/2017, 2:47 AMedvin
11/07/2017, 7:53 AMedvin
11/07/2017, 9:01 AMedvin
11/07/2017, 9:02 AMabhinay
11/07/2017, 9:06 AMedvin
11/07/2017, 9:07 AMcarlw
11/07/2017, 12:42 PMromainbsl
11/07/2017, 2:52 PMpublic class PersonJava {
private String name;
private String title;
// and so on...
}
class PersonJavaModel : ItemViewModel<PersonJava>() {
val name = bind { item?.observable(PersonJava::getName, PersonJava::setName) }
val title = bind { item?.observable(PersonJava::getTitle, PersonJava::setTitle) }
}
This works pretty well.
Now, I tried to do the same with a data class
data class PersonKotlin(var name: String? = null, var title: String? = null)
class PersonKotlinModel : ItemViewModel<PersonKotlin>() {
val name = bind { item?.observable(PersonKotlin::name) }
val title = bind { item?.observable(PersonKotlin::title) }
}
Here the bind function doesn't agree because my props are nullable.
But why does this work with POJOs ? they nullable too.
+ I tried to put the annotation @nullable on my POJO's props and this end with a compile exepction like with my data class, because my getters retrieve String? instead of String!, the type inference does its job here.
With my POJO I still can manipulate instances with null values in my UI and this works fine.
So why I cannot use nullable values with data classes and ItemViewModel ?jschneider
11/07/2017, 3:53 PMamanda.hinchman-dominguez
11/07/2017, 6:52 PMjelloranger
11/07/2017, 7:17 PMjelloranger
11/07/2017, 7:17 PMron
11/07/2017, 9:25 PMron
11/07/2017, 9:26 PMron
11/07/2017, 9:26 PMron
11/07/2017, 9:27 PMron
11/07/2017, 9:30 PMron
11/07/2017, 9:30 PMPasted image at 2017-11-07, 10:30 PM▾
ron
11/07/2017, 9:30 PMron
11/07/2017, 9:31 PMpike
11/07/2017, 11:40 PMcarlw
11/07/2017, 11:55 PMpike
11/07/2017, 11:56 PMcarlw
11/07/2017, 11:56 PM