package cgeo.geocaching.sensors; import cgeo.geocaching.CgeoApplication; import cgeo.geocaching.settings.Settings; import org.apache.commons.lang3.tuple.ImmutablePair; import rx.Observable; import rx.Subscription; import rx.android.schedulers.AndroidSchedulers; import rx.functions.Action1; import rx.functions.Func1; import rx.functions.Func2; import rx.subscriptions.CompositeSubscription; /** * GeoData and Direction handler. *
* To use this class, override {@link #updateGeoDir(IGeoData, float)}. You need to start the handler using
* {@link #start(int)}. A good place to do so might be the {@code onResume} method of the Activity. Stop the Handler
* accordingly in {@code onPause}.
*
* The direction is always relative to the top of the device (natural direction), and that it must
* be fixed using {@link DirectionProvider#getDirectionNow(float)}. When the direction is derived from the GPS,
* it is altered so that the fix can still be applied as if the information came from the compass.
*/
public abstract class GeoDirHandler {
public static final int UPDATE_GEODATA = 1 << 1;
public static final int UPDATE_DIRECTION = 1 << 2;
public static final int UPDATE_GEODIR = 1 << 3;
private static final CgeoApplication app = CgeoApplication.getInstance();
/**
* Update method called when new geodata is available. This method is called on the UI thread.
* {@link #start(int)} must be called with the {@link #UPDATE_GEODATA} flag set.
*
* @param geoData the new geographical data
*/
public void updateGeoData(final IGeoData geoData) {
}
/**
* Update method called when new direction is available. This method is called on the UI thread.
* {@link #start(int)} must be called with the {@link #UPDATE_DIRECTION} flag set.
*
* @param direction the new direction
*/
public void updateDirection(final float direction) {
}
/**
* Update method called when new data is available. This method is called on the UI thread.
* {@link #start(int)} must be called with the {@link #UPDATE_GEODIR} flag set.
*
* @param geoData the new geographical data
* @param direction the new direction
*
* If the device goes fast enough, or if the compass use is not enabled in the settings,
* the GPS direction information will be used instead of the compass one.
*/
public void updateGeoDir(final IGeoData geoData, final float direction) {
}
private static Observable