summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorBrad Leege <bleege@gmail.com>2015-02-10 14:50:18 -0800
committerBrad Leege <bleege@gmail.com>2015-02-10 14:50:18 -0800
commit83942df08b31ac696c9e857496a022c419789764 (patch)
treec4404b60ad2ceab556ba3d789ea4cf3648e6804e /android
parentdd87c34eacaea5376b24c3824dd557ec22aad5da (diff)
downloadqtlocation-mapboxgl-83942df08b31ac696c9e857496a022c419789764.tar.gz
#826 - Checkstyle issues
Diffstat (limited to 'android')
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLat.java9
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLatZoom.java9
-rw-r--r--android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java349
-rw-r--r--android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt1
4 files changed, 187 insertions, 181 deletions
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLat.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLat.java
index a36548fe3b..accc71732d 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLat.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLat.java
@@ -58,12 +58,15 @@ public class LonLat implements Parcelable {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
LonLat other = (LonLat) obj;
return Double.doubleToLongBits(lat) == Double.doubleToLongBits(other.lat) && Double.doubleToLongBits(lon) == Double.doubleToLongBits(other.lon);
}
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLatZoom.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLatZoom.java
index fd78e9356e..7b379863eb 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLatZoom.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/LonLatZoom.java
@@ -52,12 +52,15 @@ public class LonLatZoom extends LonLat implements Parcelable {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (obj == null)
+ }
+ if (obj == null) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
LonLatZoom other = (LonLatZoom) obj;
return super.equals(obj) && Double.doubleToLongBits(zoom) == Double.doubleToLongBits(other.zoom);
}
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java
index 4c51df6542..05a24fd640 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxgl/lib/MapView.java
@@ -24,7 +24,6 @@ import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.view.ViewConfiguration;
-import android.widget.ArrayAdapter;
import android.widget.ZoomButtonsController;
import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
@@ -225,7 +224,7 @@ public class MapView extends SurfaceView {
}
public void setCenterCoordinate(LonLatZoom centerCoordinate,
- boolean animated) {
+ boolean animated) {
long duration = animated ? ANIMATION_DURATION : 0;
mNativeMapView.setLonLatZoom(centerCoordinate, duration);
}
@@ -233,10 +232,12 @@ public class MapView extends SurfaceView {
public double getDirection() {
double direction = -mNativeMapView.getBearing();
- while (direction > 360)
+ while (direction > 360) {
direction -= 360;
- while (direction < 0)
+ }
+ while (direction < 0) {
direction += 360;
+ }
return direction;
}
@@ -513,7 +514,7 @@ public class MapView extends SurfaceView {
// Must handle window resizing here.
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
- int height) {
+ int height) {
Log.v(TAG, "surfaceChanged");
Log.i(TAG, "resize " + format + " " + width + " " + height);
mNativeMapView.resize((int) (width / mScreenDensity), (int) (height / mScreenDensity), mScreenDensity, width, height);
@@ -588,38 +589,38 @@ public class MapView extends SurfaceView {
// Handle two finger tap
switch (event.getActionMasked()) {
- case MotionEvent.ACTION_DOWN:
- // First pointer down
- break;
-
- case MotionEvent.ACTION_POINTER_DOWN:
- // Second pointer down
- mTwoTap = event.getPointerCount() == 2;
- break;
-
- case MotionEvent.ACTION_POINTER_UP:
- // Second pointer up
- break;
-
- case MotionEvent.ACTION_UP:
- // First pointer up
- long tapInterval = event.getEventTime() - event.getDownTime();
- boolean isTap = tapInterval <= ViewConfiguration.getTapTimeout();
- boolean inProgress = mRotateGestureDetector.isInProgress() || mScaleGestureDetector.isInProgress();
-
- if (mTwoTap && isTap && !inProgress) {
- PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event);
- zoom(false, focalPoint.x, focalPoint.y);
- mTwoTap = false;
- return true;
- }
+ case MotionEvent.ACTION_DOWN:
+ // First pointer down
+ break;
+
+ case MotionEvent.ACTION_POINTER_DOWN:
+ // Second pointer down
+ mTwoTap = event.getPointerCount() == 2;
+ break;
+
+ case MotionEvent.ACTION_POINTER_UP:
+ // Second pointer up
+ break;
+
+ case MotionEvent.ACTION_UP:
+ // First pointer up
+ long tapInterval = event.getEventTime() - event.getDownTime();
+ boolean isTap = tapInterval <= ViewConfiguration.getTapTimeout();
+ boolean inProgress = mRotateGestureDetector.isInProgress() || mScaleGestureDetector.isInProgress();
+
+ if (mTwoTap && isTap && !inProgress) {
+ PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event);
+ zoom(false, focalPoint.x, focalPoint.y);
+ mTwoTap = false;
+ return true;
+ }
- mTwoTap = false;
- break;
+ mTwoTap = false;
+ break;
- case MotionEvent.ACTION_CANCEL:
- mTwoTap = false;
- break;
+ case MotionEvent.ACTION_CANCEL:
+ mTwoTap = false;
+ break;
}
boolean retVal = mGestureDetector.onTouchEvent(event);
@@ -677,7 +678,7 @@ public class MapView extends SurfaceView {
// Called for flings
@Override
public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX,
- float velocityY) {
+ float velocityY) {
if (!mScrollEnabled) {
return false;
}
@@ -697,7 +698,7 @@ public class MapView extends SurfaceView {
// Cancel any animation
mNativeMapView.cancelTransitions();
- mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY * duration / 2.0 / mScreenDensity, (long)(duration * 1000.0f));
+ mNativeMapView.moveBy(velocityX * duration / 2.0 / mScreenDensity, velocityY * duration / 2.0 / mScreenDensity, (long) (duration * 1000.0f));
return true;
}
@@ -712,7 +713,7 @@ public class MapView extends SurfaceView {
// Cancel any animation
mNativeMapView.cancelTransitions(); // TODO need to test canceling
- // transitions with touch
+ // transitions with touch
// Scroll the map
mNativeMapView.moveBy(-distanceX / mScreenDensity, -distanceY / mScreenDensity);
@@ -885,64 +886,64 @@ public class MapView extends SurfaceView {
// Check which key was pressed via hardware/real key code
switch (keyCode) {
- // Tell the system to track these keys for long presses on
- // onKeyLongPress is fired
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- event.startTracking();
- return true;
+ // Tell the system to track these keys for long presses on
+ // onKeyLongPress is fired
+ case KeyEvent.KEYCODE_ENTER:
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ event.startTracking();
+ return true;
- case KeyEvent.KEYCODE_DPAD_LEFT:
- if (!mScrollEnabled) {
- return false;
- }
+ case KeyEvent.KEYCODE_DPAD_LEFT:
+ if (!mScrollEnabled) {
+ return false;
+ }
- // Cancel any animation
- mNativeMapView.cancelTransitions();
+ // Cancel any animation
+ mNativeMapView.cancelTransitions();
- // Move left
- mNativeMapView.moveBy(scrollDist / mScreenDensity, 0.0 / mScreenDensity);
- return true;
+ // Move left
+ mNativeMapView.moveBy(scrollDist / mScreenDensity, 0.0 / mScreenDensity);
+ return true;
- case KeyEvent.KEYCODE_DPAD_RIGHT:
- if (!mScrollEnabled) {
- return false;
- }
+ case KeyEvent.KEYCODE_DPAD_RIGHT:
+ if (!mScrollEnabled) {
+ return false;
+ }
- // Cancel any animation
- mNativeMapView.cancelTransitions();
+ // Cancel any animation
+ mNativeMapView.cancelTransitions();
- // Move right
- mNativeMapView.moveBy(-scrollDist / mScreenDensity, 0.0 / mScreenDensity);
- return true;
+ // Move right
+ mNativeMapView.moveBy(-scrollDist / mScreenDensity, 0.0 / mScreenDensity);
+ return true;
- case KeyEvent.KEYCODE_DPAD_UP:
- if (!mScrollEnabled) {
- return false;
- }
+ case KeyEvent.KEYCODE_DPAD_UP:
+ if (!mScrollEnabled) {
+ return false;
+ }
- // Cancel any animation
- mNativeMapView.cancelTransitions();
+ // Cancel any animation
+ mNativeMapView.cancelTransitions();
- // Move up
- mNativeMapView.moveBy(0.0 / mScreenDensity, scrollDist / mScreenDensity);
- return true;
+ // Move up
+ mNativeMapView.moveBy(0.0 / mScreenDensity, scrollDist / mScreenDensity);
+ return true;
- case KeyEvent.KEYCODE_DPAD_DOWN:
- if (!mScrollEnabled) {
- return false;
- }
+ case KeyEvent.KEYCODE_DPAD_DOWN:
+ if (!mScrollEnabled) {
+ return false;
+ }
- // Cancel any animation
- mNativeMapView.cancelTransitions();
+ // Cancel any animation
+ mNativeMapView.cancelTransitions();
- // Move down
- mNativeMapView.moveBy(0.0 / mScreenDensity, -scrollDist / mScreenDensity);
- return true;
+ // Move down
+ mNativeMapView.moveBy(0.0 / mScreenDensity, -scrollDist / mScreenDensity);
+ return true;
- default:
- // We are not interested in this key
- return super.onKeyUp(keyCode, event);
+ default:
+ // We are not interested in this key
+ return super.onKeyUp(keyCode, event);
}
}
@@ -951,21 +952,21 @@ public class MapView extends SurfaceView {
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
// Check which key was pressed via hardware/real key code
switch (keyCode) {
- // Tell the system to track these keys for long presses on
- // onKeyLongPress is fired
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- if (!mZoomEnabled) {
- return false;
- }
+ // Tell the system to track these keys for long presses on
+ // onKeyLongPress is fired
+ case KeyEvent.KEYCODE_ENTER:
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ if (!mZoomEnabled) {
+ return false;
+ }
- // Zoom out
- zoom(false);
- return true;
+ // Zoom out
+ zoom(false);
+ return true;
- default:
- // We are not interested in this key
- return super.onKeyUp(keyCode, event);
+ default:
+ // We are not interested in this key
+ return super.onKeyUp(keyCode, event);
}
}
@@ -983,15 +984,15 @@ public class MapView extends SurfaceView {
// Must use the key character map as physical to character is not
// fixed/guaranteed
switch (keyCode) {
- case KeyEvent.KEYCODE_ENTER:
- case KeyEvent.KEYCODE_DPAD_CENTER:
- if (!mZoomEnabled) {
- return false;
- }
+ case KeyEvent.KEYCODE_ENTER:
+ case KeyEvent.KEYCODE_DPAD_CENTER:
+ if (!mZoomEnabled) {
+ return false;
+ }
- // Zoom in
- zoom(true);
- return true;
+ // Zoom in
+ zoom(true);
+ return true;
}
// We are not interested in this key
@@ -1005,58 +1006,58 @@ public class MapView extends SurfaceView {
public boolean onTrackballEvent(MotionEvent event) {
// Choose the action
switch (event.getActionMasked()) {
- // The trackball was rotated
- case MotionEvent.ACTION_MOVE:
- if (!mScrollEnabled) {
- return false;
- }
+ // The trackball was rotated
+ case MotionEvent.ACTION_MOVE:
+ if (!mScrollEnabled) {
+ return false;
+ }
- // Cancel any animation
- mNativeMapView.cancelTransitions();
+ // Cancel any animation
+ mNativeMapView.cancelTransitions();
- // Scroll the map
- mNativeMapView.moveBy(-10.0 * event.getX() / mScreenDensity, -10.0 * event.getY() / mScreenDensity);
- return true;
+ // Scroll the map
+ mNativeMapView.moveBy(-10.0 * event.getX() / mScreenDensity, -10.0 * event.getY() / mScreenDensity);
+ return true;
// Trackball was pushed in so start tracking and tell system we are
// interested
// We will then get the up action
- case MotionEvent.ACTION_DOWN:
- // Set up a delayed callback to check if trackball is still
- // After waiting the system long press time out
- if (mCurrentTrackballLongPressTimeOut != null) {
- mCurrentTrackballLongPressTimeOut.cancel();
- mCurrentTrackballLongPressTimeOut = null;
- }
- mCurrentTrackballLongPressTimeOut = new TrackballLongPressTimeOut();
- postDelayed(mCurrentTrackballLongPressTimeOut,
- ViewConfiguration.getLongPressTimeout());
- return true;
+ case MotionEvent.ACTION_DOWN:
+ // Set up a delayed callback to check if trackball is still
+ // After waiting the system long press time out
+ if (mCurrentTrackballLongPressTimeOut != null) {
+ mCurrentTrackballLongPressTimeOut.cancel();
+ mCurrentTrackballLongPressTimeOut = null;
+ }
+ mCurrentTrackballLongPressTimeOut = new TrackballLongPressTimeOut();
+ postDelayed(mCurrentTrackballLongPressTimeOut,
+ ViewConfiguration.getLongPressTimeout());
+ return true;
// Trackball was released
- case MotionEvent.ACTION_UP:
- if (!mZoomEnabled) {
- return false;
- }
+ case MotionEvent.ACTION_UP:
+ if (!mZoomEnabled) {
+ return false;
+ }
- // Only handle if we have not already long pressed
- if (mCurrentTrackballLongPressTimeOut != null) {
- // Zoom in
- zoom(true);
- }
- return true;
+ // Only handle if we have not already long pressed
+ if (mCurrentTrackballLongPressTimeOut != null) {
+ // Zoom in
+ zoom(true);
+ }
+ return true;
// Trackball was cancelled
- case MotionEvent.ACTION_CANCEL:
- if (mCurrentTrackballLongPressTimeOut != null) {
- mCurrentTrackballLongPressTimeOut.cancel();
- mCurrentTrackballLongPressTimeOut = null;
- }
- return true;
+ case MotionEvent.ACTION_CANCEL:
+ if (mCurrentTrackballLongPressTimeOut != null) {
+ mCurrentTrackballLongPressTimeOut.cancel();
+ mCurrentTrackballLongPressTimeOut = null;
+ }
+ return true;
- default:
- // We are not interested in this event
- return super.onTrackballEvent(event);
+ default:
+ // We are not interested in this event
+ return super.onTrackballEvent(event);
}
}
@@ -1100,26 +1101,26 @@ public class MapView extends SurfaceView {
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) == InputDevice.SOURCE_CLASS_POINTER) {
// Choose the action
switch (event.getActionMasked()) {
- // Mouse scrolls
- case MotionEvent.ACTION_SCROLL:
- if (!mZoomEnabled) {
- return false;
- }
+ // Mouse scrolls
+ case MotionEvent.ACTION_SCROLL:
+ if (!mZoomEnabled) {
+ return false;
+ }
- // Cancel any animation
- mNativeMapView.cancelTransitions();
+ // Cancel any animation
+ mNativeMapView.cancelTransitions();
- // Get the vertical scroll amount, one click = 1
- float scrollDist = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
+ // Get the vertical scroll amount, one click = 1
+ float scrollDist = event.getAxisValue(MotionEvent.AXIS_VSCROLL);
- // Scale the map by the appropriate power of two factor
- mNativeMapView.scaleBy(Math.pow(2.0, scrollDist), event.getX() / mScreenDensity, event.getY() / mScreenDensity);
+ // Scale the map by the appropriate power of two factor
+ mNativeMapView.scaleBy(Math.pow(2.0, scrollDist), event.getX() / mScreenDensity, event.getY() / mScreenDensity);
- return true;
+ return true;
- default:
- // We are not interested in this event
- return super.onGenericMotionEvent(event);
+ default:
+ // We are not interested in this event
+ return super.onGenericMotionEvent(event);
}
}
@@ -1132,23 +1133,23 @@ public class MapView extends SurfaceView {
@Override
public boolean onHoverEvent(@NonNull MotionEvent event) {
switch (event.getActionMasked()) {
- case MotionEvent.ACTION_HOVER_ENTER:
- case MotionEvent.ACTION_HOVER_MOVE:
- // Show the zoom controls
- if ((mZoomButtonsController != null) && mZoomEnabled) {
- mZoomButtonsController.setVisible(true);
- }
- return true;
+ case MotionEvent.ACTION_HOVER_ENTER:
+ case MotionEvent.ACTION_HOVER_MOVE:
+ // Show the zoom controls
+ if ((mZoomButtonsController != null) && mZoomEnabled) {
+ mZoomButtonsController.setVisible(true);
+ }
+ return true;
- case MotionEvent.ACTION_HOVER_EXIT:
- // Hide the zoom controls
- if (mZoomButtonsController != null) {
- mZoomButtonsController.setVisible(false);
- }
+ case MotionEvent.ACTION_HOVER_EXIT:
+ // Hide the zoom controls
+ if (mZoomButtonsController != null) {
+ mZoomButtonsController.setVisible(false);
+ }
- default:
- // We are not interested in this event
- return super.onHoverEvent(event);
+ default:
+ // We are not interested in this event
+ return super.onHoverEvent(event);
}
}
diff --git a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt b/android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt
deleted file mode 100644
index dd3ef5113e..0000000000
--- a/android/java/MapboxGLAndroidSDKTestApp/src/main/res/raw/token.txt
+++ /dev/null
@@ -1 +0,0 @@
-pk.eyJ1IjoiYmxlZWdlIiwiYSI6IlhFcHdyMlEifQ.A8U0V-ob2G0RjI_gznrjtg \ No newline at end of file