Android Open Source - BusFollower Stops Map View






From Project

Back to project page BusFollower.

License

The source code is released under:

GNU General Public License

If you think the Android project BusFollower 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

/*
 * Copyright 2012 Clayton Smith/*  w  ww. j  a  va  2 s  . c o  m*/
 *
 * This file is part of Ottawa Bus Follower.
 *
 * Ottawa Bus Follower is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 3, or (at
 * your option) any later version.
 *
 * Ottawa Bus Follower is distributed in the hope that it will be
 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Ottawa Bus Follower; see the file COPYING.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

package net.argilo.busfollower;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;

import com.google.android.maps.GeoPoint;

public class StopsMapView extends DoubleTapZoomMapView {
    private static final String TAG = "StopsMapView";
    private GeoPoint oldCenterPoint = null;
    private int oldZoomLevel = -1;
    private List<MapMoveListener> mapMoveListeners = new ArrayList<MapMoveListener>();
    
    public StopsMapView(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    public StopsMapView(Context context, String apiKey) {
        super(context, apiKey);
    }

    public StopsMapView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    
    @Override
    public boolean onTouchEvent(MotionEvent ev) {
        if (ev.getAction() == MotionEvent.ACTION_UP) {
            GeoPoint newCenterPoint = this.getMapCenter();
            if (oldCenterPoint == null || oldCenterPoint.getLatitudeE6() != newCenterPoint.getLatitudeE6()
                    || oldCenterPoint.getLongitudeE6() != newCenterPoint.getLongitudeE6()) {
                Log.d(TAG, "New center point: " + newCenterPoint.getLatitudeE6() + "," + newCenterPoint.getLongitudeE6());
                fireMapMoveEvent();
                oldCenterPoint = newCenterPoint;
            }
        }
        return super.onTouchEvent(ev);
    }
    
    @Override
    public void dispatchDraw(Canvas canvas) {
        super.dispatchDraw(canvas);
        int newZoomLevel = getZoomLevel();
        if (newZoomLevel != oldZoomLevel) {
            Log.d(TAG, "New zoom level: " + newZoomLevel);
            fireMapMoveEvent();
            oldZoomLevel = newZoomLevel;
        }
    }
    
    public void addMapMoveListener(MapMoveListener listener) {
        mapMoveListeners.add(listener);
    }
    
    private void fireMapMoveEvent() {
        for (MapMoveListener listener : mapMoveListeners) {
            listener.onMapMove();
        }
    }
    
    public interface MapMoveListener {
        public void onMapMove();
    }
}




Java Source Code List

net.argilo.busfollower.BusFollowerActivity.java
net.argilo.busfollower.BusFollowerApplication.java
net.argilo.busfollower.BusFollowerItemizedOverlay.java
net.argilo.busfollower.BusOverlayItem.java
net.argilo.busfollower.DoubleTapZoomMapView.java
net.argilo.busfollower.FetchRoutesTask.java
net.argilo.busfollower.FetchTripsTask.java
net.argilo.busfollower.MapChooserActivity.java
net.argilo.busfollower.RecentQueryList.java
net.argilo.busfollower.RecentQuery.java
net.argilo.busfollower.RouteChooserActivity.java
net.argilo.busfollower.StopChooserActivity.java
net.argilo.busfollower.StopOverlayItem.java
net.argilo.busfollower.StopsMapView.java
net.argilo.busfollower.Util.java
net.argilo.busfollower.ocdata.BusType.java
net.argilo.busfollower.ocdata.DatabaseHelper.java
net.argilo.busfollower.ocdata.GetNextTripsForStopResult.java
net.argilo.busfollower.ocdata.GetRouteSummaryForStopResult.java
net.argilo.busfollower.ocdata.OCTranspoDataFetcher.java
net.argilo.busfollower.ocdata.RouteDirection.java
net.argilo.busfollower.ocdata.Route.java
net.argilo.busfollower.ocdata.Stop.java
net.argilo.busfollower.ocdata.Trip.java
net.argilo.busfollower.ocdata.Util.java