Skip to content

Commit

Permalink
Improve code with inspection
Browse files Browse the repository at this point in the history
  • Loading branch information
Patrick Zedler committed Jan 1, 2022
1 parent 20fc280 commit 13d76a6
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
20 changes: 17 additions & 3 deletions app/src/main/java/com/plattysoft/leonids/ParticleSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import android.animation.Animator;
import android.animation.Animator.AnimatorListener;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.Canvas;
Expand All @@ -34,6 +35,7 @@
import android.view.ViewGroup;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
import androidx.core.content.res.ResourcesCompat;
import com.plattysoft.leonids.initializers.AccelerationInitializer;
import com.plattysoft.leonids.initializers.ParticleInitializer;
import com.plattysoft.leonids.initializers.RotationInitializer;
Expand Down Expand Up @@ -163,8 +165,13 @@ public ParticleSystem(ViewGroup parentView, int maxParticles, Drawable drawable,
* @param timeToLive The time to live for the particles
*/
public ParticleSystem(Activity a, int maxParticles, int drawableRedId, long timeToLive) {
this(a, maxParticles, a.getResources().getDrawable(drawableRedId), timeToLive,
android.R.id.content);
this(
a,
maxParticles,
ResourcesCompat.getDrawable(a.getResources(), drawableRedId, null),
timeToLive,
android.R.id.content
);
}

/**
Expand All @@ -179,7 +186,13 @@ public ParticleSystem(Activity a, int maxParticles, int drawableRedId, long time
*/
public ParticleSystem(Activity a, int maxParticles, int drawableRedId, long timeToLive,
int parentViewId) {
this(a, maxParticles, a.getResources().getDrawable(drawableRedId), timeToLive, parentViewId);
this(
a,
maxParticles,
ResourcesCompat.getDrawable(a.getResources(), drawableRedId, null),
timeToLive,
parentViewId
);
}

/**
Expand Down Expand Up @@ -642,6 +655,7 @@ public void onAnimationCancel(Animator animation) {
mAnimator.start();
}

@SuppressLint("RtlHardcoded")
private void configureEmitter(View emitter, int gravity) {
// It works with an emission range
int[] location = new int[2];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ public void apply(Particle particle, long milliseconds) {
} else if (milliseconds > mEndTime) {
particle.mAlpha = mFinalValue;
} else {
float interpolaterdValue = mInterpolator
float interpolatedValue = mInterpolator
.getInterpolation((milliseconds - mStartTime) * 1f / mDuration);
particle.mAlpha = (int) (mInitialValue + mValueIncrement * interpolaterdValue);
particle.mAlpha = (int) (mInitialValue + mValueIncrement * interpolatedValue);
}
}

Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/values/colors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@

<color name="red_neutral_99">#FFFAFA</color>
<color name="red_neutral_90">#FBEEED</color>
<color name="red_neutral_50">#8f7272</color>
<color name="red_neutral_20">#362F2F</color>
<color name="red_neutral_10">#211A1A</color>

Expand Down Expand Up @@ -98,7 +97,6 @@

<color name="yellow_neutral_99">#FFFCF6</color>
<color name="yellow_neutral_90">#E5E2D9</color>
<color name="yellow_neutral_50">#797869</color>
<color name="yellow_neutral_20">#31302B</color>
<color name="yellow_neutral_10">#1C1C16</color>

Expand Down Expand Up @@ -140,7 +138,6 @@

<color name="green_neutral_99">#FDFDF6</color>
<color name="green_neutral_90">#E3E3DC</color>
<color name="green_neutral_50">#74796E</color>
<color name="green_neutral_20">#2F312C</color>
<color name="green_neutral_10">#1A1C18</color>

Expand Down Expand Up @@ -182,7 +179,6 @@

<color name="blue_neutral_99">#FBFCFF</color>
<color name="blue_neutral_90">#E1E2E5</color>
<color name="blue_neutral_50">#8f7272</color>
<color name="blue_neutral_20">#2E3133</color>
<color name="blue_neutral_10">#191C1E</color>

Expand Down Expand Up @@ -224,7 +220,6 @@

<color name="google_neutral_99">#F2F0F4</color>
<color name="google_neutral_90">#E4E2E6</color>
<color name="google_neutral_50">#8f7272</color>
<color name="google_neutral_20">#2F3034</color>
<color name="google_neutral_10">#1B1B1D</color>

Expand Down Expand Up @@ -266,7 +261,6 @@

<color name="purple_neutral_99">#FFFBFE</color>
<color name="purple_neutral_90">#E6E1E5</color>
<color name="purple_neutral_50">#8f7272</color>
<color name="purple_neutral_20">#2E3133</color>
<color name="purple_neutral_10">#1C1B1F</color>

Expand Down
6 changes: 0 additions & 6 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,12 +309,6 @@
<item name="android:breakStrategy" tools:targetApi="m">simple</item>
</style>

<style
name="Widget.Doodle.TextView.Paragraph.Unjustified"
parent="Widget.Doodle.TextView.Paragraph">
<item name="android:justificationMode" tools:targetApi="o">none</item>
</style>

<style name="Base.Doodle.TextView.Toolbar" parent="Widget.Doodle.TextView">
<item name="android:textSize">@dimen/m3_sys_typescale_title_large_text_size</item>
<item name="android:singleLine">true</item>
Expand Down

0 comments on commit 13d76a6

Please sign in to comment.