Stop file not found error in Makefile

Update JNI methods
Tiny up Java
This commit is contained in:
Leith Bade
2014-11-08 16:23:43 +11:00
parent 160712274d
commit 5b6c7aa870
14 changed files with 222 additions and 130 deletions

View File

@@ -2,6 +2,7 @@ package com.mapbox.mapboxgl.app;
import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.Log;
import com.mapbox.mapboxgl.lib.MapView;
@@ -88,7 +89,7 @@ public class MainActivity extends Activity {
// Called before activity is destroyed
@Override
protected void onSaveInstanceState(Bundle outState) {
protected void onSaveInstanceState(@NonNull Bundle outState) {
Log.v(TAG, "onSaveInstanceState");
// Need to retrieve any saved state from the map

View File

@@ -27,5 +27,6 @@ android {
}
dependencies {
compile "commons-io:commons-io:2.4"
compile 'commons-io:commons-io:2.4'
compile 'com.android.support:support-annotations:21.0.0'
}

View File

@@ -91,7 +91,8 @@ public abstract class BaseGestureDetector {
* handling in this implementation may set the gesture out of progress (via
* mGestureInProgress).
*
* @param action
*
* @param actionCode
* @param event
*/
protected abstract void handleInProgressEvent(int actionCode,

View File

@@ -74,8 +74,6 @@ public class MoveGestureDetector extends BaseGestureDetector {
private final OnMoveGestureListener mListener;
private PointF mCurrFocusInternal;
private PointF mPrevFocusInternal;
private PointF mFocusExternal = new PointF();
private PointF mFocusDeltaExternal = new PointF();
@@ -134,8 +132,8 @@ public class MoveGestureDetector extends BaseGestureDetector {
final MotionEvent prev = mPrevEvent;
// Focus intenal
mCurrFocusInternal = determineFocalPoint(curr);
mPrevFocusInternal = determineFocalPoint(prev);
PointF mCurrFocusInternal = determineFocalPoint(curr);
PointF mPrevFocusInternal = determineFocalPoint(prev);
// Focus external
// - Prevent skipping of focus delta when a finger is added or removed
@@ -155,8 +153,7 @@ public class MoveGestureDetector extends BaseGestureDetector {
* Determine (multi)finger focal point (a.k.a. center point between all
* fingers)
*
* @param MotionEvent
* e
* @param e
* @return PointF focal point
*/
private PointF determineFocalPoint(MotionEvent e) {

View File

@@ -38,8 +38,6 @@ import android.view.ViewConfiguration;
public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
private final float mEdgeSlop;
private float mRightSlopEdge;
private float mBottomSlopEdge;
protected float mPrevFingerDiffX;
protected float mPrevFingerDiffY;
@@ -168,22 +166,20 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
protected boolean isSloppyGesture(MotionEvent event) {
// As orientation can change, query the metrics in touch down
DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
mRightSlopEdge = metrics.widthPixels - mEdgeSlop;
mBottomSlopEdge = metrics.heightPixels - mEdgeSlop;
float mRightSlopEdge = metrics.widthPixels - mEdgeSlop;
float mBottomSlopEdge = metrics.heightPixels - mEdgeSlop;
final float edgeSlop = mEdgeSlop;
final float rightSlop = mRightSlopEdge;
final float bottomSlop = mBottomSlopEdge;
final float x0 = event.getRawX();
final float y0 = event.getRawY();
final float x1 = getRawX(event, 1);
final float y1 = getRawY(event, 1);
boolean p0sloppy = x0 < edgeSlop || y0 < edgeSlop || x0 > rightSlop
|| y0 > bottomSlop;
boolean p1sloppy = x1 < edgeSlop || y1 < edgeSlop || x1 > rightSlop
|| y1 > bottomSlop;
boolean p0sloppy = x0 < edgeSlop || y0 < edgeSlop || x0 > mRightSlopEdge
|| y0 > mBottomSlopEdge;
boolean p1sloppy = x1 < edgeSlop || y1 < edgeSlop || x1 > mRightSlopEdge
|| y1 > mBottomSlopEdge;
if (p0sloppy && p1sloppy) {
return true;
@@ -199,8 +195,7 @@ public abstract class TwoFingerGestureDetector extends BaseGestureDetector {
* Determine (multi)finger focal point (a.k.a. center point between all
* fingers)
*
* @param MotionEvent
* e
* @param e
* @return PointF focal point
*/
public static PointF determineFocalPoint(MotionEvent e) {

View File

@@ -3,22 +3,18 @@ package com.arieslabs.assetbridge;
import android.content.Context;
import android.content.res.AssetManager;
import android.util.Log;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
public class Assetbridge {
/*static {
System.loadLibrary("assetbridge");
}*/
// unpack
public static void unpack(Context c) {
@@ -47,7 +43,7 @@ public class Assetbridge {
public static void copyAssetFolder(AssetManager am, String src, String dest)
throws IOException{
throws IOException {
InputStream srcIS = null;
File destfh;
@@ -69,8 +65,10 @@ public class Assetbridge {
if(isDir) {
// If the directory doesn't yet exist, create it
if( !destfh.exists() ){
destfh.mkdir();
if( !destfh.exists() ) {
if (!destfh.mkdir()) {
throw new IOException("Failed to mkdir");
}
}
// list the assets in the directory...
@@ -101,7 +99,6 @@ public class Assetbridge {
}
}
// the native method to set the environment variable
//public static native void setassetdir(String s);
}

View File

@@ -65,11 +65,7 @@ public class LonLat implements Parcelable {
if (getClass() != obj.getClass())
return false;
LonLat other = (LonLat) obj;
if (Double.doubleToLongBits(lat) != Double.doubleToLongBits(other.lat))
return false;
if (Double.doubleToLongBits(lon) != Double.doubleToLongBits(other.lon))
return false;
return true;
return Double.doubleToLongBits(lat) == Double.doubleToLongBits(other.lat) && Double.doubleToLongBits(lon) == Double.doubleToLongBits(other.lon);
}
@Override

View File

@@ -93,14 +93,7 @@ public class LonLatZoom implements Parcelable {
if (getClass() != obj.getClass())
return false;
LonLatZoom other = (LonLatZoom) obj;
if (Double.doubleToLongBits(lat) != Double.doubleToLongBits(other.lat))
return false;
if (Double.doubleToLongBits(lon) != Double.doubleToLongBits(other.lon))
return false;
if (Double.doubleToLongBits(zoom) != Double
.doubleToLongBits(other.zoom))
return false;
return true;
return Double.doubleToLongBits(lat) == Double.doubleToLongBits(other.lat) && Double.doubleToLongBits(lon) == Double.doubleToLongBits(other.lon) && Double.doubleToLongBits(zoom) == Double.doubleToLongBits(other.zoom);
}
@Override

View File

@@ -1,9 +1,5 @@
package com.mapbox.mapboxgl.lib;
import java.io.IOException;
import org.apache.commons.io.Charsets;
import org.apache.commons.io.IOUtils;
import org.json.JSONException;
import org.json.JSONObject;
@@ -12,6 +8,7 @@ import android.content.pm.PackageManager;
import android.content.res.TypedArray;
import android.graphics.PointF;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.util.Log;
import android.view.GestureDetector;
@@ -61,7 +58,7 @@ public class MapView extends SurfaceView {
private String mStyleUrl;
// Used to load map tiles
private String mApiKey;
private String mAccessToken;
// Touch gesture detectors
private GestureDetector mGestureDetector;
@@ -90,19 +87,19 @@ public class MapView extends SurfaceView {
// Called when no properties are being set from XML
public MapView(Context context) {
super(context);
initialize(context, null, 0);
initialize(context, null);
}
// Called when properties are being set from XML
public MapView(Context context, AttributeSet attrs) {
super(context, attrs);
initialize(context, attrs, 0);
initialize(context, attrs);
}
// Called when properties are being set from XML
public MapView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initialize(context, attrs, defStyle);
initialize(context, attrs);
}
//
@@ -110,7 +107,7 @@ public class MapView extends SurfaceView {
//
// Common initialization code goes here
private void initialize(Context context, AttributeSet attrs, int defStyle) {
private void initialize(Context context, AttributeSet attrs) {
Log.v(TAG, "initialize");
// Check if we are in Eclipse UI editor
@@ -128,10 +125,12 @@ public class MapView extends SurfaceView {
// Load the map style and API key
//mStyleUrl = "https://mapbox.github.io/mapbox-gl-styles/styles/bright-v6.json";
mStyleUrl = "file://" + cachePath + "/styles/styles/bright-v6.json";
mApiKey = "pk.eyJ1IjoibGpiYWRlIiwiYSI6IlJSQ0FEZ2MifQ.7mE4aOegldh3595AG9dxpQ";
mAccessToken = "pk.eyJ1IjoibGpiYWRlIiwiYSI6IlJSQ0FEZ2MifQ.7mE4aOegldh3595AG9dxpQ";
// Create the NativeMapView
mNativeMapView = new NativeMapView(this, cachePath, mStyleUrl, mApiKey);
mNativeMapView = new NativeMapView(this, cachePath);
mNativeMapView.setStyleURL(mStyleUrl);
mNativeMapView.setAccessToken(mAccessToken);
// Load the attributes
TypedArray typedArray = context.obtainStyledAttributes(attrs,
@@ -500,7 +499,7 @@ public class MapView extends SurfaceView {
// Called when view is hidden and shown
@Override
protected void onVisibilityChanged(View changedView, int visibility) {
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
// Required by ZoomButtonController (from Android SDK documentation)
if ((mZoomButtonsController != null) && (visibility != View.VISIBLE)) {
mZoomButtonsController.setVisible(false);
@@ -542,7 +541,7 @@ public class MapView extends SurfaceView {
// Called when user touches the screen, all positions are absolute
@Override
public boolean onTouchEvent(MotionEvent event) {
public boolean onTouchEvent(@NonNull MotionEvent event) {
// Check and ignore non touch or left clicks
if ((event.getButtonState() != 0)
&& (event.getButtonState() != MotionEvent.BUTTON_PRIMARY)) {
@@ -563,11 +562,7 @@ public class MapView extends SurfaceView {
case MotionEvent.ACTION_POINTER_DOWN:
// Second pointer down
if (event.getPointerCount() == 2) {
mTwoTap = true;
} else {
mTwoTap = false;
}
mTwoTap = event.getPointerCount() == 2;
break;
case MotionEvent.ACTION_POINTER_UP:
@@ -598,6 +593,7 @@ public class MapView extends SurfaceView {
}
// Do not change this code! It will break very easily.
// TODO fix up these warnings
boolean retVal = rotateRetVal || scaleRetVal;
retVal = mGestureDetector.onTouchEvent(event) || retVal;
return retVal || super.onTouchEvent(event);
@@ -871,7 +867,7 @@ public class MapView extends SurfaceView {
// Called when the user presses a key, also called for repeating keys held
// down
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
public boolean onKeyDown(int keyCode, @NonNull KeyEvent event) {
// If the user has held the scroll key down for a while then accelerate
// the scroll speed
double scrollDist = event.getRepeatCount() >= 5 ? 50.0 : 10.0;
@@ -1123,7 +1119,7 @@ public class MapView extends SurfaceView {
// Called when the mouse pointer enters or exits the view
// or when it fades in or out due to movement
@Override
public boolean onHoverEvent(MotionEvent event) {
public boolean onHoverEvent(@NonNull MotionEvent event) {
switch (event.getActionMasked()) {
case MotionEvent.ACTION_HOVER_ENTER:
case MotionEvent.ACTION_HOVER_MOVE:

View File

@@ -1,10 +1,10 @@
package com.mapbox.mapboxgl.lib;
import java.util.Set;
import android.util.Log;
import android.view.Surface;
import java.util.List;
// Class that wraps the native methods for convenience
class NativeMapView {
@@ -37,11 +37,11 @@ class NativeMapView {
// Constructors
//
public NativeMapView(MapView mapView, String cachePath, String styleUrl, String apiKey) {
public NativeMapView(MapView mapView, String cachePath) {
mMapView = mapView;
// Create the NativeMapView
mNativeMapViewPtr = nativeCreate(cachePath, styleUrl, apiKey);
mNativeMapViewPtr = nativeCreate(cachePath);
}
//
@@ -80,6 +80,10 @@ class NativeMapView {
nativeStop(mNativeMapViewPtr);
}
public void run() {
nativeRun(mNativeMapViewPtr);
}
public void rerender() {
nativeRerender(mNativeMapViewPtr);
}
@@ -92,6 +96,18 @@ class NativeMapView {
nativeCleanup(mNativeMapViewPtr);
}
public void terminate() {
nativeTerminate(mNativeMapViewPtr);
}
public boolean needsSwap() {
return nativeNeedsSwap(mNativeMapViewPtr);
}
public void swapped() {
nativeSwapped(mNativeMapViewPtr);
}
public void resize(int width, int height) {
resize(width, height, 1.0f);
}
@@ -148,11 +164,15 @@ class NativeMapView {
nativeResize(mNativeMapViewPtr, width, height, ratio, fbWidth, fbHeight);
}
public void setAppliedClasses(Set<String> appliedClasses) {
nativeSetAppliedClasses(mNativeMapViewPtr, appliedClasses);
/*public void Set<StyleSource> getActiveSources() {
return nativeGetActiveSources(mNativeMapViewPtr);
}*/
public void setAppliedClasses(List<String> classes) {
nativeSetAppliedClasses(mNativeMapViewPtr, classes);
}
public Set<String> getAppliedClasses() {
public List<String> getAppliedClasses() {
return nativeGetAppliedClasses(mNativeMapViewPtr);
}
@@ -170,14 +190,30 @@ class NativeMapView {
durationMilliseconds);
}
public void setStyleURL(String url) {
nativeSetStyleURL(mNativeMapViewPtr, url);
}
public void setStyleJSON(String newStyleJSON) {
nativeSetStyleJSON(mNativeMapViewPtr, newStyleJSON);
setStyleJSON(newStyleJSON, "");
}
public void setStyleJSON(String newStyleJSON, String base) {
nativeSetStyleJSON(mNativeMapViewPtr, newStyleJSON, base);
}
public String getStyleJSON() {
return nativeGetStyleJSON(mNativeMapViewPtr);
}
public void setAccessToken(String accessToken) {
nativeSetAccessToken(mNativeMapViewPtr, accessToken);
}
public String getAccessToken() {
return nativeGetAccessToken(mNativeMapViewPtr);
}
public void cancelTransitions() {
nativeCancelTransitions(mNativeMapViewPtr);
}
@@ -339,6 +375,10 @@ class NativeMapView {
return nativeGetDebug(mNativeMapViewPtr);
}
public void setReachability(boolean status) {
nativeSetReachability(mNativeMapViewPtr, status);
}
//
// Callbacks
//
@@ -359,7 +399,7 @@ class NativeMapView {
super.finalize();
}
private native long nativeCreate(String cachePath, String styleUrl, String apiKey);
private native long nativeCreate(String cachePath);
private native void nativeDestroy(long nativeMapViewPtr);
@@ -380,31 +420,47 @@ class NativeMapView {
private native void nativeStop(long nativeMapViewPtr);
private native void nativeRun(long nativeMapViewPtr);
private native void nativeRerender(long nativeMapViewPtr);
private native void nativeUpdate(long nativeMapViewPtr);
private native void nativeCleanup(long nativeMapViewPtr);
private native void nativeTerminate(long nativeMapViewPtr);
private native boolean nativeNeedsSwap(long nativeMapViewPtr);
private native void nativeSwapped(long nativeMapViewPtr);
private native void nativeResize(long nativeMapViewPtr, int width,
int height, float ratio);
private native void nativeResize(long nativeMapViewPtr, int width,
int height, float ratio, int fbWidth, int fbHeight);
private native void nativeSetAppliedClasses(long nativeMapViewPtr,
Set<String> appliedClasses);
//private native void Set<StyleSource> nativeGetActiveSources(long nativeMapViewPtr);
private native Set<String> nativeGetAppliedClasses(long nativeMapViewPtr);
private native void nativeSetAppliedClasses(long nativeMapViewPtr,
List<String> classes);
private native List<String> nativeGetAppliedClasses(long nativeMapViewPtr);
private native void nativeSetDefaultTransitionDuration(
long nativeMapViewPtr, long durationMilliseconds);
private native void nativeSetStyleURL(long nativeMapViewPtr, String url);
private native void nativeSetStyleJSON(long nativeMapViewPtr,
String newStyleJSON);
String newStyleJSON, String base);
private native String nativeGetStyleJSON(long nativeMapViewPtr);
private native void nativeSetAccessToken(long nativeMapViewPtr, String accessToken);
private native String nativeGetAccessToken(long nativeMapViewPtr);
private native void nativeCancelTransitions(long nativeMapViewPtr);
private native void nativeMoveBy(long nativeMapViewPtr, double dx,
@@ -473,4 +529,6 @@ class NativeMapView {
private native void nativeToggleDebug(long nativeMapViewPtr);
private native boolean nativeGetDebug(long nativeMapViewPtr);
private native void nativeSetReachability(long nativeMapViewPtr, boolean status);
}