Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

Merge Leonids pull requests #5

Merged
merged 4 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,68 +9,53 @@

public class ExampleListActivity extends ListActivity {

private class Sample {
public String name;
public Class activityClass;

public Sample(String name, Class activityClass) {
this.name = name;
this.activityClass = activityClass;
}
}

/**
* List of samples to show.
* Make sure to add the activity to the manifest, too.
*/
private Sample[] samples = {
new Sample("One Shot Simple", OneShotSimpleExampleActivity.class),
new Sample("One Shot Advanced", OneShotAdvancedExampleActivity.class),

new Sample("Emiter Simple", EmiterSimpleExampleActivity.class),
new Sample("Emiting on background [NEW]", EmiterBackgroundSimpleExampleActivity.class),
new Sample("Emiter Intermediate", EmiterIntermediateExampleActivity.class),
new Sample("Emiter Time Limited", EmiterTimeLimitedExampleActivity.class),
new Sample("Emit with Gravity [NEW]", EmiterWithGravityExampleActivity.class),

new Sample("Follow touch [NEW]", FollowCursorExampleActivity.class),
new Sample("Animated particles", AnimatedParticlesExampleActivity.class),
new Sample("Fireworks", FireworksExampleActivity.class),
new Sample("Confetti [Rabbit and Eggs]", ConfettiExampleActivity.class),
new Sample("Dust [Rabbit and Eggs]", DustExampleActivity.class),
new Sample("Stars [Rabbit and Eggs]", StarsExampleActivity.class)
};

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
String sampleList[] = new String [] {"One Shot Simple", "One Shot Advanced"
, "Emiter Simple"
, "Emiting on background [NEW]"
, "Emiter Intermediate"
, "Emiter Time Limited"
, "Emit with Gravity [NEW]"
, "Follow touch [NEW]"
, "Animated particles"
, "Fireworks"
, "Confetti [Rabbit and Eggs]"
, "Dust [Rabbit and Eggs]"
, "Stars [Rabbit and Eggs]"
// , "Animated Particles"
};
String sampleList[] = new String [samples.length];
int n = 0;
for (Sample sample : samples) {
sampleList[n++] = sample.name;
}
setListAdapter(new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, sampleList));
}

@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
switch (position) {
case 0:
startActivity(new Intent(this, OneShotSimpleExampleActivity.class));
break;
case 1:
startActivity(new Intent(this, OneShotAdvancedExampleActivity.class));
break;
case 2:
startActivity(new Intent(this, EmiterSimpleExampleActivity.class));
break;
case 3:
startActivity(new Intent(this, EmiterBackgroundSimpleExampleActivity.class));
break;
case 4:
startActivity(new Intent(this, EmiterIntermediateExampleActivity.class));
break;
case 5:
startActivity(new Intent(this, EmiterTimeLimitedExampleActivity.class));
break;
case 6:
startActivity(new Intent(this, EmiterWithGravityExampleActivity.class));
break;
case 7:
startActivity(new Intent(this, FollowCursorExampleActivity.class));
break;
case 8:
startActivity(new Intent(this, AnimatedParticlesExampleActivity.class));
break;
case 9:
startActivity(new Intent(this, FireworksExampleActivity.class));
break;
case 10:
startActivity(new Intent(this, ConfettiExampleActivity.class));
break;
case 11:
startActivity(new Intent(this, DustExampleActivity.class));
break;
case 12:
startActivity(new Intent(this, StarsExampleActivity.class));
break;
if (position >=0 && position < samples.length) {
startActivity(new Intent(this, samples[position].activityClass));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,37 @@ public ParticleSystem(Activity a, int maxParticles, Bitmap bitmap, long timeToLi
}
}

/**
* Utility constructor that receives an array of Bitmaps
*
* @param a The parent activity
* @param maxParticles The maximum number of particles
* @param bitmaps An array of bitmaps which will be randomly assigned to particles
* @param timeToLive The time to live for the particles
* @param parentViewId The view Id for the parent of the particle system
*/
public ParticleSystem(Activity a, int maxParticles, Bitmap[] bitmaps, long timeToLive, int parentViewId) {
this((ViewGroup) a.findViewById(parentViewId), maxParticles, timeToLive);
for (int i=0; i<mMaxParticles; i++) {
mParticles.add (new Particle (bitmaps[mRandom.nextInt(bitmaps.length)]));
}
}

/**
* Utility constructor that receives an array of Bitmaps
*
* @param parentView The parent view group
* @param maxParticles The maximum number of particles
* @param bitmaps An array of bitmaps which will be randomly assigned to particles
* @param timeToLive The time to live for the particles
*/
public ParticleSystem(ViewGroup parentView, int maxParticles, Bitmap[] bitmaps, long timeToLive) {
this(parentView, maxParticles, timeToLive);
for (int i=0; i<mMaxParticles; i++) {
mParticles.add (new Particle (bitmaps[mRandom.nextInt(bitmaps.length)]));
}
}

/**
* Utility constructor that receives an AnimationDrawable
*
Expand Down