plattysoft / Leonids

A Particle System for standard Android UI: http://plattysoft.github.io/Leonids/
Apache License 2.0
2.28k stars 398 forks source link

oneShot() method is not working #95

Closed yash365 closed 6 years ago

yash365 commented 6 years ago

emit() method is working but oneShot() method is not working , and my phone is running on android 7.0

Code: public class MainActivity extends AppCompatActivity implements View.OnClickListener {

ImageButton foodButton;
TextView text;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    foodButton = (ImageButton) findViewById(R.id.foodButton);
    text = (TextView) findViewById(R.id.text);

    foodButton.setOnClickListener(this);
}

void smokeEffect(){

    Bitmap smokeBitmap =
            Bitmap.createScaledBitmap(
                    BitmapFactory.decodeResource(getResources(), R.drawable.smoke),
                    150,
                    150,
                    false);

    new ParticleSystem(this, 20, smokeBitmap, 10000)
            .setSpeedRange(0.2f, 0.5f)
            .oneShot(button, 10);
}

@Override
public void onClick(View view) {

    if(view == foodButton){
        smokeEffect();
    }
}

}

plattysoft commented 6 years ago

So, what you are saying is that, on that code, if you replace oneShot with emit, the particles work, but with oneShot they don't Well, I can assure that oneShot does work. Are you using the released version from jcenter or the latest source?

yash365 commented 6 years ago

I followed the steps mentioned in the documentation

  1. In the build.gradle(app module) i added this dependencies

dependencies{ // while using compile it was showing "Warning:Configuration 'compile' is obsolete and has been replaced with 'implementation' and 'api'." implementation 'com.plattysoft.leonids:LeonidsLib:1.3.2' }

  1. In the build.gradle(project module) i added the following code

repositories { jcenter{ url "http://jcenter.bintray.com/" } }

Also, i downloaded the Leonids Lib Demo app from play store, in that also One shot Simple and One Shot Advanced is not working.

plattysoft commented 6 years ago

I assume you are the same person that asked via twitter. I just tried the example app from google play on 3 different versions of Android, including Oreo. It did work on all of them. The only thing that can be missing is that you have animations disabled on your phone, and in that case, this is expected behaviour because a particle system is an animation.

yash365 commented 6 years ago

I have not asked on twitter, I have commented on play store

Yes it worked. My Animator duration scale was off in developer options. Animator duration scale should not be turned off to use oneShot() method.

Thanks for helping.

screenshot_20180516-112917

plattysoft commented 6 years ago

Great! Glad it worked.

It's funny how 2 people run into the same problem in the same 2 days while nobody mentioned it in months :)