Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

issues using this lib in Myadapter with RecyclerVIEW... #73

Open
akshaylamba opened this issue Feb 20, 2017 · 3 comments
Open

issues using this lib in Myadapter with RecyclerVIEW... #73

akshaylamba opened this issue Feb 20, 2017 · 3 comments

Comments

@akshaylamba
Copy link

0
down vote
favorite

I am trying to Using Particle system


                ParticleSystem ps = new ParticleSystem(holder.itemView.getContext(), 50, R.drawable.emoji_1f358, 1000);
                ps.setSpeedRange(0.1f, 0.25f);
                ps.setScaleRange(0.7f, 1.3f);
                ps.setSpeedRange(0.1f, 0.25f);
                ps.setAcceleration(0.0001f, 90);
                ps.setRotationSpeedRange(90, 180);
                ps.setFadeOut(200, new AccelerateInterpolator());
                ps.emit(v, 100)

I am Trying to Use it in a MyAdapter File in the below function :-


public void onBindViewHolder(final MyHolderCHAT holder, final int position) {
}

This is Giving me an Build error as Below :-

Error:(1824, 41) error: no suitable constructor found for ParticleSystem(Context,int,int,int) constructor ParticleSystem.ParticleSystem(ViewGroup,int,Drawable,long) is not applicable (argument mismatch; Context cannot be converted to ViewGroup) constructor ParticleSystem.ParticleSystem(Activity,int,int,long) is not applicable (argument mismatch; Context cannot be converted to Activity) constructor ParticleSystem.ParticleSystem(Activity,int,Drawable,long) is not applicable (argument mismatch; Context cannot be converted to Activity) constructor ParticleSystem.ParticleSystem(Activity,int,Bitmap,long) is not applicable (argument mismatch; Context cannot be converted to Activity) constructor ParticleSystem.ParticleSystem(Activity,int,AnimationDrawable,long) is not applicable (argument mismatch; Context cannot be converted to Activity)

I also tried using

ViewGroup vg = (ViewGroup) holder.itemView.getParent();
                       Drawable drawable = ContextCompat.getDrawable(c, R.drawable.emoji_1f358);
                       ParticleSystem ps = new ParticleSystem(vg, 50, drawable, 1000);
                       ps.setSpeedRange(0.1f, 0.25f);
                       ps.setScaleRange(0.7f, 1.3f);
                       ps.setSpeedRange(0.1f, 0.25f);
                       ps.setAcceleration(0.0001f, 90);
                       ps.setRotationSpeedRange(90, 180);
                       ps.setFadeOut(200, new AccelerateInterpolator());
                       ps.emit(v, 100);

But Got an error saying

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.support.v7.widget.RecyclerView$ViewHolder.shouldIgnore()' on a null object reference
at android.support.v7.widget.RecyclerView.findMinMaxChildLayoutPositions(RecyclerView.java:3709)
at android.support.v7.widget.RecyclerView.dispatchLayoutStep1(RecyclerView.java:3446)
at android.support.v7.widget.RecyclerView.dispatchLayout(RecyclerView.java:3262)

@akshaylamba akshaylamba changed the title issus using this lib in Myadapter... issues using this lib in Myadapter with RecyclerVIEW... Feb 20, 2017
@plattysoft
Copy link
Owner

A ViewGroup is something as simple as a FrameLayout or a RelativeLayout. If your list items have one of those as the top level element, it should be ok.

However I suggest giving the top level view an id and getting it by Id.

It may be confusing if the view moves and the particle system does not. There may be some side effects or unexpected behaviours. Putting particle effects on items on a ListView is not something I had tested or planned for. It may as well behave properly.

@akshaylamba
Copy link
Author

I have Relative Layout in my Recycler View as My Recycler View is attached to a Custom Layout with Contains the Relative Layout representing each row in recycler view....
How should I call the Relative Layout in the Below code...

ParticleSystem ps = new ParticleSystem(holder.itemView.getContext(), 50, R.drawable.emoji_1f358, 1000);
                ps.setSpeedRange(0.1f, 0.25f);
                ps.setScaleRange(0.7f, 1.3f);
                ps.setSpeedRange(0.1f, 0.25f);
                ps.setAcceleration(0.0001f, 90);
                ps.setRotationSpeedRange(90, 180);
                ps.setFadeOut(200, new AccelerateInterpolator());
                ps.emit(v, 100)

@fabads
Copy link

fabads commented Feb 17, 2018

Hi all,
I wake up this old issue having the same issue as above.
I'm trying to attach to top framelayout of my cardview but nothing is displayed:

(I do that in a click listener belonging to a button of my cardview)

ViewGroup mygroup = (ViewGroup) itemView.findViewById(R.id.background_hook);
                    new ParticleSystem(mygroup, 80, ContextCompat.getDrawable(itemView.getContext(), R.drawable.ic_raindrop_24dp), 10000)
                            .setSpeedByComponentsRange(0f, 0f, 0.05f, 0.1f)
                            .setAcceleration(0.00005f, 90)
                            .emitWithGravity(itemView.findViewById(R.id.button1), Gravity.BOTTOM, 8);

And what is the behaviour if we scroll the list?
The particles stay in the item view?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants