@Override public void onSelects(final List<EntitySelect> entitySelects) { if (mWaitfor != null) { mWaitfor.close(); mWaitfor = null; } if (entitySelects != null) { mSelectObject = new PopWindowSelectObject(this, mEntityRelation, entitySelects, this); mSelectObject.show(); } }
@Override public void onRelation(final EntityLocation entityLocation, final boolean auto) { if (mWaitfor != null) { mWaitfor.close(); mWaitfor = null; } if (!auto) { int id = R.string.request_relation_success; if (entityLocation == null) id = R.string.request_relation_fail; final Toast toast = Toast.makeText(this, id, Toast.LENGTH_LONG); toast.show(); } if (mHandler == null) mHandler = new Handler(); final int delayed = 2 * 60 * 1000; mHandler.postDelayed(this, delayed); if (mEntityRelation == null || entityLocation == null) { mapViewRefresh(mLatitude, mLongitude, mZoom); return; } final String to = mEntityRelation.getTo(); if (to == null) { mapViewRefresh(mLatitude, mLongitude, mZoom); return; } final String sColor = entityLocation.getColor(); final List<EntityLocations> locations = entityLocation.getLocations(); if (locations == null) { mapViewRefresh(mLatitude, mLongitude, mZoom); return; } int color = 0, alpha = 20; try { color = Color.parseColor(sColor); } catch (Exception e) { color = Color.argb(alpha, 255, 0, 0); } color = Color.argb(alpha, Color.red(color), Color.green(color), Color.blue(color)); if (locations.size() > 0) { mBaiduMap.clear(); int i = 0; for (final EntityLocations entityLocations : locations) { addTime(sColor, entityLocations, i); final int j = i + 1; final String name = to.toLowerCase(Locale.ENGLISH) + j; final double latitude = entityLocations.getLatitude(); final double longitude = entityLocations.getLongitude(); final double accuracy = entityLocations.getRadius(); if (i == 0) { mLatitude = latitude; mLongitude = longitude; } final MarkerOptions markerOptions = new MarkerOptions(); final CircleOptions circleOptions = new CircleOptions(); final LatLng latLng = new LatLng(latitude, longitude); markerOptions.position(latLng); circleOptions.center(latLng); circleOptions.radius((int) accuracy); circleOptions.fillColor(color); circleOptions.stroke(new Stroke(1, color)); if (mBitmapDescriptor.containsKey(name)) { final BitmapDescriptor bitmapDescriptor = mBitmapDescriptor.get(name); markerOptions.icon(bitmapDescriptor); mBaiduMap.addOverlay(markerOptions); } else { final BitmapDescriptor bitmapDescriptor = Images.getIcon(name); if (bitmapDescriptor != null) { markerOptions.icon(bitmapDescriptor); mBitmapDescriptor.put(name, bitmapDescriptor); mBaiduMap.addOverlay(markerOptions); } } mBaiduMap.addOverlay(circleOptions); i++; } mapViewRefresh(mLatitude, mLongitude, 17.0f, 800); } }