Skip to content

Commit

Permalink
Adds one radius circle around search location when search is finished (
Browse files Browse the repository at this point in the history
  • Loading branch information
jLynx authored and comann committed Jul 28, 2016
1 parent df6879e commit 6cd0a9c
Showing 1 changed file with 108 additions and 89 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -312,18 +312,18 @@ private void updateMarkers() {
int markerSize = getResources().getDimensionPixelSize(R.dimen.pokestop_marker);

RemoteImageLoader.load(
pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl,
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
marker.setIcon(bitmapDescriptor);
marker.setZIndex(pokestop.hasLurePokemon() ? 1.0f : 0.5f);
pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl,
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
marker.setIcon(bitmapDescriptor);
marker.setZIndex(pokestop.hasLurePokemon() ? 1.0f : 0.5f);
}
}
}
);
}
} else if (pokestopsList != null && !pokestopsList.isEmpty() && !mPref.getShowPokestops()) {
Expand All @@ -345,17 +345,17 @@ public void onFetch(Bitmap bitmap) {
int markerSize = getResources().getDimensionPixelSize(R.dimen.gym_marker);

RemoteImageLoader.load(
gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()),
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
marker.setIcon(bitmapDescriptor);
gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()),
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);
marker.setIcon(bitmapDescriptor);
}
}
}
);
}
} else if(gymsList != null && !gymsList.isEmpty() && !mPref.getShowGyms()){
Expand Down Expand Up @@ -393,28 +393,28 @@ private void setPokestopsMarkers(final PokestopsEvent event) {

if (!markerKeys.contains(pokestop.getId()) && distanceFromCenterInMeters <= MapHelper.convertStepsToRadius(mPref.getSteps())) {

RemoteImageLoader.load(
pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl,
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);

Marker marker = mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(pokestop.getLatitude(), pokestop.getLongitude()))
.title(getString(R.string.pokestop))
.icon(bitmapDescriptor)
.zIndex(MapHelper.LAYER_POKESTOPS)
.alpha(pokestop.hasLurePokemon() ? 1.0f : 0.5f)
.anchor(0.5f, 0.5f));

//adding pokemons to list to be removed on next search
pokestopsList.put(pokestop.getId(), new PokestopMarkerExtended(pokestop, marker));
RemoteImageLoader.load(
pokestop.hasLurePokemon() ? lurePokeStopImageUrl : pokeStopImageUrl,
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);

Marker marker = mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(pokestop.getLatitude(), pokestop.getLongitude()))
.title(getString(R.string.pokestop))
.icon(bitmapDescriptor)
.zIndex(MapHelper.LAYER_POKESTOPS)
.alpha(pokestop.hasLurePokemon() ? 1.0f : 0.5f)
.anchor(0.5f, 0.5f));

//adding pokemons to list to be removed on next search
pokestopsList.put(pokestop.getId(), new PokestopMarkerExtended(pokestop, marker));
}
}
}
);
}
}
Expand Down Expand Up @@ -443,26 +443,26 @@ private void setGymsMarkers(final GymsEvent event){
if (!markerKeys.contains(gym.getId()) && distanceFromCenterInMeters <= MapHelper.convertStepsToRadius(mPref.getSteps())) {

RemoteImageLoader.load(
gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()),
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);

Marker marker = mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(gym.getLatitude(), gym.getLongitude()))
.title(getString(R.string.gym))
.icon(bitmapDescriptor)
.zIndex(MapHelper.LAYER_GYMS)
.anchor(0.5f, 0.5f));

// adding gyms to list to be removed on next search
gymsList.put(gym.getId(), new GymMarkerExtended(gym, marker));
gymTeamImageUrls.get(gym.getOwnedByTeam().getNumber()),
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);

Marker marker = mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(gym.getLatitude(), gym.getLongitude()))
.title(getString(R.string.gym))
.icon(bitmapDescriptor)
.zIndex(MapHelper.LAYER_GYMS)
.anchor(0.5f, 0.5f));

// adding gyms to list to be removed on next search
gymsList.put(gym.getId(), new GymMarkerExtended(gym, marker));
}
}
}
);
}
}
Expand All @@ -488,31 +488,31 @@ private void setPokemonMarkers(final List<CatchablePokemon> pokeList){
if (showablePokemonIDs.contains(pokemonId)) {

RemoteImageLoader.load(
"http://serebii.net/pokemongo/pokemon/"+PokemonIdUtils.getCorrectPokemonImageId(pokemonId.getNumber())+".png",
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);

//Setting marker since we got image
//int resourceID = getResources().getIdentifier("p" + poke.getPokemonId().getNumber(), "drawable", getActivity().getPackageName());
final Marker marker = mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(poke.getLatitude(), poke.getLongitude()))
.title(PokemonIdUtils.getLocalePokemonName(getContext(), poke.getPokemonId().name()))
.icon(bitmapDescriptor)
.zIndex(MapHelper.LAYER_POKEMONS)
.anchor(0.5f, 0.5f));

//adding pokemons to list to be removed on next search
PokemonMarkerExtended markerExtended = new PokemonMarkerExtended(poke, marker);
markerList.put(poke.getSpawnPointId(), markerExtended);
MarkerRefreshController.getInstance().postMarker(markerExtended);

"http://serebii.net/pokemongo/pokemon/"+PokemonIdUtils.getCorrectPokemonImageId(pokemonId.getNumber())+".png",
markerSize, markerSize, null,
getActivity(),
new RemoteImageLoader.Callback() {
@Override
public void onFetch(Bitmap bitmap) {

BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(bitmap);

//Setting marker since we got image
//int resourceID = getResources().getIdentifier("p" + poke.getPokemonId().getNumber(), "drawable", getActivity().getPackageName());
final Marker marker = mGoogleMap.addMarker(new MarkerOptions()
.position(new LatLng(poke.getLatitude(), poke.getLongitude()))
.title(PokemonIdUtils.getLocalePokemonName(getContext(), poke.getPokemonId().name()))
.icon(bitmapDescriptor)
.zIndex(MapHelper.LAYER_POKEMONS)
.anchor(0.5f, 0.5f));

//adding pokemons to list to be removed on next search
PokemonMarkerExtended markerExtended = new PokemonMarkerExtended(poke, marker);
markerList.put(poke.getSpawnPointId(), markerExtended);
MarkerRefreshController.getInstance().postMarker(markerExtended);

}
}
}
);

//Increase founded pokemon counter
Expand Down Expand Up @@ -598,6 +598,25 @@ private String getExpirationBreakdown(long millis) {
public void onEvent(CatchablePokemonEvent event) {
setPokemonMarkers(event.getCatchablePokemon());
drawCatchedPokemonCircle(event.getLat(), event.getLongitude());
if(nianticManager.getCurrentScan() == 1) {
currentCenter.setLatitude(event.getLat());
currentCenter.setLongitude(event.getLongitude());
}
if(nianticManager.getCurrentScan() == nianticManager.getPendingSearch())
{
if (mGoogleMap != null) {

if (mPref.getShowScannedPlaces()) {
double radiusInMeters = MapHelper.convertStepsToRadius(mPref.getSteps());
int strokeColor = 0x44DC990D; // outline
int shadeColor = 0x44DCD90D; // fill

CircleOptions circleOptions = new CircleOptions().center(new LatLng(currentCenter.getLatitude(), currentCenter.getLongitude())).radius(radiusInMeters).fillColor(shadeColor).strokeColor(strokeColor).strokeWidth(8);
clearPokemonCircles();
userSelectedPositionCircles.add(mGoogleMap.addCircle(circleOptions));
}
}
}
}

/**
Expand Down Expand Up @@ -651,10 +670,10 @@ public void onEvent(GymsEvent event) {
* @param event
*/

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(MarkerExpired event){
removeExpiredMarker(event.getData());
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(MarkerExpired event){
removeExpiredMarker(event.getData());
}

@Subscribe(threadMode = ThreadMode.MAIN)
public void onEvent(MarkerUpdate event){
Expand Down

0 comments on commit 6cd0a9c

Please sign in to comment.