greenfrvr / hashtag-view Goto Github PK
View Code? Open in Web Editor NEWAndroid fully customizable widget for representing data like hashtags collection and similiar.
License: MIT License
Android fully customizable widget for representing data like hashtags collection and similiar.
License: MIT License
Hi.
How do for hashtag-view I apply this https://github.com/deano2390/FlowTextView?
Do you have any advice?
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;
Hello
how select or unselect tag programmatically?
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.
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);
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
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...
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 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)
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)
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
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
help me if any can i want to implement hashtags in which we select a tags at time if we select another so it deselect first and second when is selected true..help thanks in advance
e.printStackTrace() is nothing for Android, replace it with Android Debug Logging
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?
Hi, I'm using HashTagView in RecyclerView
I want to remove fade-in animaition in HashTagView when I scroll down or up RecyclerView
How can I do this???
Thanks.
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?
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);
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 ?
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.
Any solution of that ?
Attribute tagPaddingLeft
in xml layout, defines all paddings, i.e. other padding attributes in xml are ignored.
_Quick fix_ - set paddings programmatically.
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
if we had more 200 tags, the app is no response.
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
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
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.
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?
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);
}
});
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
Need some method like setSelectedItems()
, so that when widget is in selectionMode
it would be possible to set "items selected by default".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.