lint cleanup

This commit is contained in:
edgar 2016-10-29 10:59:19 -07:00
parent 0684a75b44
commit fef6431e67
9 changed files with 65 additions and 109 deletions

View file

@ -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;

View file

@ -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<Star> stars;
private Vector<Star> 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,

View file

@ -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;

View file

@ -1,10 +0,0 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.erz.joystick.MainActivity">
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:title="@string/action_settings"
app:showAsAction="never" />
</menu>

View file

@ -1,9 +0,0 @@
<resources>>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
</style>
</resources>

View file

@ -1,6 +0,0 @@
<resources>
<!-- Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

View file

@ -1,6 +0,0 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
<dimen name="fab_margin">16dp</dimen>
</resources>

View file

@ -1,4 +1,3 @@
<resources>
<string name="app_name">JoyStick</string>
<string name="action_settings">Settings</string>
</resources>
</resources>

View file

@ -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));