greenfrvr / hashtag-view

Android fully customizable widget for representing data like hashtags collection and similiar.
MIT License
336 stars 54 forks source link

Dynamic Mode addData() not working , Throwing Null Pointer Exception #24

Closed ankesh4040 closed 7 years ago

ankesh4040 commented 8 years ago

In my HashTag view I am trying to dynamically add item. But doing so throws null pointer exception. Instead of addItem() if I use removeItem() {at same place} then there is no exception and the method returns true/false as result. Only issue is while using addItem(Object T) method.

Please help me with this urgently. Thanks

Error log:-------

   Process: objectdistance.ankeshkjaisansaria.ram.sita., PID: 866
                                                                                              java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Collection com.google.common.collect.Multimap.values()' on a null object reference
                                                                                                  at com.greenfrvr.hashtagview.HashtagView.addItem(HashtagView.java:238)
                                                                                                  at objectdistance.ankeshkjaisansaria.ram.sita..SearchPanelClass.mainHashTagItemSelect(SearchPanelClass.java:210)
                                                                                                  at objectdistance.ankeshkjaisansaria.ram.sita..SearchPanelClass$1.onItemSelected(SearchPanelClass.java:75)
                                                                                                  at com.greenfrvr.hashtagview.HashtagView.handleSelection(HashtagView.java:784)
                                                                                                  at com.greenfrvr.hashtagview.HashtagView.access$600(HashtagView.java:45)
                                                                                                  at com.greenfrvr.hashtagview.HashtagView$2.onClick(HashtagView.java:756)
                                                                                                  at android.view.View.performClick(View.java:5697)
                                                                                                  at android.view.View$PerformClick.run(View.java:22534)
                                                                                                  at android.os.Handler.handleCallback(Handler.java:739)
                                                                                                  at android.os.Handler.dispatchMessage(Handler.java:95)
                                                                                                  at android.os.Looper.loop(Looper.java:158)
                                                                                                  at android.app.ActivityThread.main(ActivityThread.java:7229)
                                                                                                  at java.lang.reflect.Method.invoke(Native Method)
                                                                                                  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
                                                                                                  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Renk01 commented 8 years ago

I have exactly the same problem. If I use the following code line from the example it is working correctly: hashtagView3.setData(DATA, Transformers.HASH);

psincraian commented 8 years ago

I have the same problem. It seems the problem is in line 238 of file HashtagView.java.

The problem is that viewMap is null.

public <T> boolean addItem(@NonNull T item) {
[...]
        if (viewMap.values().contains(itemData)) return false;
[...]
MrDizzle commented 7 years ago

Any fix on this? Really frustrating!

mohan9 commented 7 years ago

Any fix on this?

greenfrvr commented 7 years ago

fixed in v1.3.0