Search in sources :

Example 1 with ProjectionTask

use of com.peterlaurence.trekadvisor.core.projection.ProjectionTask in project TrekAdvisor by peterLaurence.

the class MapViewFragment method onLocationReceived.

private void onLocationReceived(Location location) {
    if (isHidden())
        return;
    if (location != null) {
        /* If there is no TileView, no need to go further */
        if (mTileView == null) {
            return;
        }
        /* In the case there is no Projection defined, the latitude and longitude are used */
        Projection projection = mMap.getProjection();
        if (projection != null) {
            ProjectionTask projectionTask = new ProjectionTask(this, location.getLatitude(), location.getLongitude(), projection);
            projectionTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            updatePosition(location.getLongitude(), location.getLatitude());
        }
        /* If the user wants to see the speed */
        if (mSpeedListener != null) {
            mSpeedListener.onSpeed(location.getSpeed(), SpeedUnit.KM_H);
        }
    }
}
Also used : ProjectionTask(com.peterlaurence.trekadvisor.core.projection.ProjectionTask) Projection(com.peterlaurence.trekadvisor.core.projection.Projection)

Aggregations

Projection (com.peterlaurence.trekadvisor.core.projection.Projection)1 ProjectionTask (com.peterlaurence.trekadvisor.core.projection.ProjectionTask)1