All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.osmdroid.util.NetworkLocationIgnorer Maven / Gradle / Ivy

There is a newer version: 6.1.20
Show newest version
package org.osmdroid.util;

import org.osmdroid.util.constants.UtilConstants;

import android.location.LocationManager;

/**
 *
 * A class to check whether we want to use a location. If there are multiple location providers,
 * i.e. network and GPS, then you want to ignore network locations shortly after a GPS location
 * because you will get another GPS location soon.
 *
 * @author Neil Boyd
 *
 */
public class NetworkLocationIgnorer implements UtilConstants {

	/** last time we got a location from the gps provider */
	private long mLastGps = 0;

	/**
	 * Whether we should ignore this location.
	 *
	 * @param pProvider
	 *            the provider that provided the location
	 * @param pTime
	 *            the time of the location
	 * @return true if we should ignore this location, false if not
	 */
	public boolean shouldIgnore(final String pProvider, final long pTime) {

		if (LocationManager.GPS_PROVIDER.equals(pProvider)) {
			mLastGps = pTime;
		} else {
			if (pTime < mLastGps + GPS_WAIT_TIME) {
				return true;
			}
		}

		return false;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy