Coder Social home page Coder Social logo

leonids's People

Contributors

cooperrs avatar fettlaus avatar haoxiqiang avatar ks-simakov avatar libtastic avatar magneticflux- avatar nominator avatar plattysoft avatar ryanwr 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

leonids's Issues

Make raining animation

Hi @plattysoft,
I'm trying to use your lib to make raining animation for my app.
I use below code (I copy from internet):

new ParticleSystem(GoActivity.this, 80, R.drawable.rain, 10000)
.setSpeedByComponentsRange(0f, 0f, 0.05f, 0.1f)
.setAcceleration(0.00005f, 90)
.emitWithGravity(findViewById(R.id.cloud), Gravity.CENTER, 8);

Unfortunately after running code, my drop image appeared only left side of the screen and it showed a half of it.

Can you help me solve this problem?
Thank you

NullPointerException

I am using com.plattysoft.leonids:LeonidsLib:1.3.1 version of this library and getting the following crashes from google play store :

java.lang.NullPointerException
! 1 at com.plattysoft.leonids.ParticleSystem.onUpdate(ParticleSystem.java:556)
2 at com.plattysoft.leonids.ParticleSystem.access$100(ParticleSystem.java:35)
3 at com.plattysoft.leonids.ParticleSystem$1.run(ParticleSystem.java:363)
4 at java.util.Timer$TimerImpl.run(Timer.java:284)

So can you please check it and resolve it?

Taking Screenshot

Hi,
I found your particle system and I like it a lot. Good work!!!
My problem is about screenshots. I wan't to programmatically take a screenshot while the particles are flying around on the screen. The problem is that the particles are missing on the screenshot.

I tried several solutions that I found on SO but none of them helped.
http://stackoverflow.com/questions/2661536/how-to-programatically-take-a-screenshot-on-android
http://stackoverflow.com/questions/16748384/take-screenshot-programmatically-of-the-whole-screen

If I try it with the hardware buttons (power + volume-down) all particles are on the screenshot but I wan't to provide a screenshot button in the user interface. So I have to do it programmatically. The device has no root access.

Maybe you had the same problem and can give me a hint?

Best,
Emanuel

Change size of particles in Leonids Particle System Lib

I am using the Leonids Particle System Lib, using the JAR library. When you use, for example, the .OneShot function, as in:

new ParticleSystem(Activity.this, 200, R.drawable.particle, (int)(t_star/2.0f))
.setSpeedRange(0.1f, 0.2f)
.oneShot(view, time);

the lib loads the R.drawable.particle, and emits the oneshot with the exact height and width in pixels than the original image. I want to control the exact size of the particles, since the effect should be different depending on the density of the used device (and LDPI, MDPI, etc. are not the exact approach, since the exact size control is desired)

Is if there are any ways to change the width or height of the particles in px or dp?

Does Lenoids support particle with trails?

I want to create a firework animation, but unlike the example, what I want to create is an animation with trails. That is, the firework should have their trails, not just single particles, below is one example. Could Lenoids do it? Or any other particle system that have the effect?Thanks!
ffede585-877b-40d9-bce5-2b7569842fba

java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0

Getting IndexOutOfBoundsException on Click on of Button while using Vector images. :-

java.lang.IndexOutOfBoundsException: Invalid index 0, size is 0
at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
at java.util.ArrayList.remove(ArrayList.java:403)
at com.plattysoft.leonids.ParticleSystem.activateParticle(ParticleSystem.java:518)
at com.plattysoft.leonids.ParticleSystem.oneShot(ParticleSystem.java:427)
at com.plattysoft.leonids.ParticleSystem.oneShot(ParticleSystem.java:411)
at com.example.amandeepsingh.demoexample.MainActivity.onClick(MainActivity.java:56)
at android.view.View.performClick(View.java:4785)
at android.view.View$PerformClick.run(View.java:19884)
at android.os.Handler.handleCallback(Handler.java:746)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5343)
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:907)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:702)

Lag on on emitWithGravity

It seems "TIMMERTASK_INTERVAL" in ParticaleSystem.java with 50 is too long and makes the animation lag. Can we change it to 10 so that it looks smooth on animation.

Particles image , How to rotate Y axis-angle?

Hi,
I had issues like unable to rotate in z -axis side of particles image from leonids lib, right now its rotating like x-axis angle. how to make like z-axis rotation in gravity bottom. I am expecting to do like below gif file, in that each particles rotate like z-axis and x-axis.

confetti_new - copy

Memory Leak: Timer thread stacks endlessly

Timer threads are not clean up correctly and will stack forever. Find out yourself when checking the heap dump.

We use your framework for some animations in a our project and fixed it ourselves. If you are interested, we can share the source and you may apply the fix to your library as well.

Missing Class?

Hey! Nice library you've got here! I was trying to use this library with lower apis, so I downloaded the sources and added nineoldandroids, but found out there's a class that's missing: AccelerationInitializer.

While I can remove the references and all, I won't be able to use the setAccelerate function. Am I doing something wrong?

setScaleRange not working for oneShot

The following code results in a particle effect where the size of the image remains fixed, when it is expected to vary in scale from 0.2 to 1.

ParticleSystem stars = new ParticleSystem(me, 50, R.drawable.star_particle, 2000);
stars.setScaleRange(0.2f, 5f);
stars.setSpeedRange(0.3f, 1f);
stars.oneShot(dials, 50);

Crashing when emit is present

Hi, I'm trying to create a falling snowflakes but my app crashes whenever i use the .emit function
this is my code

@OverRide
public void onClick(View arg0) {
new ParticleSystem(this, 80, R.drawable.snowflake, 10000)
.setSpeedModuleAndAngleRange(0f, 0.1f, 180, 180)
.setRotationSpeed(144)
.setAcceleration(0.000017f, 90)
.emit(findViewById(R.id.emiter_top_left), 8);
}

i have the emiter_top_left and snowflake in the xml file so that shouldnt be the problem. Snowflake isnt any big image so that shouldnt be it either. Could you help me please?

Animation effect like below?

I want to create a animation with some dots and they are falling from top to bottom. For that I am using a translate animation which moves the dots images from top to bottom. But I want this to be continuous meaning the animation should repeat itself.

I have to create a animation with some dots and they are falling from top to bottom i will post gif animation file , which is my requirement , please anyone guide me how to create this one?
it starts with FadeIn animation it is running fine in my code and then the dots moving in continuous Motion from TOP TO BOTTOM as in gif i have posted it is not working in my code i have created 14 Linearlayouts they contains 7 texviews Horizontally with VISIBILITY.GONE in Oncreate i am changing its VISIBILITY to VISIBLE and starting FADE IN animation and i will post my code , please anyone guide me?
splash gif
http://stackoverflow.com/questions/28762408/android-how-to-create-rain-like-animtion

Particles all appearing on the left side

Hey man,

so i was trying to implement your particle system (great job on this) but all the particles on the emitwithgravity all appear on the most left part of the screen. Not at all what was shown in previews.

Greetings

how to use it in Fragments

i was trying to test it in an 'OnClick' method in a fragment but got an error...

new ParticleSystem(getActivity(), 80, R.drawable.error_center_x, 10000)
.setSpeedModuleAndAngleRange(0f, 0.3f, 180, 180)
.setRotationSpeed(144)
.setAcceleration(0.00005f, 90)
.emit(findViewById(R.id.emiter_top_right), 8);

and the Log

java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.getLocationInWindow(int[])' on a null object reference

How to show Fireworks on custom dialog ?

Hi.
Thanks you so much for this library.
It's great and ease to use.

I'm using ParticleSystem to show fireworks, and i want show it on custom dialog.
I'm trying show it at a view on custom dialog, but it show wrong position.

How to i can ?

oneShot method not working on some devices

Hi,
Awesome and simple library, very nice job!
Everything is working fine in the emulator, but on my Xperia Z (running 5.1.1), the oneShot method doesn't work, both in the example APK and other custom code.
No error or debug info are displayed, however, I noticed some "normal extra" memory consumption when calling the method, it seems the drawable is loaded but not displayed.
No problem with the emit method.
Any idea?

Fix for emit gravity

Hi,

Please change in ParticleSystem#configureEmiter code from

line 457 mEmiterYMax = location[1] + emiter.getWidth() - mParentLocation[1];

to

line 457 mEmiterYMax = location[1] + emiter.getHeight() - mParentLocation[1];

Awesome library, but need help with "circles emitter" :-P

Well, I have to admit, this is awesome work. Easy to use implementation, documented source code. What more could we ask ? Well, there is always more ... ^^

Let's get straight to the point.

I have to draw an empty circle, which means we can only see the border (the membrane) of the circle and that's it.

This is the XML content that draws a circle :

<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:innerRadius="0dp"
    android:shape="ring"
    android:thicknessRatio="5"
    android:useLevel="false" >
    <solid android:color="@android:color/transparent" />

    <stroke
        android:width="2dp"
        android:color="@color/yellow" />
</shape>

So now I can add in a XML View's background and there I have my circle.

What I am looking for is that the yellow membrane/border of this circle is supposed to emit the particles and have these particles being drawn to the center of the circle. Unfortunately, I don't have sample to provide to show what I am looking for.

So to be simple and precise, the particles are generated all around the circle, from the inner-side of the border (so not from outside !). These particles must move very very slowly and must be drawn to the center of the circle. Moreoever, the fastest particles are supposed to die before reaching the center.

I hope I am clear enough.

If I try to have a ParticleSystem emit on the circle's View, it will emit particles both inside and outside the circle, because the View containing the circle is a square. So the X&Y coordinates do not match the circle's...

Is there a way to accomplish this ?

Thanks !

Sample App is not responding after continuously touching for long time in FollowCursorExampleActivity

As I mention above, after touching continuously for several minutes, sample app will be not responding. If I increase to several ParticleSystem, it will be faster to not responding.

The problem can be it just create new ParticleSystem objects, but after using it. The app still keep memory for those object without free them and continuously create new objects when touching. (I don't see you have function to free the memory).

It will be great if you can fix this issue and destructive objects after using them. Thank you very much for your time.

From afar, inviting

I am an Android developer from China, now see your project in GitHub, and now you want to project, adding Chinese translation comment commentary in Chinese community to share learning, hoping to get your approval

Make usable in Fragments and custom ViewGroups

At the moment ParticleSystem requires an Activity to be instantiated.
The activity is used to retrieve the parent view calling findViewById() and to get a Resources instance.
This makes tricky to use the lib inside a Fragment (you can call getActivity there, but findViewById may fail) and in a custom ViewGroup (no way to get the Activity here, and most likely the ViewGroup is the parent view you need).
The solution to this problem would be to have another public constructor that takes a ViewGroup and a Resources instead of an Activity and a viewResId, keep the old one for compatibility but make it call the new constructor

Pause/resume behaviour

Is there a way to pause all the particles/animations in the place they are and later just resume it? If it isn't it would be a great feature for the next version.

setStartTime does not properly work

Hello! Great library!

So, setStartTime() doesn't work currently. It's not fast-forwarding my particles.

I looked into the issue, and it seems to come from updateParticlesBeforeStartTime() being broken. setStartTime() takes a long, and directly sets it to mCurrentTime. mCurrentTime is the current time in milliseconds. And yet, on line 721 in updateParticlesBeforeStartTime(), there's this line:

long currentTimeInMs = mCurrentTime / 1000;

The variable currentTimeInMs is actually the time in seconds! This means that the particles are not properly updated before it starts when you use setStartTime(). If you have something like setStartTime(4000) with a particle rate of 5, there won't be any initial frames since framesCount will be 0, when there should be a lot of initial frames.

What's worse is that the function updateParticlesBeforeStartTime() is private, and it's called from a private function. If you made these functions protected, I could at least subclass the ParticleSystem class to fix this. But as it is, there's no real workaround. So maybe functions like these should be protected instead of private?

My current workaround is that I copied over both ParticleSystem and ParticleField to my project and replaced the updateParticlesBeforeStartTime() function with:

private void updateParticlesBeforeStartTime(int particlesPerSecond) {
    if (particlesPerSecond == 0) {
        return;
    }
    if (mCurrentTime == 0) {
        return;
    }
    for (int i = 0; i <= mCurrentTime; i += 100) {
        onUpdate(i);
    }
}

And now the setStartTime(3000) properly fast-forwards the particles 3 seconds. Obviously the framerate of 10 was chosen arbitrarily and can be fixed, but it suits my purposes. Maybe it can be an optional parameter for setStartTime()?

Anyway, hope this helps.

Thanks!

IllegalArgumentException from Random.nextInt

Hi,

I've implemented a particle animation using this library, but I keep getting this exceptions from time to time. Here is the stacktrace from the exception I got from the exception.

E/AndroidRuntime﹕ FATAL EXCEPTION: Timer-28
java.lang.IllegalArgumentException
at java.util.Random.nextInt(Random.java:187)
at com.plattysoft.leonids.ParticleSystem.getFromRange(ParticleSystem.java:536)
at com.plattysoft.leonids.ParticleSystem.activateParticle(ParticleSystem.java:524)
at com.plattysoft.leonids.ParticleSystem.onUpdate(ParticleSystem.java:544)
at com.plattysoft.leonids.ParticleSystem.access$1(ParticleSystem.java:539)
at com.plattysoft.leonids.ParticleSystem$1.run(ParticleSystem.java:363)
at java.util.Timer$TimerImpl.run(Timer.java:284)

I did search trough Random class and I found only one IllegalArgumentException from the whole class in the method nextInt(int n).

   /**
     * Returns a pseudo-random uniformly distributed {@code int}
     * in the half-open range [0, n).
     */
    public int nextInt(int n) {
        if (n <= 0) {
           throw new IllegalArgumentException("n <= 0: " + n);
        }
        if ((n & -n) == n) {
            return (int) ((n * (long) next(31)) >> 31);
        }
        int bits, val;
        do {
            bits = next(31);
            val = bits % n;
        } while (bits - val + (n - 1) < 0);
        return val;
    }

Particles without onclick call Example

Hey,

I'm using this wonderful library but i'm blocked to animate particles without a touch on a button.

I have a Xml view with

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
    android:layout_height="match_parent"  tools:context=".MainActivity"
    >
    <FrameLayout
        android:id="@+id/background_hook"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
    <TextView
        android:id="@+id/button"
        android:text="Button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerVertical="true"
        android:layout_centerHorizontal="true" />
...
</RelativeLayout>

And an actvity with

   @OnClick(R.id.button)
    public void buttonTouched(View v){
            doAnimation();
   }

 public void doAnimation(){
            ParticleSystem ps = new ParticleSystem(this, 50, R.drawable.placeholder, 1000, R.id.background_hook);
            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);
 }

That code is okay. I have particles around the button.
But if i start the animation programatically without onclick event I have the animation in the top left corner --'

 protected void onStart() {
            super.onStart();
            doAnimation();
    }

It's the same with

 protected void onStart() {
            super.onStart();
            button.performClick();
    }

Thank you in advance for any help you can provide

emmitWithGravity error.

Hi, i'm using Leonids to create background raining animation.
The problem is that all particles are running from the top left corner one by one. Can you help me handle it?

new ParticleSystem(MainActivity.this, 50, R.mipmap.ic_launcher, 5000)
                .setAcceleration(0.00013f, 90)
                .setSpeedByComponentsRange(0f, 0f, 0.05f, 0.1f)
                .setFadeOut(200, new AccelerateInterpolator())
                .emitWithGravity((Button)findViewById(R.id.mainForeground), Gravity.BOTTOM, 20);

ParticleSystem oneShot listener [Enhancement]

@plattysoft I was working with your library and I wanted to know when a particle ends or starts, for that I modified the source a little and added a listener inside ParticleSystem.java:

Source line: ParticleSystem#startAnimator()

The end result looks like this:

ParticleAnimationListener.java

public abstract class ParticleAnimationListener {

    public abstract void onStart();
    public abstract void onEnd();
    public abstract void onCancel();
    public abstract void onRepeat();

}

ParticleSystem.java

// ... 

/**
 * Launches particles in one Shot
 * 
 * @param emiter View from which center the particles will be emited
 * @param numParticles number of particles launched on the one shot
 */
public void oneShot(View emiter, int numParticles, ParticleAnimationListener listener) {
    oneShot(emiter, numParticles, new LinearInterpolator(), listener);
}

/**
 * Launches particles in one Shot using a special Interpolator
 * 
 * @param emiter View from which center the particles will be emited
 * @param numParticles number of particles launched on the one shot
 * @param interpolator the interpolator for the time
 */
public void oneShot(View emiter, int numParticles, Interpolator interpolator, ParticleAnimationListener listener) {
    configureEmiter(emiter, Gravity.CENTER);
    mActivatedParticles = 0;
    mEmitingTime = mTimeToLive;
    // We create particles based in the parameters
    for (int i=0; i<numParticles && i<mMaxParticles; i++) {
        activateParticle(0);
    }
    // Add a full size view to the parent view      
    mDrawingView = new ParticleField(mParentView.getContext());
    mParentView.addView(mDrawingView);
    mDrawingView.setParticles(mActiveParticles);
    // We start a property animator that will call us to do the update
    // Animate from 0 to timeToLiveMax
    startAnimator(interpolator, mTimeToLive, listener);
}

private void startAnimator(Interpolator interpolator, long animationTime, final ParticleAnimationListener listener) {

    mAnimator = ValueAnimator.ofInt(0, (int) animationTime);
    mAnimator.setDuration(animationTime);
    mAnimator.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int miliseconds = (Integer) animation.getAnimatedValue();
            onUpdate(miliseconds);
        }
    });
    mAnimator.addListener(new AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {
            if (listener != null)
                listener.onStart();
        }

        @Override
        public void onAnimationRepeat(Animator animation) {
            if (listener != null)
                listener.onRepeat();
        }

        @Override
        public void onAnimationEnd(Animator animation) {
            cleanupAnimation();

            if (listener != null)
                listener.onEnd();
        }

        @Override
        public void onAnimationCancel(Animator animation) {
            cleanupAnimation();

            if (listener != null)
                listener.onCancel();
        }
    });
    mAnimator.setInterpolator(interpolator);
    mAnimator.start();
}

End Result

Now you can call the ParticleSystem with a listener like so:

new ParticleSystem(activity, maxParticles, R.drawable.particle, timeToLive)
            .setSpeedModuleAndAngleRange(speedMin, speedMax, angleMin, angleMax)
            .setFadeOut(millBeforeFade, fadeInterpolator)
            .oneShot(view, particles, oneShotInterpolator, new ParticleAnimationListener() {
                    @Override
                    public void onStart() { // Do stuff when particle animation starts... }

                    @Override
                    public void onEnd() { // Do stuff when particle animation ends... }

                    @Override
                    public void onRepeat() { // Do stuff when particle animation repeats... }

                    @Override
                    public void onCancel() { // Do stuff when particle animation cancels... }
            });

The listener is optional and you can just pass null if you don't care to listen.

Can I do a pull request for this?

Support for vector drawables

Nice library, got me playing playing with the parameters real fast!
I noticed vectors don't work if I pass their resourceId.
Would it be hard to implement it?

ViewGroup and EmiterBackground

Hi!
Today I found a way to put particles inside a Fragment (#58) but now the problem i'm dealing with is that the constructor new ParticleSystem(ViewGroup parentView, Drawable drawable, int maxParticles, long timeToLive) cannot be used for the displaying the particles in the background because it throws the error android.support.v7.widget.AppCompatImageView cannot be cast to android.view.ViewGroup when new ParticleSystem(getActivity(), 50, R.drawable.animated_particles, 1000, R.id.background_hook)
Any idea of how to fix this?
Thanks for your time!

Using in Custom Views OnTouchEvent

Is there a way to emit particles on onTouchEvent in canvas view?

For example: If there is an ACTION_DOWN event then emit particles from the coordinates of that event.

snowimg effect

I m glad that you have released such a great library.

I would like to ask how can I simulate snowing effect with it?

Hope someone can give me some hints

documents on initialization lacking

the constructor

new ParticleSystem

should only be called after your view is loaded and positioned. Nothing is mentioned. Took me a while to find out.

If you do it inside activity construction, it will make emitter coordinates always 0,0
int[] location = new int[2];
emiter.getLocationInWindow(location);

Relicense Under Apache 2.0?

The use LGPL is disappointing for potential users of this excellent looking library. Something like Apache 2 is much more permissive in the manner in which the library can be used.

Would you be open to relicensing under Apache 2.0? Or maybe MIT?

Remove activity reference in ParticleSystem [Enhancement]

It might be a good idea to remove the activity reference in the ParticleSystem.java constructors. Benefits would be:

  • Could use the ParticleSystem in lists such as inside ViewHolders
  • Prevent memory leaks

I can look into alternative ways to find the parent view without a reference to activity

Particle system as background

Hi,

First of all, I would like to thank you for making this library. It's very useful for what I'm trying to achieve.

However, I want all the emitted particles to be in the background instead of the foreground. As of currently I have it, it show a snow-like particles but all those particles will make all my other views in the layout to be in the background. Is there any way to make the particles to be in the background instead?

Anything you can point out to help me with this would be appreciated.

Thanks,

Shinta

Can particle system be launched from OpenGL model?

I have an OpenGL 3D model in my Android app and I wanted to know if I can create a OneShot particle release upon the user tapping a certain point on the model. Is this possible and if so how? Thank you!

Change particles gravity dynamically

Hi,

I want my particles to change their gravity depending on the device's position. I already have a sensor listener but I can't find a way of changing the gravity (acceleration) dynamically.
Is there an easy way to do this?

Thanks

Crash in ParticleField.onDraw

There is a concurrency problem that is causing constant repeatable crashes. I've traced the issue to the fact that ParticleSystem.onUpdate is called via a Timer on a non-UI thread where it changes the contents of the mActiveParticles array. Meanwhile, the ParticleField view is accessing the same array to draw the particles on the UI thread, leading to the crash. A quick fix would be synchronize on the array to alleviate the contention, or use a Handler or similar mechanism to schedule the onUpdate operation on the UI thread.

java.lang.IndexOutOfBoundsException: Invalid index 50, size is 50
        at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:255)
        at java.util.ArrayList.get(ArrayList.java:308)
        at com.plattysoft.leonids.ParticleField.onDraw(ParticleField.java:36)
        at android.view.View.draw(View.java:14692)
        at android.view.View.getDisplayList(View.java:13573)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3095)
        at android.view.View.getDisplayList(View.java:13498)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.View.draw(View.java:14409)
        at android.view.ViewGroup.drawChild(ViewGroup.java:3121)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2947)
        at android.view.View.draw(View.java:14695)
        at android.widget.FrameLayout.draw(FrameLayout.java:472)
        at android.view.View.getDisplayList(View.java:13573)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3095)
        at android.view.View.getDisplayList(View.java:13498)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3095)
        at android.view.View.getDisplayList(View.java:13498)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3095)
        at android.view.View.getDisplayList(View.java:13498)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:3095)
        at android.view.View.getDisplayList(View.java:13498)
        at android.view.View.getDisplayList(View.java:13627)
        at android.view.HardwareRenderer$GlRenderer.buildDisplayList(HardwareRenderer.java:1773)
        at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:1638)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:2624)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:2469)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2035)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1095)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6010)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:799)
        at android.view.Choreographer.doCallbacks(Choreographer.java:599)
        at android.view.Choreographer.doFrame(Choreographer.java:559)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:784)
        at android.os.Handler.handleCallback(Handler.java:733)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:157)
        at android.app.ActivityThread.main(ActivityThread.java:5872)
        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:852)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:668)
        at dalvik.system.NativeStart.main(Native Method)

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.