splitwise / TokenAutoComplete

Gmail style MultiAutoCompleteTextView for Android
Apache License 2.0
1.3k stars 383 forks source link

Crash on rotate when field is disabled #151

Closed massivespace closed 9 years ago

massivespace commented 9 years ago

When I set the "android:enabled" flag to false for the field, then rotate the device, it crashes with this:

    java.lang.NullPointerException: Attempt to invoke interface method 'boolean android.view.inputmethod.InputConnection.reportFullscreenMode(boolean)' on a null object reference
            at android.view.inputmethod.InputConnectionWrapper.reportFullscreenMode(InputConnectionWrapper.java:122)
            at com.android.internal.view.IInputConnectionWrapper.executeMessage(IInputConnectionWrapper.java:416)
            at com.android.internal.view.IInputConnectionWrapper$MyHandler.handleMessage(IInputConnectionWrapper.java:78)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5254)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)

If I enable the view, I have no issues, guessing it isn't necessarily due to rotation but due to Resuming or restoring the view state? One thing I noticed is that when the view is enabled, and I don't have focus on the view, if I rotate the device, it puts focus in the view to start editing, and the keyboard comes up, which I don't want either. This may be related.

I'm running it on a device with 5.X android and also tested on 4.4, using the latest release of TokenAutoComplete.

EDIT: Just a bit more testing on my end to help you out. I set the control's "clickable", "focusable", and "focusableInTouchMode" values to false in the XML, and now setting the enabled flag false works fine, and the keyboard doesn't pop up on rotation. So it has something to do with focusing this as the first focusable element in my view after restoring the view state.