janishar / PlaceHolderView

This library provides advance views for lists and stacks. Some of the views are build on top of RecyclerView and others are written in their own. Annotations are compiled by annotation processor to generate bind classes. DOCS -->
http://janishar.com/PlaceHolderView
Apache License 2.0
2.11k stars 367 forks source link

@View field is null #146

Closed satadii11 closed 4 years ago

satadii11 commented 5 years ago

Hey this is my code

@NonReusable
@Layout(R.layout.item_swipe_card)
class TinderCard(
    private val item: Interest
) {
    @View(R.id.sdvItemSwipeCard)
    @JvmField
    var ivInterest: SimpleDraweeView? = null
    @View(R.id.tvItemSwipeCard)
    @JvmField
    var tvInterest: TextView? = null

    var likedListener: (() -> Unit)? = null
    var dislikedListener: (() -> Unit)? = null

    @Resolve
    fun onResolved() {
        ivInterest?.setActualImageResource(item.image)
        tvInterest?.text = item.name
    }

    @SwipeOut
    fun onSwipeOut() {
        dislikedListener?.invoke()
    }

    @SwipeIn
    fun onSwipeIn() {
        likedListener?.invoke()
    }
}

There is nothing wrong with this code few hours ago. But now, i don't understand myself the tvInterest is null while the ivInterest is not. Why is that problem occured? How do i solve it? I've tried to make likedListener and dislikedListener to @JvmField, it doesn't work. I've also tried to use lateinit modifier, it make my apps force close.

Really appreciate your help, thanks

thanhpd-teko commented 4 years ago

Hi, did you find solution for this issue?

janishar commented 4 years ago

What is the Android Studio version you are using? @GoLok56 Try to invalidate cache and run

satadii11 commented 4 years ago

it has been 1.5 years since the issue if I'm not mistaken I was using java instead of Kotlin just for this class. it solved the problem.