Android Open Source - CrimeSweeper Player Location Overlay






From Project

Back to project page CrimeSweeper.

License

The source code is released under:

Apache License

If you think the Android project CrimeSweeper listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.markupartist.crimesweeper;
//  w w w . j a  va2s  .  com
import com.google.android.maps.MyLocationOverlay;
import com.google.android.maps.MapView;
import android.content.Context;
import android.location.Location;

import java.util.List;

public class PlayerLocationOverlay extends MyLocationOverlay {
    private CrimeLocationHitListener listener;
    private List<CrimeSite> mCrimeSites;

    public PlayerLocationOverlay(Context context, MapView mapView) {
        super(context, mapView);
    }

    public void setCrimeLocationHitListener(CrimeLocationHitListener listener) {
        this.listener = listener;
    }

    public void setCrimeSites(List<CrimeSite> crimeSites) {
        this.mCrimeSites = crimeSites;
    }

    @Override
    public void onLocationChanged(Location location) {
        super.onLocationChanged(location);

        if(listener == null || mCrimeSites == null) {
            return;
        }

        for(CrimeSite crimeSite : mCrimeSites) {
            if(crimeSite.intersectWithPlayer(location)) {
                listener.onCrimeLocationHit(crimeSite);
            }
        }
    }
}




Java Source Code List

com.markupartist.crimesweeper.CrimeLocationHitListener.java
com.markupartist.crimesweeper.CrimeSite.java
com.markupartist.crimesweeper.CrimeSitesLoadedListener.java
com.markupartist.crimesweeper.PlayerLocationOverlay.java
com.markupartist.crimesweeper.StartActivity.java