I would like to call this method:
fun workingWithBtn(k: Int) {
when (k) {
1 -> {
btn_submit_t.showError();
Handler().postDelayed({
this@LoginScr.runOnUiThread {
btn_submit_t.hideLoading()
btn_submit_t.isEnabled
}
}, 1000)
}
2 -> {
btn_submit_t.showSuccess()
}
3 -> Handler().postDelayed({
clickCount--
this@LoginScr.runOnUiThread {
btn_submit_t.hideLoading()
btn_submit_t.isEnabled
}
}, 1000)
}
}
this method is placed at the kotlin-based activity and I would like to call it from java singleton. I call this method from singleton like this:
new LoginScr().workingWithBtn(3);
but I receive the error:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$Callback android.view.Window.getCallback()' on a null object reference
as I understand my class can't find my button. I tried to use findViewById and then work with btn but it didn't help me. How I can solve this problem?