Giter VIP home page Giter VIP logo

hashtag-view's People

Contributors

gitter-badger avatar greenfrvr avatar psincraian 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

hashtag-view's Issues

ArrayIndexOutOfBoundsException in HashtagView

Unfortunately I can't find any documentation on how to use the new Lineair compose mode, so I've just been playing around a bit, but I'm getting this error.

My Code:

        ArrayList<XXX> genres = YYY.getAllGenres();
        // Load data into view
        hashtagView.setData(genres, new HashtagView.DataTransform<XXX>() {
            @Override
            public CharSequence prepare(XXX item) {
                // code here
                return spannableString;
            }
        });
        hashtagView.setComposeMode(HashtagView.COMPOSE_LINEAR);

Error:

java.lang.ArrayIndexOutOfBoundsException: length=9; index=9
at com.greenfrvr.hashtagview.HashtagView$LinearComposer.evaluateRowsQuantity(HashtagView.java:923)

line 923 in HashtagView:

rowsWidth[rowsCounter] += item;

Item is wider than widget

There is an unhandled case. When the value of measured text width + left/right paddings + left/right drawables is greater than total widget width, an infinite loop appears on items sorting step.

TagsSelectListener impovement

Need to pass selection state when onItemSelected() method is invoked. So method

TagsSelectListener.onItemSelected(Object item);

should be changed to

TagsSelectListener.onItemSelected(Object item, boolean selected);

Limit the selection items

I use this view in my project,but i found it can not limit the selection items.
eg:
when i seleced five items then let the item can not select

RecyclerView and HashtagView

Hi I have some problems using your library in my project with a RecyclerView (in particular with Material List).
I have a list of cards with some text and HashtagView. The first time the cards are populated in the right way, when I scroll cards are populated in the right way except that HashtagView that reuse previous tags.

I believed that the problem was in your view because I read that you don't call anytime invalidate() when data are setted. After that I added those calls in your code the result is the same.

So I don't understand where is the problem.. I tried to add some log in your code and when I setData the log works, so I believed that the problem is in the RecyclerView that doesn't redraw your view. I don't know why...

Not possible to keep tag order

Currently it seems to be impossible to have the tags ordered similar to the input list.
It would be great if there was another option for rowDistribution that allows that.

HashTagView calls removeAllViews in onDraw method

HashTagView calls removeAllViews() in onDraw() method despite documentation forbid it.

    private void draw() {
        if (viewMap == null || viewMap.isEmpty()) return;
        removeAllViews();

        for (Integer key : viewMap.keySet()) {
            ViewGroup rowLayout = getRowLayout(viewMap.get(key).size());
            addView(rowLayout);
            applyDistribution(viewMap.get(key));

            for (ItemData item : viewMap.get(key)) {
                rowLayout.addView(item.view, itemLayoutParams);
            }
        }
    }

Sometime it results in crash with stacktrace like this:

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:3562)
    at android.view.ViewGroup.addView(ViewGroup.java:3415)
    at android.view.ViewGroup.addView(ViewGroup.java:3391)
    at com.greenfrvr.hashtagview.HashtagView.draw(HashtagView.java:535)
    at com.greenfrvr.hashtagview.HashtagView.access$300(HashtagView.java:41)
    at com.greenfrvr.hashtagview.HashtagView$1.onPreDraw(HashtagView.java:141)
    at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:847)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1870)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:996)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5603)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
    at android.view.Choreographer.doCallbacks(Choreographer.java:574)
    at android.view.Choreographer.doFrame(Choreographer.java:544)
    at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
    at android.os.Handler.handleCallback(Handler.java:733)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:136)
    at android.app.ActivityThread.main(ActivityThread.java:5146)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:515)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:732)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:566)
    at dalvik.system.NativeStart.main(Native Method)

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

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)

Double click

public void addOnTagClickListener(TagsClickListener listener) {
if (clickListeners == null) {
clickListeners = new ArrayList<>();
}
clickListeners.clear();
clickListeners.add(listener);
}
Suggest you to add
clickListeners.clear();
because without it it gets clicked several times although I have added tag click listener once

Make items show in alphabetically order

Is there a reason why the item order changes (except for your algorithm)?

I'm trying to display some names but the order keeps changing every time I rotate my phone

library doesn't let use selector in tagTextColor attrribute

Hi,
first of all, thank you for your library.
Unfortunately it doesn't let user to use color selectors in tagTextColor attribute. In my app I need to change text color depending on is tag selected or not (because the background changes significantly as well).
Is there any special reason for it?
The implementation is very simple:

private void extractAttributes(AttributeSet attrs) {
    //...
    itemTextColorStateList = a.getColorStateList(R.styleable.HashtagView_tagTextColor);
    //...  
}

private void decorateItemTextView(TextView textView) {
    //textView.setTextColor(itemTextColor);
    textView.setTextColor(itemTextColorStateList);
    //...
}

Or do I miss any point?

Long hash tag cause the app to be unresponsive

If I supply tags with many characters, over 15 characters, it can cause the app to become unresponsive.

ArrayList<String> tags = new ArrayList<>();
tags.add("underwatercinematograpy");
tags.add("surfcinematography");
tags.add("chrisbryanfilms");
HashtagView.setData(tags, Transformers.HASH);

Do you know how this can be fixed?

Unable to display hashTags

I'm trying to display hash tags but it shows empty.

 <?xml version="1.0" encoding="utf-8"?>

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="vertical">

<include
    android:id="@+id/toolBar"
    layout="@layout/toolbar" />

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:padding="10dp"
    android:background="@color/repost_bg"
    android:orientation="vertical">

    <com.greenfrvr.hashtagview.HashtagView
        android:id="@+id/htvHashTag"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_margin="10dp"
        app:rowMode="stretch"
        app:tagForeground="@color/white"
        app:selectionMode="true"
        app:tagPaddingBottom="10dp"
        app:tagPaddingTop="10dp"
        app:tagTextSize="14sp"
        app:tagTextColor="@color/black" />

</LinearLayout>
</LinearLayout>

List<String> tagList = new ArrayList<>();
tagList.add("#php")
tagList.add("#love");
tagList.add("#android");
tagList.add("#programming");

HashtagView  hashtagView = (HashtagView)findViewById(R.id.htvHashTag);
hashtagView.setData(tagList);

How to remove tags ?

There is no method to remove a tag (or add a single tag, btw), so I tried calling setData with a new Array, and calling invalidate, which works.
However, removing the last tag by setting an empty array, crashes with
"java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first."
As workaround, I'm just setting visibility to GONE whenever I remove all tags.
Is there a recommended way to remove one or all tags ?

Unable to retrieve all tags from hashtagview

Hi,
probably I am missing something. If so, I am sorry. But I am not able to retrieve all entered tags from the hashtagview programmatically. I didn´t find any method to get that information. And in the documentation of the library it´s also not described how to get all tags.

P.S.: Appart from that problem this library is just awesome. Thanks for the work and effort you put into this.

Appcompat-v7 22 support

Hi! Is there a way to add support to library appcompat-v7:22.x.x? I'm working on a existing project built with compileSdkVersion "22" and I couldn't import this library in Gradle because of it needs appcompat-v7:23. Thanks

Gradle doesn't build (likely due to this being very out of date)

Error:Execution failed for task ':app:dexDebug'.

com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2

java.lang.NoClassDefFoundError thrown.

I tried using your library with this dependency

compile 'com.github.greenfrvr:hashtag-view:1.1.0@aar'

But the app crashes when i call

htv.setData(strings, Transformers.HASH);

with this stacktrace below. It looks like some classes don't get recognized. Specifically the ArrayListMultimap class. Is that not included in your library?

09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/common/collect/ArrayListMultimap;
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.greenfrvr.hashtagview.HashtagView.sort(HashtagView.java:406)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.greenfrvr.hashtagview.HashtagView.access$100(HashtagView.java:41)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.greenfrvr.hashtagview.HashtagView$1.onPreDraw(HashtagView.java:134)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:670)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:606)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.common.collect.ArrayListMultimap" on path: DexPathList[[zip file "/data/app/com.etiennelawlor.loop-1/base.apk"],nativeLibraryDirectories=[/data/app/com.etiennelawlor.loop-1/lib/arm, /data/app/com.etiennelawlor.loop-1/base.apk!/lib/armeabi-v7a, /vendor/lib, /system/lib]]
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.greenfrvr.hashtagview.HashtagView.sort(HashtagView.java:406) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.greenfrvr.hashtagview.HashtagView.access$100(HashtagView.java:41) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.greenfrvr.hashtagview.HashtagView$1.onPreDraw(HashtagView.java:134) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2055) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1107) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6013) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:858) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:670) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:606) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:844) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:148) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5417) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:   Suppressed: java.lang.ClassNotFoundException: com.google.common.collect.ArrayListMultimap
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.Class.classForName(Native Method)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:           ... 19 more
09-24 16:03:33.344 7542-7542/com.etiennelawlor.loop E/AndroidRuntime:  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available

Remove all tags (clear all) programmatically

Can I remove all tags programmatically?

hashtagview.removeAll()

I'm using dynamic mode and applying an for each to remove item by item. But the view refresh only once and only the first tagview is removed.

Add and remove tags

What would be a neat way to add and remove tags graphically? How could I keep one editable Tag at the end of the list to add another item?

Remove doesn't work

Hello,
I want to remove an item after its click. When I click on an item, the view is refreshed but my item is still there.. However the method "removeItem" return true.
The dynamic mode is set to true.
Could you help me ?

Here's my code :

myHashtagView.addOnTagClickListener(new HashtagView.TagsClickListener() {
            @Override
            public void onItemClicked(Object item) {
                Tag tag = (Tag) item;
                boolean success = suggestedTagsView.removeItem(item);
                Log.d(TAG, "removing item success : "+ success);
            }
        });

setSelected on item

Is there any way to set selected on an item? Basically, I want to set selected for only one tag at a time and if I can setSelected on an item then I can unselect any that are already selected

Pre-defined selected items

Need some method like setSelectedItems(), so that when widget is in selectionMode it would be possible to set "items selected by default".

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.