Skip to content

Commit bdb07f5

Browse files
itderrickhcomann
authored andcommitted
Addressed issue #196 (#200)
Filtered the notifications based on showable Pokemon settings.
1 parent b5ca634 commit bdb07f5

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

app/src/main/java/com/omkarmoghe/pokemap/controllers/service/PokemonNotificationService.java

+16-8
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
import org.greenrobot.eventbus.Subscribe;
2626

2727
import java.util.List;
28+
import java.util.Set;
2829
import java.util.concurrent.TimeUnit;
2930

31+
import POGOProtos.Enums.PokemonIdOuterClass;
32+
3033

3134
public class PokemonNotificationService extends Service{
3235

@@ -136,15 +139,20 @@ public void onEvent(CatchablePokemonEvent event) {
136139
if(!catchablePokemon.isEmpty()){
137140
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
138141
inboxStyle.setBigContentTitle(catchablePokemon.size() + getString(R.string.notification_service_pokemon_in_area));
142+
Set<PokemonIdOuterClass.PokemonId> showablePokemonIDs = preffs.getShowablePokemonIDs();
143+
139144
for(CatchablePokemon cp : catchablePokemon){
140-
Location pokeLocation = new Location("");
141-
pokeLocation.setLatitude(cp.getLatitude());
142-
pokeLocation.setLongitude(cp.getLongitude());
143-
long remainingTime = cp.getExpirationTimestampMs() - System.currentTimeMillis();
144-
inboxStyle.addLine(cp.getPokemonId().name() + "(" +
145-
TimeUnit.MILLISECONDS.toMinutes(remainingTime) +
146-
" "+getString(R.string.minutes)+"," + Math.ceil(pokeLocation.distanceTo(myLoc)) + " "+getString(
147-
R.string.meters)+")");
145+
//Only show the notification if the Pokemon is in the preference list
146+
if(showablePokemonIDs.contains(cp.getPokemonId())) {
147+
Location pokeLocation = new Location("");
148+
pokeLocation.setLatitude(cp.getLatitude());
149+
pokeLocation.setLongitude(cp.getLongitude());
150+
long remainingTime = cp.getExpirationTimestampMs() - System.currentTimeMillis();
151+
inboxStyle.addLine(cp.getPokemonId().name() + "(" +
152+
TimeUnit.MILLISECONDS.toMinutes(remainingTime) +
153+
" "+getString(R.string.minutes)+"," + Math.ceil(pokeLocation.distanceTo(myLoc)) + " "+getString(
154+
R.string.meters)+")");
155+
}
148156
}
149157

150158
builder.setStyle(inboxStyle);

0 commit comments

Comments
 (0)