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

NPE in view runnable #11

Open
vcoolish opened this issue Apr 6, 2022 · 1 comment
Open

NPE in view runnable #11

vcoolish opened this issue Apr 6, 2022 · 1 comment

Comments

@vcoolish
Copy link

vcoolish commented Apr 6, 2022

https://github.com/konaire/NumericKeyboard/blob/master/numeric-keyboard/src/main/java/com/konaire/numerickeyboard/NumericKeyboard.kt#L35

at some point 'this' becomes null, need to handle this case

java.lang.NullPointerException: 
  at com.konaire.numerickeyboard.NumericKeyboard$removeChar$1.run (NumericKeyboard.kt:39)
  at android.os.Handler.handleCallback (Handler.java:938)
  at android.os.Handler.dispatchMessage (Handler.java:99)
  at android.os.Looper.loopOnce (Looper.java:226)
  at android.os.Looper.loop (Looper.java:313)
  at android.app.ActivityThread.main (ActivityThread.java:8663)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:567)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1135)
@Mojtaba-Shafaei
Copy link

I got the NPE too, like @vcoolish

handler.postDelayed(this, 50) inside the runnable throws NPE
I guess the "postDelayed" was executed after onStop, so, the activity is no longer alive

private val removeChar: ViewRunnable = object : ViewRunnable() {
        override fun run() {
            val listener = KeyClickListener(field, fieldMaxLength)

            listener.onClick(view)
            handler.postDelayed(this, 50)
        }
    }

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

2 participants