From fef6431e676f61605b5d7b39c45a973f3f8dca35 Mon Sep 17 00:00:00 2001 From: edgar Date: Sat, 29 Oct 2016 10:59:19 -0700 Subject: [PATCH] lint cleanup --- .../main/java/com/erz/joystick/GameLoop.java | 14 ++-- .../main/java/com/erz/joystick/GameView.java | 65 ++++++++----------- app/src/main/java/com/erz/joystick/Star.java | 18 ++--- app/src/main/res/menu/menu_main.xml | 10 --- app/src/main/res/values-v21/styles.xml | 9 --- app/src/main/res/values-w820dp/dimens.xml | 6 -- app/src/main/res/values/dimens.xml | 6 -- app/src/main/res/values/strings.xml | 3 +- .../com/erz/joysticklibrary/JoyStick.java | 43 ++++++------ 9 files changed, 65 insertions(+), 109 deletions(-) delete mode 100644 app/src/main/res/menu/menu_main.xml delete mode 100644 app/src/main/res/values-v21/styles.xml delete mode 100644 app/src/main/res/values-w820dp/dimens.xml delete mode 100644 app/src/main/res/values/dimens.xml diff --git a/app/src/main/java/com/erz/joystick/GameLoop.java b/app/src/main/java/com/erz/joystick/GameLoop.java index 71e2b5f..a684e6a 100644 --- a/app/src/main/java/com/erz/joystick/GameLoop.java +++ b/app/src/main/java/com/erz/joystick/GameLoop.java @@ -7,13 +7,13 @@ import android.view.SurfaceView; * Created by edgarramirez on 7/17/15. */ public class GameLoop extends Thread { - static final long FPS = 60; - static final long ticksPS = 1000 / FPS; - SurfaceView view; - boolean running = false; - long startTime; - long sleepTime; - Canvas canvas; + private static final long FPS = 60; + private static final long ticksPS = 1000 / FPS; + private SurfaceView view; + private boolean running = false; + private long startTime; + private long sleepTime; + private Canvas canvas; public GameLoop(SurfaceView view) { this.view = view; diff --git a/app/src/main/java/com/erz/joystick/GameView.java b/app/src/main/java/com/erz/joystick/GameView.java index 4ff2ce7..0b515c8 100644 --- a/app/src/main/java/com/erz/joystick/GameView.java +++ b/app/src/main/java/com/erz/joystick/GameView.java @@ -20,36 +20,26 @@ import java.util.Vector; */ public class GameView extends SurfaceView implements SurfaceHolder.Callback { - float width; - float height; - float centerX; - float centerY; - float min; - float posX; - float posY; - float radius; - GameLoop gameLoop; - Paint paint; - Random random = new Random(); - int i; - int size = 20; - int minSpeed; - int maxSpeed; - int minRadius; - int maxRadius; - int maxX; - int maxY; - int tmpRadius; - Bitmap droid; - RectF rectF; - float rotate; + private float width; + private float height; + private float posX; + private float posY; + private float radius; + private GameLoop gameLoop; + private Paint paint; + private Random random = new Random(); + private int i; + private int size = 20; + private int maxRadius; + private Bitmap droid; + private RectF rectF; - double angle; - double power; + private double angle; + private double power; - double angle2; + private double angle2; - Vector stars; + private Vector stars; public GameView(Context context, AttributeSet attrs) { super(context, attrs); @@ -79,7 +69,7 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback { if (stars != null && stars.size() > 0) { for (i = 0; i < size; i++) { - stars.get(i).draw(canvas, paint, width, height, maxRadius); + stars.get(i).draw(canvas, paint, height, maxRadius); } } @@ -90,6 +80,7 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback { if (posY > height - radius) posY = height - radius; if (posY < radius) posY = radius; + float rotate; if (angle2 == 0) rotate = 0; else rotate = (float) Math.toDegrees(angle2) - 90; canvas.rotate(rotate, posX, posY); @@ -108,28 +99,28 @@ public class GameView extends SurfaceView implements SurfaceHolder.Callback { public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { this.width = width; this.height = height; - min = Math.min(width, height); + float min = Math.min(width, height); - centerX = width / 2; - centerY = height / 2; + float centerX = width / 2; + float centerY = height / 2; posX = centerX; posY = centerY; radius = min / 12; rectF = new RectF(posX - radius, posY - radius, posX + radius, posY + radius); - minSpeed = (int) (min / 75); - maxSpeed = (int) (min / 25); + int minSpeed = (int) (min / 75); + int maxSpeed = (int) (min / 25); - minRadius = (int) (min / 250); + int minRadius = (int) (min / 250); maxRadius = (int) (min / 220); if (maxRadius == minRadius) maxRadius += minRadius; stars = new Vector<>(); for (i = 0; i < size; i++) { - tmpRadius = random.nextInt(maxRadius - minRadius) + minRadius; - maxX = width - tmpRadius; - maxY = height - tmpRadius; + int tmpRadius = random.nextInt(maxRadius - minRadius) + minRadius; + int maxX = width - tmpRadius; + int maxY = height - tmpRadius; stars.add(new Star(random.nextInt(maxX - tmpRadius + (maxRadius * 4)) + (tmpRadius - (maxRadius * 4)), random.nextInt(maxY - tmpRadius + (maxRadius * 4)) + (tmpRadius - (maxRadius * 4)), random.nextInt(maxSpeed - minSpeed) + minSpeed, diff --git a/app/src/main/java/com/erz/joystick/Star.java b/app/src/main/java/com/erz/joystick/Star.java index d72a494..b95c56c 100644 --- a/app/src/main/java/com/erz/joystick/Star.java +++ b/app/src/main/java/com/erz/joystick/Star.java @@ -8,12 +8,12 @@ import android.graphics.RectF; * Created by edgarramirez on 6/16/15. */ public class Star { - public float x; - public float y; - public float speedY; - public float radius; - public boolean ready = false; - RectF rectF; + private float x; + private float y; + private float speedY; + private float radius; + private boolean ready = false; + private RectF rectF; public Star(float x, float y, float speedY, float radius) { this.x = x; @@ -24,9 +24,9 @@ public class Star { rectF = new RectF(); } - public void draw(Canvas canvas, Paint paint, float width, float height, float max) { + public void draw(Canvas canvas, Paint paint, float height, float max) { if (!ready) return; - update(width, height, max); + update(height, max); rectF.set(x - radius, y - radius, x + radius, y + radius); @@ -34,7 +34,7 @@ public class Star { canvas.drawOval(rectF, paint); } - public void update(float width, float height, float max) { + public void update(float height, float max) { if (!ready) return; y += speedY; diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml deleted file mode 100644 index 4066b45..0000000 --- a/app/src/main/res/menu/menu_main.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml deleted file mode 100644 index 251fb9f..0000000 --- a/app/src/main/res/values-v21/styles.xml +++ /dev/null @@ -1,9 +0,0 @@ -> - - - diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml deleted file mode 100644 index 63fc816..0000000 --- a/app/src/main/res/values-w820dp/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 64dp - diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml deleted file mode 100644 index 812cb7b..0000000 --- a/app/src/main/res/values/dimens.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - 16dp - 16dp - 16dp - diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index b0b94ce..a73e10f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1,4 +1,3 @@ JoyStick - Settings - + \ No newline at end of file diff --git a/joysticklibrary/src/main/java/com/erz/joysticklibrary/JoyStick.java b/joysticklibrary/src/main/java/com/erz/joysticklibrary/JoyStick.java index 5b900f1..feeec04 100644 --- a/joysticklibrary/src/main/java/com/erz/joysticklibrary/JoyStick.java +++ b/joysticklibrary/src/main/java/com/erz/joysticklibrary/JoyStick.java @@ -33,38 +33,35 @@ import android.view.View; */ public class JoyStick extends View { - JoyStickListener listener; - Paint paint; - float width; - float height; - float centerX; - float centerY; - float min; - float posX; - float posY; - float radius; - float buttonRadius; - double power = -1; - double angle = -1; - RectF temp; + private JoyStickListener listener; + private Paint paint; + private float centerX; + private float centerY; + private float posX; + private float posY; + private float radius; + private float buttonRadius; + private double power = -1; + private double angle = -1; + private RectF temp; //Background Color - int padColor; + private int padColor; //Stick Color - int buttonColor; + private int buttonColor; //Keeps joystick in last position - boolean stayPut; + private boolean stayPut; //Button Size percentage of the minimum(width, height) - int percentage = 25; + private int percentage = 25; //Background Bitmap - Bitmap padBGBitmap = null; + private Bitmap padBGBitmap = null; //Button Bitmap - Bitmap buttonBitmap = null; + private Bitmap buttonBitmap = null; public interface JoyStickListener { void onMove(JoyStick joyStick, double angle, double power); @@ -118,11 +115,11 @@ public class JoyStick extends View { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); - width = MeasureSpec.getSize(widthMeasureSpec); - height = MeasureSpec.getSize(heightMeasureSpec); + float width = MeasureSpec.getSize(widthMeasureSpec); + float height = MeasureSpec.getSize(heightMeasureSpec); centerX = width / 2; centerY = height / 2; - min = Math.min(width, height); + float min = Math.min(width, height); posX = centerX; posY = centerY; buttonRadius = (min / 2f * (percentage / 100f));