Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed GoogleMaps/lib/CLDC11.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,29 @@
import com.google.android.gms.maps.model.LatLng;
import android.graphics.BitmapFactory;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.view.ViewGroup;
import android.graphics.BitmapFactory;
import android.graphics.Point;
import android.os.Bundle;
import android.os.Looper;
import android.view.View;
import android.view.ViewGroup;
import com.codename1.impl.android.AndroidImplementation;
import com.codename1.impl.android.AndroidNativeUtil;
import com.codename1.impl.android.LifecycleListener;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.codename1.io.Log;
import com.google.android.gms.maps.CameraUpdateFactory;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.MapView;
import com.google.android.gms.maps.MapsInitializer;
import android.os.Looper;
import android.view.View;
import com.google.android.gms.maps.model.PolylineOptions;
import com.google.android.gms.maps.model.Polyline;
import android.graphics.Point;
//import com.codename1.impl.android.AndroidImplementation.PeerDraw;
import com.codename1.io.Log;
import com.codename1.ui.Display;
import com.google.android.gms.maps.OnMapReadyCallback;
import com.google.android.gms.maps.model.BitmapDescriptorFactory;
import com.google.android.gms.maps.model.CameraPosition;
import com.google.android.gms.maps.model.LatLng;
import com.google.android.gms.maps.model.Marker;
import com.google.android.gms.maps.model.MarkerOptions;
import com.google.android.gms.maps.model.Polyline;
import com.google.android.gms.maps.model.PolylineOptions;
import java.util.HashMap;

public class InternalNativeMapsImpl implements LifecycleListener {
private int mapId;
Expand All @@ -64,21 +70,25 @@ public class InternalNativeMapsImpl implements LifecycleListener {
private Point lastPoint;
private boolean showMyLocation;
private boolean rotateGestureEnabled;
private static boolean initialized = false;

static {

if(AndroidNativeUtil.getActivity() != null) {
android.util.Log.d("CN1 Maps", "Initializing maps");
android.util.Log.i("CN1 Maps", "Initializing maps");
if (Looper.getMainLooper().getThread() == Thread.currentThread()) {
android.util.Log.i("CN1 Mapss", "static()->getMainLooper:ok");
initMaps();
} else {
AndroidNativeUtil.getActivity().runOnUiThread(new Runnable() {
public void run() {
android.util.Log.d("CN1 Mapss", "static()->runOnUiThread:ok");
initMaps();
}
});
}
} else {
android.util.Log.d("CN1 Mapss", "Did not initialize maps because activity was null");
android.util.Log.i("CN1 Mapss", "static()->Did not initialize maps because activity was null");
}
AndroidNativeUtil.registerViewRenderer(MapView.class, new AndroidNativeUtil.BitmapViewRenderer() {

Expand All @@ -98,6 +108,7 @@ public Bitmap renderViewOnBitmap(View v, final int w, final int h) {

}
});

}

private static class PeerImage {
Expand Down Expand Up @@ -236,6 +247,7 @@ public void run() {

private static boolean initialized = false;
private static void initMaps() {

if (!initialized) {
initialized = true;
try {
Expand All @@ -246,12 +258,15 @@ private static void initMaps() {
v.onCreate(AndroidNativeUtil.getActivationBundle());
v.onResume();
v.getMap();
android.util.Log.i("CN1 Mapss", "initMaps()->initialized:"+initialized);
} catch (Exception e) {
supported = false;
System.out.println("Failed to initialize, google play services not installed: " + e);
e.printStackTrace();
}
}
} else
android.util.Log.i("CN1 Mapss", "initMaps()->initialized:"+initialized);

}

public long addMarker(final byte[] icon, final double lat, final double lon, final String text, final String snippet, final boolean callback) {
Expand All @@ -261,7 +276,7 @@ public long addMarker(final byte[] icon, final double lat, final double lon, fin
public void run() {
MarkerOptions mo = new MarkerOptions();
if(text != null) {
mo.title(text);
mo.title(text);
}
if(icon != null) {
Bitmap bmp = BitmapFactory.decodeByteArray(icon, 0, icon.length);
Expand All @@ -271,8 +286,12 @@ public void run() {
mo.snippet(snippet);
}
mo.position(new LatLng(lat, lon));

Marker m = mapInstance.addMarker(mo);

if (text!=null)
m.showInfoWindow();

if(callback) {
listeners.put(m, key);
}
Expand Down Expand Up @@ -470,6 +489,7 @@ public void onMapLongClick(LatLng point) {
});
mapInstance.setMyLocationEnabled(showMyLocation);
mapInstance.getUiSettings().setRotateGesturesEnabled(rotateGestureEnabled);
android.util.Log.i("CN1 Mapss", "installListeners()->loaded:ok");
}
});

Expand Down Expand Up @@ -501,6 +521,8 @@ public void run() {
//PeerImage.submitUpdate(view, view.getWidth(), view.getHeight());
}
});
android.util.Log.i("CN1 Mapss", "createNativeMap()->mapInstance:"+(mapInstance!=null?"ok":"null"));
android.util.Log.i("CN1 Mapss", "createNativeMap()->view :"+(view!=null?"ok":"null"));
return view;
}

Expand Down Expand Up @@ -588,44 +610,51 @@ public boolean isSupported() {
}

public void onCreate(Bundle savedInstanceState) {
android.util.Log.d("CN1 Mapss", "onCreate()");
try {
if (view != null) {
view.onCreate(savedInstanceState);
initMaps();
mapInstance = view.getMap();


}
} catch (Exception e) {
e.printStackTrace();
}
}

public void onResume() {
android.util.Log.i("CN1 Mapss", "onResume()");
try {
if(view != null) {
mapInstance = view.getMap();

view.onResume();
mapInstance = view.getMap();
installListeners();
}
android.util.Log.i("CN1 Mapss", "onResume()->ok");
}else
android.util.Log.i("CN1 Mapss", "onResume()->view:null");

} catch (Exception e) {
e.printStackTrace();
android.util.Log.e("CN1 Mapss", "onResume()->err:"+e.toString());
}
}

public void onPause() {
android.util.Log.i("CN1 Mapss", "onPause()");
try {
if(view != null) {
view.onPause();

}
} catch (Exception ex) {
ex.printStackTrace();
android.util.Log.e("CN1 Mapss", "onPause()->err:"+ex.toString());
}
}

public void onDestroy() {
android.util.Log.i("CN1 Mapss", "onDestroy()");
try {
if(view != null) {
if (view.getParent() != null) {
Expand All @@ -636,6 +665,7 @@ public void onDestroy() {
}
} catch (Exception e) {
e.printStackTrace();
android.util.Log.e("CN1 Mapss", "onPause()->err:"+e.toString());
}
}

Expand All @@ -650,6 +680,7 @@ public void onSaveInstanceState(Bundle b) {
}

public void onLowMemory() {
android.util.Log.i("CN1 Mapss", "onLowMemory()");
try {
if(view != null) {
view.onLowMemory();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ -(long long)addMarker:(NSData*)param param1:(double)param1 param2:(double)param2
} else {
marker.userData = nil;
}

//mapView.appearAnimation = kGMSMarkerAnimationPop
mapView.selectedMarker = marker;
[marker retain];
[pool release];
});
Expand Down
158 changes: 79 additions & 79 deletions GoogleMaps/nbproject/project.properties
Original file line number Diff line number Diff line change
@@ -1,79 +1,79 @@
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=GoogleMaps
application.vendor=Codename One
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/GoogleMaps.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.CLDC11.jar=lib/CLDC11.jar
file.reference.CodenameOne.jar=lib/CodenameOne.jar
file.reference.CodenameOne_SRC.zip=lib/CodenameOne_SRC.zip
file.reference.GoogleMaps-override=override
includes=**
jar.compress=false
javac.classpath=\
${file.reference.CLDC11.jar}:\
${file.reference.CodenameOne.jar}:\
${file.reference.CodenameOne_SRC.zip}:\
${file.reference.GoogleMaps-override}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.processorpath=\
${javac.classpath}
javac.source=1.5
javac.target=1.5
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=windows-1252
src.dir=src
test.src.dir=test
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=
annotation.processing.run.all.processors=true
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
application.title=GoogleMaps
application.vendor=Codename One
build.classes.dir=${build.dir}/classes
build.classes.excludes=**/*.java,**/*.form
# This directory is removed when the project is cleaned:
build.dir=build
build.generated.dir=${build.dir}/generated
build.generated.sources.dir=${build.dir}/generated-sources
# Only compile against the classpath explicitly listed here:
build.sysclasspath=ignore
build.test.classes.dir=${build.dir}/test/classes
build.test.results.dir=${build.dir}/test/results
# Uncomment to specify the preferred debugger connection transport:
#debug.transport=dt_socket
debug.classpath=\
${run.classpath}
debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/GoogleMaps.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.CLDC11.jar=lib/CLDC11.jar
file.reference.CodenameOne.jar=lib/CodenameOne.jar
file.reference.CodenameOne_SRC.zip=lib/CodenameOne_SRC.zip
includes=**
jar.compress=true
javac.classpath=\
${file.reference.CLDC11.jar}:\
${file.reference.CodenameOne.jar}:\
${file.reference.CodenameOne_SRC.zip}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
javac.external.vm=false
javac.processorpath=\
${javac.classpath}
javac.source=1.8
javac.target=1.8
javac.test.classpath=\
${javac.classpath}:\
${build.classes.dir}
javac.test.processorpath=\
${javac.test.classpath}
javadoc.additionalparam=
javadoc.author=false
javadoc.encoding=${source.encoding}
javadoc.noindex=false
javadoc.nonavbar=false
javadoc.notree=false
javadoc.private=false
javadoc.splitindex=true
javadoc.use=true
javadoc.version=false
javadoc.windowtitle=
manifest.file=manifest.mf
meta.inf.dir=${src.dir}/META-INF
mkdist.disabled=false
platform.active=default_platform
run.classpath=\
${javac.classpath}:\
${build.classes.dir}
# Space-separated list of JVM arguments used when running the project
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
# or test-sys-prop.name=value to set system properties for unit tests):
run.jvmargs=
run.test.classpath=\
${javac.test.classpath}:\
${build.test.classes.dir}
source.encoding=windows-1252
src.dir=src
test.src.dir=test
Loading