From 13d76a600ffe343e090e4be867ef14d488deb623 Mon Sep 17 00:00:00 2001 From: Patrick Zedler Date: Sat, 1 Jan 2022 04:58:26 +0100 Subject: [PATCH] Improve code with inspection --- .../plattysoft/leonids/ParticleSystem.java | 20 ++++++++++++++++--- .../leonids/modifiers/AlphaModifier.java | 4 ++-- app/src/main/res/values/colors.xml | 6 ------ app/src/main/res/values/styles.xml | 6 ------ 4 files changed, 19 insertions(+), 17 deletions(-) diff --git a/app/src/main/java/com/plattysoft/leonids/ParticleSystem.java b/app/src/main/java/com/plattysoft/leonids/ParticleSystem.java index f8e6660b..220128e4 100644 --- a/app/src/main/java/com/plattysoft/leonids/ParticleSystem.java +++ b/app/src/main/java/com/plattysoft/leonids/ParticleSystem.java @@ -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; @@ -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; @@ -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 + ); } /** @@ -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 + ); } /** @@ -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]; diff --git a/app/src/main/java/com/plattysoft/leonids/modifiers/AlphaModifier.java b/app/src/main/java/com/plattysoft/leonids/modifiers/AlphaModifier.java index fce2841d..f9f2cb99 100644 --- a/app/src/main/java/com/plattysoft/leonids/modifiers/AlphaModifier.java +++ b/app/src/main/java/com/plattysoft/leonids/modifiers/AlphaModifier.java @@ -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); } } diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 4139d3b1..cbbea315 100755 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -56,7 +56,6 @@ #FFFAFA #FBEEED - #8f7272 #362F2F #211A1A @@ -98,7 +97,6 @@ #FFFCF6 #E5E2D9 - #797869 #31302B #1C1C16 @@ -140,7 +138,6 @@ #FDFDF6 #E3E3DC - #74796E #2F312C #1A1C18 @@ -182,7 +179,6 @@ #FBFCFF #E1E2E5 - #8f7272 #2E3133 #191C1E @@ -224,7 +220,6 @@ #F2F0F4 #E4E2E6 - #8f7272 #2F3034 #1B1B1D @@ -266,7 +261,6 @@ #FFFBFE #E6E1E5 - #8f7272 #2E3133 #1C1B1F diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d631fb0a..5ca880cd 100755 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -309,12 +309,6 @@ simple - -