Permalink
Browse files

renamed baloon to balloon

  • Loading branch information...
1 parent 243c3dd commit 3c73914487418474e19f104c22a472337e9991be Barry@Work committed Jul 13, 2011
@@ -23,7 +23,7 @@
public static final int transparent_panel=0x7f050000;
}
public static final class layout {
- public static final int baloon=0x7f030000;
+ public static final int balloon=0x7f030000;
public static final int main=0x7f030001;
}
public static final class string {
@@ -15,7 +15,7 @@
<keystore.linux>/home/barry/dev/android/market/android-key.keystore</keystore.linux>
<!-- change the following for Linux vs. Windows -->
- <target.device>emulator</target.device>
+ <target.device>usb</target.device>
<sdk>${sdk.win}</sdk>
<keystore>${keystore.win}</keystore>
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
-<com.barryku.android.hellomap.BaloonLayout
+<com.barryku.android.hellomap.BalloonLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/transparent_panel"
android:layout_width="fill_parent"
@@ -29,5 +29,5 @@
android:clickable="true"
/>
</RelativeLayout>
-</com.barryku.android.hellomap.BaloonLayout>
+</com.barryku.android.hellomap.BalloonLayout>
@@ -8,11 +8,11 @@
import android.util.AttributeSet;
import android.widget.LinearLayout;
-public class BaloonLayout extends LinearLayout {
+public class BalloonLayout extends LinearLayout {
- public BaloonLayout(Context context, AttributeSet attrs) {
+ public BalloonLayout(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
}
@@ -37,7 +37,7 @@ public void addOverlay(OverlayItem overlay) {
@Override
public boolean onTap(GeoPoint point, MapView view) {
Log.d(LOG_TAG, "onTap point/view: " + point + "," + view);
- parent.removeBaloonTip();
+ parent.removeBalloonTip();
return super.onTap(point, view);
}
@@ -42,24 +42,24 @@
private List<Overlay> mapOverlays;
private Drawable drawable;
private HelloItemizedOverlay itemizedOverlay;
- private BaloonLayout noteBaloon;
+ private BalloonLayout noteBalloon;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
- setupBaloonLayout();
+ setupBalloonLayout();
mapView = (MapView) findViewById(R.id.mapview);
mapView.setBuiltInZoomControls(true);
mapOverlays = mapView.getOverlays();
drawable = this.getResources().getDrawable(R.drawable.androidmarker);
itemizedOverlay = new HelloItemizedOverlay(this, drawable);
try {
- setupKmlOverlays();
- //setupJsonOverlays();
+ //setupKmlOverlays();
+ setupJsonOverlays();
mapOverlays.add(itemizedOverlay);
adjustMapZoomCenter();
} catch (Exception e) {
@@ -100,7 +100,7 @@ private void setupKmlOverlays() throws Exception {
KmlRoot kml = serializer.read(KmlRoot.class, is);
List<Placemark> markers = kml.getDocument().getPlacemarks();
for (Placemark marker: markers) {
- point = getGeoPoint(marker.getCoordinates());
+ point = getGeoPointFromCoordiate(marker.getCoordinates());
Log.d(LOG_TAG, marker.getName());
itemizedOverlay.addOverlay(new OverlayItem(point, marker.getName(), marker.getDescription()));
}
@@ -138,19 +138,11 @@ private void setupJsonOverlays() throws Exception {
}
- private void setupBaloonLayout() {
+ private void setupBalloonLayout() {
LayoutInflater layoutInflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
- noteBaloon = (BaloonLayout) layoutInflater.inflate(R.layout.baloon, null);
-
- /**
- RelativeLayout.LayoutParams layoutParams = new
- RelativeLayout.LayoutParams(200,200);
- layoutParams.addRule(RelativeLayout.CENTER_VERTICAL);
- layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
- noteBaloon.setLayoutParams(layoutParams);
- **/
-
- TextView title = (TextView) noteBaloon.findViewById(R.id.note_txt);
+ noteBalloon = (BalloonLayout) layoutInflater.inflate(R.layout.balloon, null);
+
+ TextView title = (TextView) noteBalloon.findViewById(R.id.note_txt);
title.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
@@ -159,7 +151,7 @@ public void onClick(View v) {
});
- ImageView goButton = (ImageView) noteBaloon.findViewById(R.id.go_button);
+ ImageView goButton = (ImageView) noteBalloon.findViewById(R.id.go_button);
goButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
@@ -169,21 +161,8 @@ public void onClick(View v) {
});
}
- private int placeUrlIndex;
- public void setPlaceUrlIndex(int index) {
- placeUrlIndex = index;
- }
-
- private void goPlace() {
- if (placeUrlMap != null) {
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(placeUrlMap.get(placeUrlIndex)));
- startActivity(intent);
- } else {
- removeBaloonTip();
- }
- }
-
- private GeoPoint getGeoPoint(String coordinate) {
+
+ private GeoPoint getGeoPointFromCoordiate(String coordinate) {
StringTokenizer st = new StringTokenizer(coordinate, ",");
float lo = Float.parseFloat(st.nextToken());
float la = Float.parseFloat(st.nextToken());
@@ -194,17 +173,32 @@ private GeoPoint getGeoPoint(String coordinate) {
protected boolean isRouteDisplayed() {
return false;
}
-
+
+ private void goPlace() {
+ if (placeUrlMap != null) {
+ Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(placeUrlMap.get(placeUrlIndex)));
+ startActivity(intent);
+ } else {
+ removeBalloonTip();
+ }
+ }
+
+ //the following methods are called by HelloItemizedOverlay.onTap();
+ private int placeUrlIndex;
+ public void setPlaceUrlIndex(int index) {
+ placeUrlIndex = index;
+ }
+
public void doTap(OverlayItem noteOverlay, String txt) {
- mapView.removeView(noteBaloon);
- noteBaloon.setVisibility(View.VISIBLE);
- ((TextView)noteBaloon.findViewById(R.id.note_txt)).setText(txt);
+ mapView.removeView(noteBalloon);
+ noteBalloon.setVisibility(View.VISIBLE);
+ ((TextView)noteBalloon.findViewById(R.id.note_txt)).setText(txt);
MapController mapController = mapView.getController();
mapController.animateTo(noteOverlay.getPoint());
- mapView.addView(noteBaloon, new MapView.LayoutParams(12*txt.getBytes().length,55,noteOverlay.getPoint(),MapView.LayoutParams.BOTTOM_CENTER));
+ mapView.addView(noteBalloon, new MapView.LayoutParams(12*txt.getBytes().length,55,noteOverlay.getPoint(),MapView.LayoutParams.BOTTOM_CENTER));
}
- public void removeBaloonTip() {
- noteBaloon.setVisibility(View.GONE);
+ public void removeBalloonTip() {
+ noteBalloon.setVisibility(View.GONE);
}
}

0 comments on commit 3c73914

Please sign in to comment.