splitwise / TokenAutoComplete

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

Fatal Exception: java.lang.NullPointerException #208

Closed slm closed 8 years ago

slm commented 8 years ago
Fatal Exception: java.lang.NullPointerException: Attempt to invoke interface method 'int android.widget.ListAdapter.getCount()' on a null object reference
       at com.tokenautocomplete.TokenCompleteTextView.performCompletion(TokenCompleteTextView.java:441)
       at com.tokenautocomplete.TokenCompleteTextView.onFocusChanged(TokenCompleteTextView.java:717)
       at android.view.View.clearFocusInternal(View.java:5500)
       at android.view.View.unFocus(View.java:5533)
       at android.view.ViewGroup.unFocus(ViewGroup.java:978)
       at android.view.ViewGroup.requestChildFocus(ViewGroup.java:668)
       at android.view.ViewGroup.requestChildFocus(ViewGroup.java:674)
       at android.view.ViewGroup.requestChildFocus(ViewGroup.java:674)
       at android.view.ViewGroup.requestChildFocus(ViewGroup.java:674)
       at android.view.ViewGroup.requestChildFocus(ViewGroup.java:674)
       at android.view.View.handleFocusGainInternal(View.java:5365)
       at android.view.View.requestFocusNoSearch(View.java:8115)
       at android.view.View.requestFocus(View.java:8094)
       at android.view.View.requestFocus(View.java:8061)
       at android.view.View.requestFocus(View.java:8040)
       at android.view.View.onTouchEvent(View.java:10333)
       at android.widget.TextView.onTouchEvent(TextView.java:9522)
       at android.view.View.dispatchTouchEvent(View.java:8962)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.widget.AbsListView.dispatchTouchEvent(AbsListView.java:5303)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2709)
       at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2425)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2559)
       at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1767)
       at android.app.Activity.dispatchTouchEvent(Activity.java:2866)
       at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
       at android.support.v7.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
       at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2520)
       at android.view.View.dispatchPointerEvent(View.java:9167)
       at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4708)
       at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:4546)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
       at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:4203)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4097)
       at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:4260)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
       at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:4123)
       at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:4089)
       at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:4097)
       at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:4070)
       at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:6567)
       at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:6457)
       at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:6428)
       at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:6657)
       at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:185)
       at android.os.MessageQueue.nativePollOnce(MessageQueue.java)
       at android.os.MessageQueue.next(MessageQueue.java:143)
       at android.os.Looper.loop(Looper.java:130)
       at android.app.ActivityThread.main(ActivityThread.java:5942)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195)

How can ı fix it ?

mgod commented 8 years ago

I looks like you didn't set an adapter for the token view?

slm commented 8 years ago

I use custom list view for suggestions. And when user click on ıtem, I call "addObject()" method. It is work perfect but sometimes I got crash. Can we implement null check for getAdapter() on performCompletion method or more sensible solve ?

mgod commented 8 years ago

It looks like adding that check should be fairly simple. Until I get a new version out with that change, I would set an empty adapter for the tokenview to prevent the crash

slm commented 8 years ago

209 I implemented check for now. When you release new version, I could use it.