Giter Site home page Giter Site logo

materialchipsinput's Introduction

[CURRENT SITUATION OF THE LIBRARY]

⚠️ The library is currently not maintained.

MaterialChipsInput

Implementation of Material Design Chips component for Android. The library provides two views : ChipsInput and ChipView.

Release

Demo

Demo

Download sample-v1.0.8.apk

Setup

To use this library your minSdkVersion must be >= 15.

In your project level build.gradle :

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}       

In your app level build.gradle :

dependencies {
    compile 'com.github.pchmn:MaterialChipsInput:1.0.8'
}      



ChipsInput

This view implements the Material Design Contact chips component.

It is composed of a collection of chips (ChipView) and an input (EditText). Touching a chip open a full detailed view (if non disable). The GIF above describes the behavior of the ChipsInput view.

But everything is configurable (optional avatar icon, optional full detailed view, ...) so you can use the ChipsInput view for non contact chips.

Basic Usage

XML

Use the ChipsInput view in your layout with default options :

<com.pchmn.materialchips.ChipsInput
        android:id="@+id/chips_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:hint="Enter a name" />

You can also customize it (see all attributes) :

<com.pchmn.materialchips.ChipsInput
        android:id="@+id/chips_input"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:hint="Enter a name"
        app:hintColor="@color/customColor"
        app:textColor="@color/customColor"
        app:maxRows="3"
        app:chip_labelColor="@color/customColor"
        app:chip_hasAvatarIcon="true"
        app:chip_backgroundColor="@color/customColor"
        app:chip_deletable="false"
        app:chip_deleteIconColor="@color/customColor"
        app:chip_detailed_textColor="@color/customColor"
        app:chip_detailed_backgroundColor="@color/customColor"
        app:chip_detailed_deleteIconColor="@color/customColor"
        app:filterable_list_backgroundColor="@color/customColor"
        app:filterable_list_textColor="@color/customColor" />

Suggestions

You can pass a List<? extends ChipInterface> object, which represents your suggestions, to the ChipsInput view, so it will work as a MultiAutoCompleteTextView :

1. Create a class that implements ChipInterface (or use directly the Chip class included in the library) :
public class ContactChip implements ChipInterface {
    ...
}
2. Then in your activity, or anything else, build your suggestion list of ContactChip (or Chip) and pass it to the ChipsInput view :
// get ChipsInput view
ChipsInput chipsInput = (ChipsInput) findViewById(R.id.chips_input);

// build the ContactChip list
List<ContactChip> contactList = new ArrayList<>();
contactList.add(new ContactChip()); 
...

// pass the ContactChip list
chipsInput.setFilterableList(contactList);

Get the selected list

When you want you can get the current list of chips selected by the user :

// get the list
List<ContactChip> contactsSelected = (List<ContactChip>) chipsInput.getSelectedChipList();

That's it, there is nothing more to do.

Advanced Usage

ChipsListener

The ChipsInput view provides a listener to interact with the input :

chipsInput.addChipsListener(new ChipsInput.ChipsListener() {
            @Override
            public void onChipAdded(ChipInterface chip, int newSize) {
                // chip added
                // newSize is the size of the updated selected chip list
            }

            @Override
            public void onChipRemoved(ChipInterface chip, int newSize) {
                // chip removed
                // newSize is the size of the updated selected chip list
            }

            @Override
            public void onTextChanged(CharSequence text) {
                // text changed
            }
        });

Add and remove chips manually

You don't have to pass a List<? extends ChipInterface> to the ChipsInput view and you can do the trick manually. Thanks to the ChipsListener you can be notified when the user is typing and do your own work.

ChipsInput chipsInput = (ChipsInput) findViewById(R.id.chips_input);
Add a chip

There are multiple implementations :

chipsInput.addChip(ChipInterface chip);
// or
chipsInput.addChip(Object id, Drawable icon, String label, String info);
// or
chipsInput.addChip(Drawable icon, String label, String info);
// or
chipsInput.addChip(Object id, Uri iconUri, String label, String info);
// or
chipsInput.addChip(Uri iconUri, String label, String info);
// or
chipsInput.addChip(String label, String info);
Remove a chip

There are multiple implementations :

chipsInput.removeChip(ChipInterface chip);
// or
chipsInput.removeChipById(Object id);
// or
chipsInput.removeChipByLabel(String label);
// or
chipsInput.removeChipByInfo(String info);

After you added or removed a chip the ChipsListener will be triggered.

Get the selected list

When you want you can get the current list of chips selected by the user :

// get the list
List<ChipInterface> contactsSelected = chipsInput.getSelectedChipList();

ChipsInput attributes

Attribute Type Description Default
app:hint string Hint of the input when there is no chip null
app:hintColor color Hint color android default
app:textColor color Text color when user types android default
app:maxRows int Max rows of chips 2
app:chip_labelColor color Label color of the chips android default
app:chip_hasAvatarIcon boolean Whether the chips have avatar icon or not true
app:chip_deletable boolean Whether the chips are deletable (delete icon) or not false
app:chip_deleteIconColor color Delete icon color of the chips white/black
app:chip_backgroundColor color Background color of the chips grey
app:showChipDetailed boolean Whether to show full detailed view or not when touching a chip true
app:chip_detailed_textColor color Full detailed view text color white/balck
app:chip_detailed_backgroundColor color Background color of the full detailed view colorAccent
app:chip_detailed_deleteIconColor color Delete icon color of the full detailed view white/black
app:filterable_list_backgroundColor color Background color of the filterable list of suggestions white
app:filterable_list_textColor color Text color of the filterable list of suggestions black



ChipView

This view implements the chip component according to the Material Design guidelines with configurable options (background color, text color, ...).

Chips examples

Usage

<com.pchmn.materialchips.ChipView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            app:label="Chip 1" />
            
<com.pchmn.materialchips.ChipView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:label="Chip 4"
                app:hasAvatarIcon="true" />

<com.pchmn.materialchips.ChipView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                app:label="Chip 6"
                app:labelColor="@android:color/white"
                app:avatarIcon="@drawable/avatar"
                app:backgroundColor="@android:color/holo_blue_light"
                app:deletable="true"
                app:deleteIconColor="@android:color/white" />
    

ChipView attributes

Attribute Type Description Default
app:label string Label of the chip null
app:labelColor color Label color of the chip android default
app:hasAvatarIcon boolean Whether the chip has avatar icon or not false
app:avatarIcon drawable Avatar icon resource null
app:deletable boolean Whether the chip is deletable (delete icon) or not false
app:deleteIconColor color Delete icon color of the chip grey
app:backgroundColor color Background color of the chip grey

Listeners

ChipView chip = (ChipView) findViewById(R.id.chip_view);

On chip click listener :

chip.setOnChipClicked(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // handle click    
    }
});

On delete button click listener :

chip.setOnDeleteClicked(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        // handle click     
    }
});



Sample

A sample app with some use cases of the library is available on this link

You can also download the sample APK here

Credits

License

Copyright 2017 pchmn

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

materialchipsinput's People

Contributors

marconi1992 avatar pchmn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

materialchipsinput's Issues

[Bug] The chip is deleted in backspace

When the user type a bad word and wants to fix it the previous chip is deleted.

Steps to reproduce:

  • Add a chip
  • Type some word
  • Delete a letter with backspace

Disable blinker when activity loads

Would like to be able to NOT have the chip focus when entering the activity. I can have keyboard not opened, but I can't disable the blinker from blinking.

Prevent the focus getting on start

Is there any way to control the focus getting for the component on application start ?
For example in demo application, let it keyboards appears after user has clicked on the component.

ChipInput height cannot be changed

Hello, thanks for the awesome library.
But is there any way to change the initial height of the ChipsInput? Because I need it a to be a little bit shorter at first and then expanding up to 3 rows after adding some items

Chipview could not be instantiated

java.lang.UnsupportedOperationException
at android.content.res.Resources_Delegate.obtainTypedArray(Resources_Delegate.java:509)
at android.content.res.Resources.obtainTypedArray(Resources.java:559)
at com.pchmn.materialchips.util.LetterTileProvider.(LetterTileProvider.java:67)
at com.pchmn.materialchips.ChipView.init(ChipView.java:78)
at com.pchmn.materialchips.ChipView.(ChipView.java:64)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:475)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:262)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:220)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:186)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:334)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:345)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:245)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:727)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:858)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:861)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:70)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:834)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:821)
at android.view.LayoutInflater.inflate(LayoutInflater.java:518)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:324)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:429)
at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:368)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:567)
at com.android.tools.idea.rendering.RenderTask$2.compute(RenderTask.java:549)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:863)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:549)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$1(RenderTask.java:680)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

NullPointerException in new version

I upgraded to the new version and then I got the below error.

java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.String.length()' on a null object reference at com.pchmn.materialchips.util.LetterTileProvider.getLetterTile(LetterTileProvider.java:83) at com.pchmn.materialchips.ChipView.setHasAvatarIcon(ChipView.java:219) at com.pchmn.materialchips.ChipView.inflateWithAttributes(ChipView.java:122) at com.pchmn.materialchips.ChipView.newInstance(ChipView.java:448) at com.pchmn.materialchips.ChipView.access$000(ChipView.java:29) at com.pchmn.materialchips.ChipView$Builder.build(ChipView.java:432) at com.pchmn.materialchips.ChipsInput.getChipView(ChipsInput.java:207) at com.pchmn.materialchips.adapter.ChipsAdapter.onCreateViewHolder(ChipsAdapter.java:78) at android.support.v7.widget.RecyclerView$Adapter.createViewHolder(RecyclerView.java:6367) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5555) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5440) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5436) at com.beloo.widget.chipslayoutmanager.ChipsLayoutManager.fillWithLayouter(ChipsLayoutManager.java:858) at com.beloo.widget.chipslayoutmanager.ChipsLayoutManager.fill(ChipsLayoutManager.java:821) at com.beloo.widget.chipslayoutmanager.ChipsLayoutManager.onLayoutChildren(ChipsLayoutManager.java:719) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3583) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3025) at android.view.View.measure(View.java:19957) at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1420) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482) at com.pchmn.materialchips.views.ScrollViewMaxHeight.onMeasure(ScrollViewMaxHeight.java:47) at android.view.View.measure(View.java:19957) at android.support.v4.widget.NestedScrollView.measureChildWithMargins(NestedScrollView.java:1420) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v4.widget.NestedScrollView.onMeasure(NestedScrollView.java:482) at com.pchmn.materialchips.views.ScrollViewMaxHeight.onMeasure(ScrollViewMaxHeight.java:47) at android.view.View.measure(View.java:19957) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.support.design.widget.TextInputLayout.onMeasure(TextInputLayout.java:1056) at android.view.View.measure(View.java:19957) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.view.View.measure(View.java:19957) at android.widget.ScrollView.measureChildWithMargins(ScrollView.java:1311) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.widget.ScrollView.onMeasure(ScrollView.java:345) at android.view.View.measure(View.java:19957) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:19957) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6087) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758)

Bug: Manually selected chips are duplicated in the filtered input list

If the chip is manually selected (using addChip(...)), then the chip still appears in the filtered list. If the chip is selected by clicking on the filtered list then it no longer appears in the filtered list. Presence in the filtered list should not be dependent on how the chip was selected.

Info not showing in FilterableListView

My app is using the ChipsInput view to show contacts (name, email) for a user to select from. As instructed I extend ChipsInterface and insert the required information. Everything looks great, I can see all the contacts I've added and the performance is perfect, except the emails (info fields for the Chips) don't show for any of the suggestions. Once I've selected it and it shows in the ChipsInput view, opening the detailed view shows the email as expected.
I've been able to break point inside of the FilterableAdapter so I know the data gets there and it appears to run the lines to set the text and make the info visible despite it not showing.
I am adding the filterable list on the UIThread and I have tried switching out my custom ChipInterface with the provided Chip object with the same effect.

NPE without specified FilterableList

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)

ChipsInput UI customizable

Hi,

First of all thank you for such an extensive and customizable library.

Can we make the chips input ui also customizable as right now there is no way to fix the ui as per app's need.

Memory leak

It seems both the sample and the library are leaking memory and abusing of the CPU of the device.

captura de pantalla 2017-08-16 a la s 18 19 52

That happens when you add a chip to the input on the contacts sample.

Can't disable hide keyboard

The library's default behavior hides keyboard if a user clicks outside the ChipInput.

I found I way to disable this by removing window callback on my activity with some delay. Since this looks really bad in the project it would be great to have an option to turn off auto keyboard hide feature.

NullPointerException at FilterableListView.fadeIn()

Getting this error when chips_input.setFilterableList(contactChips); is called after network call

java.lang.NullPointerException: Attempt to write to field 'int android.view.ViewGroup$MarginLayoutParams.topMargin' on a null object reference at com.pchmn.materialchips.views.FilterableListView.fadeIn(FilterableListView.java:135) at com.pchmn.materialchips.views.FilterableListView$2.onFilterComplete(FilterableListView.java:113) at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)

expose ChipsAdapter mChipsAdapter

I think is a good idea to make it public or even just create a getter method for mChipsAdapter, it'll make easier to customize the current adapter and have more control on the current list of chips.

How do you feel about that?

Avatar Icon not visible

Hi,
I added this code in my adapter to add chips programatically, but I am not getting the letter tile when using this. There is a black space for the avatar icon.When I am doing this using xml then it is working perfectly.

ChipView chip=new ChipView(context);
            chip.setLabel(sms.getRecieverList().get(i).getLabel());
            chip.setLabelColor(context.getColor(R.color.colorPrimaryDark));
            chip.setAvatarIcon(sms.getRecieverList().get(i).getAvatarUri());
            chip.setHasAvatarIcon(true);

can't update suggestion list when onTextChanged

I want to implement MaterialChipsInput for a search widget linked to a search web service on the api. I tried to use ChipsListener like this :

`final ArrayList contactList = new ArrayList<>();

    searchUsersForChatChipsInput.addChipsListener(new ChipsInput.ChipsListener() {
        @Override
        public void onChipAdded(ChipInterface chipInterface, int i) {

        }

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

        }

        @Override
        public void onTextChanged(final CharSequence charSequence) {
            if (charSequence.toString().length()>= 2) {
                StringRequest searchUserForChatRequest = new StringRequest(Request.Method.GET, SingletonApplicationController.URL + "/api/search/users.json?user_id=1&to_search=" + charSequence.toString()
                        , new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        try {
                            JSONObject JSONResponse = new JSONObject(response);
                            JSONArray JSONResultUsers = JSONResponse.getJSONArray("users");
                            contactList.clear();
                            for (int i = 0; i < JSONResultUsers.length(); i++) {
                                String username = JSONResultUsers.getJSONObject(i).getString("username");
                                String mail = JSONResultUsers.getJSONObject(i).getString("email");
                                contactList.add(new Chip(username, mail));
                            }
                            // pass contact list to chips input
                            searchUsersForChatChipsInput.setFilterableList(contactList);


                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                    }
                }, new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {
                        Toast.makeText(context, error.toString(), Toast.LENGTH_LONG).show();
                    }
                });

                // add the request object to the queue to be executed
                SingletonApplicationController.getInstance().addToRequestQueue(searchUserForChatRequest);
            }
        }
    });

`
But it's not really workin the listview for the result is not showing up even though it receives the right data from the web service in the JSONResponse. Even contactList gets well updated.

Any help .. Much Appreciated

java.lang.IllegalStateException: The specified child already has a parent.

I got his exception when I navigated away from a fragment where com.pchmn.materialchips.ChipsInput is used.

 FATAL EXCEPTION: main
Process: app.contactplus, PID: 3201
java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first.
at android.view.ViewGroup.addViewInner(ViewGroup.java:4310)
at android.view.ViewGroup.addView(ViewGroup.java:4146)
at android.view.ViewGroup.addView(ViewGroup.java:4118)
at com.pchmn.materialchips.views.FilterableListView$1.onGlobalLayout(FilterableListView.java:94)
at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:912)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1996)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1134)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6050)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:860)
at android.view.Choreographer.doCallbacks(Choreographer.java:672)
at android.view.Choreographer.doFrame(Choreographer.java:608)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:846)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5438)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:738)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:628)

Apart from this your library is awesome!!! :)

ClassCastException

When using a DialogFragment (AppCompatDialogFragment) I see this crash when the layout is inflated.

If I get time, I might submit a fix and pull request, but have noted it here until then.

Caused by: java.lang.ClassCastException: android.view.ContextThemeWrapper cannot be cast to android.app.Activity
at com.pchmn.materialchips.ChipsInput.init(ChipsInput.java:144)
at com.pchmn.materialchips.ChipsInput.<init>(ChipsInput.java:78)
at java.lang.reflect.Constructor.newInstance0(Native Method) 

FilterableList with data from external sources

For example I want to provide suggestions on the FilteredListView with data from a REST API , but not is possible because the method filterList into the class ChipsInput is called before of provide the external suggestions.

 mProductTags.addChipsListener(new ChipsInput.ChipsListener() {
            Handler handler = new Handler(Looper.getMainLooper());
            Runnable workRunnable;

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

            }

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

            }

            @Override
            public void onTextChanged(final CharSequence charSequence) {

                handler.removeCallbacks(workRunnable);
                workRunnable = new Runnable() {
                    @Override
                    public void run() {
                        queryTags(charSequence);
                    }
                };
                handler.postDelayed(workRunnable, 500);
            }
        });

Sample app crashes when Contact List Example clicked on Xperia X Performance

How to reproduce on Xperia X Performance:

  1. Install the latest repo code.
  2. Click "Contact List Example"
  3. App crashes with the error below.
04-25 23:35:30.861 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a748111
04-25 23:35:30.926 10895-10895/com.pchmn.sample.materialchipsinput I/Timeline: Timeline: Activity_launch_request id:com.pchmn.sample.materialchipsinput time:29040260
04-25 23:35:31.000 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@fe9ec7c
04-25 23:35:31.001 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@8fa905
04-25 23:35:31.051 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a944526
04-25 23:35:31.051 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@f973567
04-25 23:35:31.055 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@82ef3bd
04-25 23:35:31.055 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@b6f8db2
04-25 23:35:31.079 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@557c103
04-25 23:35:31.079 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@e7e4880
04-25 23:35:31.317 10895-10895/com.pchmn.sample.materialchipsinput I/Timeline: Timeline: Activity_idle id: android.os.BinderProxy@f78e4e4 time:29040651
04-25 23:35:31.506 10895-10956/com.pchmn.sample.materialchipsinput D/OpenGLRenderer: endAllActiveAnimators on 0x7f88aaf000 (RippleDrawable) with handle 0x7f88ab1400
04-25 23:35:34.783 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@bdbe4d3
04-25 23:35:34.784 10895-10895/com.pchmn.sample.materialchipsinput V/BoostFramework: BoostFramework() : mPerf = com.qualcomm.qti.Performance@a8ae810
04-25 23:35:34.806 10895-10895/com.pchmn.sample.materialchipsinput W/System.err: io.reactivex.exceptions.OnErrorNotImplementedException
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmitScalar(ObservableFlatMap.java:234)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:146)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableBuffer$BufferExactObserver.onNext(ObservableBuffer.java:113)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit(ObservableFlatMap.java:262)
04-25 23:35:34.807 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext(ObservableFlatMap.java:559)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:112)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.operators.observable.ObservableConcatMap$SourceObserver$InnerObserver.onNext(ObservableConcatMap.java:249)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:265)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:184)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:64)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:49)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:7120)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.Activity.dispatchActivityResult(Activity.java:6966)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.deliverResults(ActivityThread.java:4162)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.handleSendResult(ActivityThread.java:4209)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.-wrap20(ActivityThread.java)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:102)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.os.Looper.loop(Looper.java:241)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at android.app.ActivityThread.main(ActivityThread.java:6223)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
04-25 23:35:34.808 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err: Caused by: java.lang.NullPointerException
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.text.RuleBasedCollator.compare(RuleBasedCollator.java:356)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:66)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:61)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.TimSort.countRunAndMakeAscending(TimSort.java:351)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.TimSort.sort(TimSort.java:230)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.Arrays.sort(Arrays.java:1523)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at java.util.Collections.sort(Collections.java:238)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.adapter.FilterableAdapter.<init>(FilterableAdapter.java:61)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.views.FilterableListView.build(FilterableListView.java:66)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.materialchips.ChipsInput.setFilterableList(ChipsInput.java:342)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.sample.materialchipsinput.ContactListActivity.getContactList(ContactListActivity.java:124)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.sample.materialchipsinput.ContactListActivity.lambda$onCreate$12(ContactListActivity.java:47)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at com.pchmn.sample.materialchipsinput.ContactListActivity$$Lambda$1.accept(Unknown Source)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err:     at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
04-25 23:35:34.809 10895-10895/com.pchmn.sample.materialchipsinput W/System.err: 	... 24 more
04-25 23:35:34.811 10895-10895/com.pchmn.sample.materialchipsinput E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                     Process: com.pchmn.sample.materialchipsinput, PID: 10895
                                                                                     io.reactivex.exceptions.OnErrorNotImplementedException
                                                                                         at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:704)
                                                                                         at io.reactivex.internal.functions.Functions$OnErrorMissingConsumer.accept(Functions.java:701)
                                                                                         at io.reactivex.internal.observers.LambdaObserver.onError(LambdaObserver.java:74)
                                                                                         at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:64)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmitScalar(ObservableFlatMap.java:234)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:146)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139)
                                                                                         at io.reactivex.internal.operators.observable.ObservableBuffer$BufferExactObserver.onNext(ObservableBuffer.java:113)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit(ObservableFlatMap.java:262)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext(ObservableFlatMap.java:559)
                                                                                         at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:112)
                                                                                         at io.reactivex.internal.operators.observable.ObservableConcatMap$SourceObserver$InnerObserver.onNext(ObservableConcatMap.java:249)
                                                                                         at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:265)
                                                                                         at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:184)
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:64)
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:49)
                                                                                         at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:7120)
                                                                                         at android.app.Activity.dispatchActivityResult(Activity.java:6966)
                                                                                         at android.app.ActivityThread.deliverResults(ActivityThread.java:4162)
                                                                                         at android.app.ActivityThread.handleSendResult(ActivityThread.java:4209)
                                                                                         at android.app.ActivityThread.-wrap20(ActivityThread.java)
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571)
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                         at android.os.Looper.loop(Looper.java:241)
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6223)
                                                                                         at java.lang.reflect.Method.invoke(Native Method)
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
                                                                                      Caused by: java.lang.NullPointerException
                                                                                         at java.text.RuleBasedCollator.compare(RuleBasedCollator.java:356)
                                                                                         at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:66)
                                                                                         at com.pchmn.materialchips.adapter.FilterableAdapter$1.compare(FilterableAdapter.java:61)
                                                                                         at java.util.TimSort.countRunAndMakeAscending(TimSort.java:351)
                                                                                         at java.util.TimSort.sort(TimSort.java:230)
                                                                                         at java.util.Arrays.sort(Arrays.java:1523)
                                                                                         at java.util.Collections.sort(Collections.java:238)
                                                                                         at com.pchmn.materialchips.adapter.FilterableAdapter.<init>(FilterableAdapter.java:61)
                                                                                         at com.pchmn.materialchips.views.FilterableListView.build(FilterableListView.java:66)
                                                                                         at com.pchmn.materialchips.ChipsInput.setFilterableList(ChipsInput.java:342)
                                                                                         at com.pchmn.sample.materialchipsinput.ContactListActivity.getContactList(ContactListActivity.java:124)
                                                                                         at com.pchmn.sample.materialchipsinput.ContactListActivity.lambda$onCreate$12(ContactListActivity.java:47)
                                                                                         at com.pchmn.sample.materialchipsinput.ContactListActivity$$Lambda$1.accept(Unknown Source)
                                                                                         at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60)
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmitScalar(ObservableFlatMap.java:234) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.subscribeInner(ObservableFlatMap.java:146) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.onNext(ObservableFlatMap.java:139) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableBuffer$BufferExactObserver.onNext(ObservableBuffer.java:113) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$MergeObserver.tryEmit(ObservableFlatMap.java:262) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableFlatMap$InnerObserver.onNext(ObservableFlatMap.java:559) 
                                                                                         at io.reactivex.observers.SerializedObserver.onNext(SerializedObserver.java:112) 
                                                                                         at io.reactivex.internal.operators.observable.ObservableConcatMap$SourceObserver$InnerObserver.onNext(ObservableConcatMap.java:249) 
                                                                                         at io.reactivex.subjects.PublishSubject$PublishDisposable.onNext(PublishSubject.java:265) 
                                                                                         at io.reactivex.subjects.PublishSubject.onNext(PublishSubject.java:184) 
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:64) 
                                                                                         at com.tbruyelle.rxpermissions2.RxPermissionsFragment.onRequestPermissionsResult(RxPermissionsFragment.java:49) 
                                                                                         at android.app.Activity.dispatchRequestPermissionsResultToFragment(Activity.java:7120) 
                                                                                         at android.app.Activity.dispatchActivityResult(Activity.java:6966) 
                                                                                         at android.app.ActivityThread.deliverResults(ActivityThread.java:4162) 
                                                                                         at android.app.ActivityThread.handleSendResult(ActivityThread.java:4209) 
                                                                                         at android.app.ActivityThread.-wrap20(ActivityThread.java) 
                                                                                         at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1571) 
                                                                                         at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                         at android.os.Looper.loop(Looper.java:241) 
                                                                                         at android.app.ActivityThread.main(ActivityThread.java:6223) 
                                                                                         at java.lang.reflect.Method.invoke(Native Method) 
                                                                                         at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865) 
                                                                                         at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755) 

Could React Java be causing a problem here? I am testing on a Sony Xperia X Performance with Android Nougat. The library seems to work fine in the emulators. What could the problem be on my Android device?

Multiple ChipViews are not getting added

I have set filterableList to ChipsInput View, items are coming when I am typing the text but only first item is getting added to view once I search for another item and trying to click on it nothing happens.
I have tried it with your sample application code too, I can only add one item.

Please tell if I am doing something wrong.

<com.pchmn.materialchips.ChipsInput
android:id="@+id/expense_split_contacts"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hint="Enter a friend or group name"
app:maxRows="3"/>

FilterableListView shows over nav bar in landscape

If you have the chips input used in landscape mode, the drop down suggestions goes over the nav bar (AKA too far to the left). It is also very difficult to determine if this is the case and react to it from our side.
screenshot_20170818-164612 1

LetterTileProvider should be separated from core

LetterTileProvider should probably be separated from the library. It should either be placed into a separate library or exposed explicitly as a part of the API of just ripped out and thrown away.

The reason for separation is consistency. By using the built-in LetterTileProvider, the MaterialChipsInput forces a certain way of displaying contact icons. The icons are expected to be the same throughout the application. That mean the library forces the entire app to choose one of the two suboptimal choices:

  • Reimplement LetterTileProvider in the app (LetterTileProvider is not a part of MaterialChipsInput API)
  • Always provide a non-null icon to MaterialChipsInput effectively disabling its built-in LetterTileProvider.

I.e. in both cases LetterTileProvider is somewhat useless. It's also not an essential part of the library functionality.

Setting ChipView background color to ColorStateList not working

Hi there,

I am trying to set background color of chip to a color state list but it isn't working. However, setting color state list for label color is working. Here is the code:

  1. Activity Partial Code:
<com.pchmn.materialchips.ChipView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        app:backgroundColor="@color/chip_color"
        app:deletable="false"
        app:labelColor="@color/chip_label_color" />
  1. chip_color.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_selected="true"
        android:color="@color/colorPrimary"/>
    <item android:state_pressed="true"
        android:color="@color/colorPrimary"/>
    <item android:color="@color/grey500"/>
</selector>

Unable to use library

I have added dependency and program ran successfully but issue when try to see view in xml (Android studio).

project build.gradle
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io" }
}
}

app build.gradle
compile 'com.github.pchmn:MaterialChipsInput:1.0.8'
compile 'com.jakewharton:butterknife:8.6.0'

===================================================

java.lang.ClassCastException: android.view.Context cannot be cast to android.app.Activity
at com.pchmn.materialchips.ChipsInput.init(ChipsInput.java:147)
at com.pchmn.materialchips.ChipsInput.(ChipsInput.java:79)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

Fragment xml snapshot

<RelativeLayout
    android:id="@+id/ll_main"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:background="@color/white"
    android:orientation="vertical">

    <com.pchmn.materialchips.ChipsInput
        android:id="@+id/chips_input"
        android:layout_width="match_parent"
        android:layout_height="200dp"
        app:hint="Enter a name"
        tools:context=".activity.compose.ComposeActivity" />

=======================================================

rewrite

after looking at your code and edit it I found lots of bad code and bad performances,
the project could be much better, faster.
If you need help contact me in private

Problem resizing collapsing toolbar when maxRows for ChipsInput is not used

Writing more to help those who will meet the same issue rather than to get fix (since I have working workaround).

In my app I use ChipsInput in the same activity with CollapsingToolbarLayout.
By default I have 4 chips which takes 2 rows on my screen.
When I delete one of the chips or simply tap ChipsInput and then tap away - I'm no longer able to resize toolbar. It only begin to work again after I delete more chips so that there would be only one row left.
After some expirements I have noticed this behaviour does not occur when maxRows is defined (with value of 4 in my case).

Disable drop down menu

Would like to disable dropdown menu. It appears this library requires the chipInput view to be on the top of the screen for room above keyboard and under the text input to show the autocomplete list. Would like to disable this feature and just enter chip by clicking enter on keyboard.

getEditText return new instance

You are not able to reference the editText used for entering the input. This means I can't add extra TextWatcher nor can I get the current text input.

edittext inside recycler causing performance issue

it seems the edit text keeps measuring layout when it is inside a recyclerview. I found a old posting about this performance issue in google forum: https://issuetracker.google.com/issues/37015285.

the solution it says set the RecyclerView to not focusable, or you can specify the descendantFocusability to afterDescendants doesn't help because it still need to request focus for filtering chips. Is there any walk around solution?

thanks!

null pointer exception

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.nouman.winslosses, PID: 3082
java.lang.NullPointerException: Attempt to write to field 'int android.view.ViewGroup$MarginLayoutParams.topMargin' on a null object reference at com.pchmn.materialchips.views.FilterableListView.fadeIn(FilterableListView.java:135)
atcom.pchmn.materialchips.views.FilterableListView$2.onFilterComplete(FilterableListView.java:113)
at android.widget.Filter$ResultsHandler.handleMessage(Filter.java:285)
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)

Can't change inputType, remove focus and suggestions

So this is just about the only library I've used so far that looks good and seems to work well for my needs but I have these two 'issues' and a suggestions that I've found from the limitations present with it.

Both the inputType and focus do nothing, whether I change it in the layout or in the code. It looks unprofessional having the EditText view always have the cursor in the EditText. A detail but my mild obsession with details makes me a bit annoyed about this.

InputType doesn't seem to be possible to change. I wanted to use the Enter/New line button has a delimiter to create a chip but in the current state I can't, making me use the comma. Not really an issue as it's still fully usable, but I'd like the option.

Suggestions:

By default there is no way to add a chip without suggestions, making it obligatory to write code in TextChanged and create our own logic and delimiters. This can be worked around but I'd prefer this to be optional, not mandatory if I want to add chips without having suggestions. This includes creating delimiters and letting the ChipsInput deal with the creation and trigger onChipAdded.

Override the comparison method. I don't know if the ChipValidator is supposed to deal with this but it does nothing, there's no mention of the Validator in the readme also which makes me a bit confused and Android Studio doesn't even find usages so any intentions of implementing this soon? I want to use this because my language and main language of the user will contain special chars and I want the user to not have to worry about writing special chars to find an already existing chip, specially when I already implemented this with a search function in other areas - this was also requested by an user, in this case my teacher.

Anyway, I've decided to use your library as it seems to accomplish the task well enough and is better than the ones I've already tried. Even with the complains I have, which are minor, I'll still keep it. Keep up the good work, specially seeing that this does seem to be the best to create chips. :)

How do I show filterable list on clicking ChipsInput

As in AutoCompleteTextView we setThreshold to 0, and inside setOnclickListener we do view.showDropDown().

How do I implement the same for your library.

I didn't find any threshold or show drop down list kind methods.

Kindly help,
Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.