-
Notifications
You must be signed in to change notification settings - Fork 104
Unable to get it working with Kotlin #43
Description
Im using kotlin and have been following the guide in the readme.
Problem 1
I came across the section below in the readme and i cannot get it to work.
class BookCell(item: Book) : SimpleCell<Book>(item) {
override fun getLayoutRes(): Int {
return R.layout.cell_book
}
override fun onBindViewHolder(holder: SimpleViewHolder, position: Int, context: Context, payload: Any) {
holder.textView.text = item.title
}
}
Android Studio does not recognize textView in this line:
holder.textView.text = item.title
I did create the layout file and have a textView with the matching Id so im not sure whats going on.
I was under the impression that maybe you were doing some sort of compile time generation to generate the holder to be used based off of the layout file, but that cant be because com.jaychang.srv.kae.SimpleCell uses SimpleViewHolder explicitly which only extends com.jaychang.srv.SimpleViewHolder.
Problem 2
Cant create list of SimpleCell type in kotlin that is shown in the Multiple Types section of the readme.
List<Book> books = DataUtils.getBooks();
List<Ad> ads = DataUtils.getAds();
List<SimpleCell> cells = new ArrayList<>();
My version, In Kotlin
val books:MutableList<Book> = DataUtils.getBooks();
val ads:MutableList<Ad> = DataUtils.getAds();
val cells:MutableList<SimpleCell> = mutableListOf()
Android Studio is complaining about SimpleCell in the list declaration ( MutableList<SimpleCell> ) stating that I must add the Type argument.
One type argument expected for class SimpleCell<T>
I am very confused and would greatly appreciate it if you could provide a more detailed guide for using this library with kotlin and perhaps several kotlin example activities in the source.
I suppose for the time being i can write this in java but that also means other areas of my app that are already in kotlin will have to be converted back to java, which is a bummer. :(