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 without specified FilterableList #16

Closed
mstup opened this issue May 5, 2017 · 1 comment
Closed

NPE without specified FilterableList #16

mstup opened this issue May 5, 2017 · 1 comment

Comments

@mstup
Copy link

mstup commented May 5, 2017

It looks like FilberableList is mandatory to specify before to use component (version 1.0.5)

`public class MainAppActivity extends AppCompatActivity {
private ChipsInput chipsInput;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main_app);

    this.chipsInput = (ChipsInput) findViewById(R.id.chips_input);
    
    // without the next line of code application will crushed with NPE
    chipsInput.setFilterableList(new ArrayList<ChipInterface>());
}

@Override
protected void onResume() {
    super.onResume();

    chipsInput.setFilterableList(new ArrayList<ChipInterface>());
    chipsInput.addChip("Test", null);
    chipsInput.addChipsListener(new ChipsInput.ChipsListener() {
        @Override
        public void onChipAdded(ChipInterface chipInterface, int i) {}

        @Override
        public void onChipRemoved(ChipInterface chipInterface, int i) {}

        @Override
        public void onTextChanged(CharSequence charSequence) {
            String text = charSequence.toString();
            if (text.endsWith(" ")) {
                chipsInput.addChip(text, null);
            }
        }
    });
}

}`

NPE stack trace:

E/AndroidRuntime: FATAL EXCEPTION: main java.lang.NullPointerException at com.pchmn.materialchips.views.ChipsInputEditText.isFilterableListVisible(ChipsInputEditText.java:21) at com.pchmn.materialchips.util.MyWindowCallback.dispatchTouchEvent(MyWindowCallback.java:60) at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1873) at android.view.View.dispatchPointerEvent(View.java:7307) at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3174) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3119) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4155) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4134) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4226) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:171) at android.os.MessageQueue.nativePollOnce(Native Method) at android.os.MessageQueue.next(MessageQueue.java:125) at android.os.Looper.loop(Looper.java:124) at android.app.ActivityThread.main(ActivityThread.java:4745) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) at dalvik.system.NativeStart.main(Native Method)

pchmn added a commit that referenced this issue May 9, 2017
@pchmn
Copy link
Owner

pchmn commented May 9, 2017

Yeah right, I fixed the bug and pushed the correction in the dev branch, I will soon merge it to the master branch.
Thanks.

@mstup mstup closed this as completed May 9, 2017
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