Search in sources :

Example 1 with CacheOverlayItemImpl

use of carnero.cgeo.mapinterfaces.CacheOverlayItemImpl in project c-geo by just-radovan.

the class cgMapOverlay method onTap.

@Override
public boolean onTap(int index) {
    try {
        if (items.size() <= index) {
            return false;
        }
        if (waitDialog == null) {
            waitDialog = new ProgressDialog(context);
            waitDialog.setMessage("loading details...");
            waitDialog.setCancelable(false);
        }
        waitDialog.show();
        CacheOverlayItemImpl item = items.get(index);
        cgCoord coordinate = item.getCoord();
        if (coordinate.type != null && coordinate.type.equalsIgnoreCase("cache") == true && coordinate.geocode != null && coordinate.geocode.length() > 0) {
            Intent popupIntent = new Intent(context, cgeopopup.class);
            popupIntent.putExtra("fromdetail", fromDetail);
            popupIntent.putExtra("geocode", coordinate.geocode);
            context.startActivity(popupIntent);
        } else if (coordinate.type != null && coordinate.type.equalsIgnoreCase("waypoint") == true && coordinate.id != null && coordinate.id > 0) {
            Intent popupIntent = new Intent(context, cgeowaypoint.class);
            popupIntent.putExtra("waypoint", coordinate.id);
            popupIntent.putExtra("geocode", coordinate.geocode);
            context.startActivity(popupIntent);
        } else {
            waitDialog.dismiss();
            return false;
        }
        waitDialog.dismiss();
    } catch (Exception e) {
        Log.e(cgSettings.tag, "cgMapOverlay.onTap: " + e.toString());
    }
    return false;
}
Also used : carnero.cgeo.cgCoord(carnero.cgeo.cgCoord) carnero.cgeo.cgeowaypoint(carnero.cgeo.cgeowaypoint) Intent(android.content.Intent) ProgressDialog(android.app.ProgressDialog) CacheOverlayItemImpl(carnero.cgeo.mapinterfaces.CacheOverlayItemImpl)

Example 2 with CacheOverlayItemImpl

use of carnero.cgeo.mapinterfaces.CacheOverlayItemImpl in project c-geo by just-radovan.

the class cgMapOverlay method drawInternal.

private void drawInternal(Canvas canvas, MapProjectionImpl projection) {
    MapFactory mapFactory = settings.getMapFactory();
    if (displayCircles) {
        if (blockedCircle == null) {
            blockedCircle = new Paint();
            blockedCircle.setAntiAlias(true);
            blockedCircle.setStrokeWidth(1.0f);
        }
        if (setfil == null)
            setfil = new PaintFlagsDrawFilter(0, Paint.FILTER_BITMAP_FLAG);
        if (remfil == null)
            remfil = new PaintFlagsDrawFilter(Paint.FILTER_BITMAP_FLAG, 0);
        canvas.setDrawFilter(setfil);
        for (CacheOverlayItemImpl item : items) {
            final cgCoord itemCoord = item.getCoord();
            float[] result = new float[1];
            Location.distanceBetween(itemCoord.latitude, itemCoord.longitude, itemCoord.latitude, itemCoord.longitude + 1, result);
            final float longitudeLineDistance = result[0];
            GeoPointImpl itemGeo = mapFactory.getGeoPointBase((int) (itemCoord.latitude * 1e6), (int) (itemCoord.longitude * 1e6));
            GeoPointImpl leftGeo = mapFactory.getGeoPointBase((int) (itemCoord.latitude * 1e6), (int) ((itemCoord.longitude - 161 / longitudeLineDistance) * 1e6));
            projection.toPixels(itemGeo, center);
            projection.toPixels(leftGeo, left);
            int radius = center.x - left.x;
            final String type = item.getType();
            if (type == null || "multi".equals(type) || "mystery".equals(type) || "virtual".equals(type)) {
                blockedCircle.setColor(0x66000000);
                blockedCircle.setStyle(Style.STROKE);
                canvas.drawCircle(center.x, center.y, radius, blockedCircle);
            } else {
                blockedCircle.setColor(0x66BB0000);
                blockedCircle.setStyle(Style.STROKE);
                canvas.drawCircle(center.x, center.y, radius, blockedCircle);
                blockedCircle.setColor(0x44BB0000);
                blockedCircle.setStyle(Style.FILL);
                canvas.drawCircle(center.x, center.y, radius, blockedCircle);
            }
        }
        canvas.setDrawFilter(remfil);
    }
}
Also used : carnero.cgeo.cgCoord(carnero.cgeo.cgCoord) MapFactory(carnero.cgeo.mapinterfaces.MapFactory) GeoPointImpl(carnero.cgeo.mapinterfaces.GeoPointImpl) Paint(android.graphics.Paint) PaintFlagsDrawFilter(android.graphics.PaintFlagsDrawFilter) CacheOverlayItemImpl(carnero.cgeo.mapinterfaces.CacheOverlayItemImpl) carnero.cgeo.cgeowaypoint(carnero.cgeo.cgeowaypoint) Point(android.graphics.Point) Paint(android.graphics.Paint)

Example 3 with CacheOverlayItemImpl

use of carnero.cgeo.mapinterfaces.CacheOverlayItemImpl in project c-geo by just-radovan.

the class cgMapOverlay method updateItems.

public void updateItems(ArrayList<CacheOverlayItemImpl> itemsPre) {
    if (itemsPre == null) {
        return;
    }
    for (CacheOverlayItemImpl item : itemsPre) {
        item.setMarker(boundCenterBottom(item.getMarker(0)));
    }
    //		items.clear();
    //		if (itemsPre.size() > 0) {
    items = (ArrayList<CacheOverlayItemImpl>) itemsPre.clone();
    //		}
    // to reset tap during data change
    setLastFocusedItemIndex(-1);
    populate();
}
Also used : CacheOverlayItemImpl(carnero.cgeo.mapinterfaces.CacheOverlayItemImpl)

Example 4 with CacheOverlayItemImpl

use of carnero.cgeo.mapinterfaces.CacheOverlayItemImpl in project c-geo by just-radovan.

the class cgMapOverlay method infoDialog.

public void infoDialog(int index) {
    final CacheOverlayItemImpl item = items.get(index);
    final cgCoord coordinate = item.getCoord();
    if (coordinate == null) {
        Log.e(cgSettings.tag, "cgMapOverlay:infoDialog: No coordinates given");
        return;
    }
    try {
        AlertDialog.Builder dialog = new AlertDialog.Builder(context);
        dialog.setCancelable(true);
        if (coordinate.type.equalsIgnoreCase("cache")) {
            dialog.setTitle("cache");
            String cacheType;
            if (cgBase.cacheTypesInv.containsKey(coordinate.typeSpec) == true) {
                cacheType = cgBase.cacheTypesInv.get(coordinate.typeSpec);
            } else {
                cacheType = cgBase.cacheTypesInv.get("mystery");
            }
            dialog.setMessage(Html.fromHtml(item.getTitle()) + "\n\ngeocode: " + coordinate.geocode.toUpperCase() + "\ntype: " + cacheType);
            if (fromDetail == false) {
                dialog.setPositiveButton("detail", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        Intent cachesIntent = new Intent(context, cgeodetail.class);
                        cachesIntent.putExtra("geocode", coordinate.geocode.toUpperCase());
                        context.startActivity(cachesIntent);
                        dialog.cancel();
                    }
                });
            } else {
                dialog.setPositiveButton("navigate", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        cgeonavigate navigateActivity = new cgeonavigate();
                        cgeonavigate.coordinates = new ArrayList<cgCoord>();
                        cgeonavigate.coordinates.add(coordinate);
                        Intent navigateIntent = new Intent(context, navigateActivity.getClass());
                        navigateIntent.putExtra("latitude", coordinate.latitude);
                        navigateIntent.putExtra("longitude", coordinate.longitude);
                        navigateIntent.putExtra("geocode", coordinate.geocode.toUpperCase());
                        context.startActivity(navigateIntent);
                        dialog.cancel();
                    }
                });
            }
        } else {
            dialog.setTitle("waypoint");
            String waypointType;
            if (cgBase.cacheTypesInv.containsKey(coordinate.typeSpec) == true) {
                waypointType = cgBase.waypointTypes.get(coordinate.typeSpec);
            } else {
                waypointType = cgBase.waypointTypes.get("waypoint");
            }
            dialog.setMessage(Html.fromHtml(item.getTitle()) + "\n\ntype: " + waypointType);
            dialog.setPositiveButton("navigate", new DialogInterface.OnClickListener() {

                public void onClick(DialogInterface dialog, int id) {
                    cgeonavigate navigateActivity = new cgeonavigate();
                    cgeonavigate.coordinates = new ArrayList<cgCoord>();
                    cgeonavigate.coordinates.add(coordinate);
                    Intent navigateIntent = new Intent(context, navigateActivity.getClass());
                    navigateIntent.putExtra("latitude", coordinate.latitude);
                    navigateIntent.putExtra("longitude", coordinate.longitude);
                    navigateIntent.putExtra("geocode", coordinate.name);
                    context.startActivity(navigateIntent);
                    dialog.cancel();
                }
            });
        }
        dialog.setNegativeButton("dismiss", new DialogInterface.OnClickListener() {

            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        AlertDialog alert = dialog.create();
        alert.show();
    } catch (Exception e) {
        Log.e(cgSettings.tag, "cgMapOverlay.infoDialog: " + e.toString());
    }
}
Also used : AlertDialog(android.app.AlertDialog) carnero.cgeo.cgCoord(carnero.cgeo.cgCoord) DialogInterface(android.content.DialogInterface) ArrayList(java.util.ArrayList) Intent(android.content.Intent) CacheOverlayItemImpl(carnero.cgeo.mapinterfaces.CacheOverlayItemImpl) carnero.cgeo.cgeowaypoint(carnero.cgeo.cgeowaypoint) Point(android.graphics.Point) Paint(android.graphics.Paint) carnero.cgeo.cgeonavigate(carnero.cgeo.cgeonavigate) carnero.cgeo.cgeodetail(carnero.cgeo.cgeodetail)

Aggregations

CacheOverlayItemImpl (carnero.cgeo.mapinterfaces.CacheOverlayItemImpl)4 carnero.cgeo.cgCoord (carnero.cgeo.cgCoord)3 carnero.cgeo.cgeowaypoint (carnero.cgeo.cgeowaypoint)3 Intent (android.content.Intent)2 Paint (android.graphics.Paint)2 Point (android.graphics.Point)2 AlertDialog (android.app.AlertDialog)1 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 PaintFlagsDrawFilter (android.graphics.PaintFlagsDrawFilter)1 carnero.cgeo.cgeodetail (carnero.cgeo.cgeodetail)1 carnero.cgeo.cgeonavigate (carnero.cgeo.cgeonavigate)1 GeoPointImpl (carnero.cgeo.mapinterfaces.GeoPointImpl)1 MapFactory (carnero.cgeo.mapinterfaces.MapFactory)1 ArrayList (java.util.ArrayList)1