Skip to content
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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lateinit property has not been initialized #118

Closed
ekrmh opened this issue May 11, 2018 · 7 comments
Closed

lateinit property has not been initialized #118

ekrmh opened this issue May 11, 2018 · 7 comments

Comments

@ekrmh
Copy link

ekrmh commented May 11, 2018

Sometimes i had "has not been initialized "

data class Learn(var key:String="")
@Layout(R.layout.item_word_stack)
class LearnCard(private val context: Context,
                private val learn: Learn,
                private val speak: (text:String) -> Unit
                ) {

    @View(R.id.btnSound)
    lateinit var btnSound : ImageView

    @View(R.id.txtEN)
    lateinit var txtEN: TextView

    @View(R.id.txtTR)
    lateinit var txtTR: TextView


    @SwipeView
    lateinit var swipeView: android.view.View

    @JvmField
    @Position
    var position: Int = 0


    @Resolve
    fun onResolved() {
        FirebaseFirestore.getInstance().collection(").document(l).get().addOnSuccessListener {
           val data = it.toObject(Word::class.java)
            txtEN.text = data?.EN
            txtTR.text = data?.TR
            swipeView.alpha = 1f
        }

    }
    @Click(R.id.btnSound)
    fun onClick(){
        speak(txtEN.text.toString())
    }
    @SwipeOutDirectional
    fun onSwipeOutDirectional(direction: SwipeDirection) {
        Log.d("DEBUG", "SwipeOutDirectional " + direction.name)
        if (direction.direction == SwipeDirection.TOP.direction) {
        }
    }

    @SwipeCancelState
    fun onSwipeCancelState() {
        Log.d("DEBUG", "onSwipeCancelState")
        swipeView.alpha = 1f
    }

    @SwipeInDirectional
    fun onSwipeInDirectional(direction: SwipeDirection) {
        Log.d("DEBUG", "SwipeInDirectional " + direction.name)
    }

    @SwipingDirection
    fun onSwipingDirection(direction: SwipeDirection) {
        Log.d("DEBUG", "SwipingDirection " + direction.name)
    }
    @SwipeIn
    fun  onSwipeIn(){
        Log.d("DEBUG","swipe in")
        DBHelper(context).updateData(learn.key)
    }
    @SwipeOut
    fun  onSwipeOut(){
        Log.d("DEBUG","swipe out")
        DBHelper(context).deleteKey(learn.key)
    }

}
@ekrmh ekrmh changed the title lateinit property txtEN has not been initialized lateinit property has not been initialized May 11, 2018
@ekrmh ekrmh closed this as completed May 24, 2018
@vodre
Copy link

vodre commented Jun 15, 2018

why is this issue closed? what was the solution?

@djavid
Copy link

djavid commented Aug 16, 2018

Have the same issue, every time have to clean project, else is not working, why is this happening?

@vodre
Copy link

vodre commented Sep 5, 2018

This is a kotlin solution that worked for me:

@view(R.id.myView)
@JvmField
var imageView: ImageView? = null

@Menris
Copy link

Menris commented Sep 25, 2018

Facing the same problem. @vodre answer doesn't help

@vodre
Copy link

vodre commented Sep 27, 2018

@Menris you should be seeing at least a different type of error since you are actually gettin rid of the lateinit vars . Make sure you are doing the same for ALL of your variables.

@Menris
Copy link

Menris commented Sep 28, 2018

@vodre I was facing another problem when I've putted @JvmField only for toggleIcon. Doing it for all variables did the work. Thanks!

@jas10022
Copy link

I am having this same issue on Android is there a solution to this yet because Iev been stuck on this for a while.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants