Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set custom Interpolate for mapController #1834

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -2,14 +2,18 @@
package org.osmdroid.views;

import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.graphics.Point;
import android.os.Build;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.Interpolator;
import android.view.animation.ScaleAnimation;

import org.osmdroid.api.IGeoPoint;
Expand Down Expand Up @@ -48,6 +52,7 @@ public class MapController implements IMapController, OnFirstLayoutListener {
private double mTargetZoomLevel = 0;

private Animator mCurrentAnimator;
public TimeInterpolator interpolator = new AccelerateDecelerateInterpolator();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public TimeInterpolator interpolator = new AccelerateDecelerateInterpolator();
private TimeInterpolator mInterpolator;


// Keep track of calls before initial layout
private ReplayController mReplayController;
Expand Down Expand Up @@ -166,6 +171,7 @@ public void animateTo(final IGeoPoint point, final Double pZoom, final Long pSpe
if (mCurrentAnimator != null) {
mapAnimatorListener.onAnimationCancel(mCurrentAnimator);
}
mapAnimator.setInterpolator(interpolator);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
mapAnimator.setInterpolator(interpolator);
mapAnimator.setInterpolator(mInterpolator);

mCurrentAnimator = mapAnimator;
mapAnimator.start();
return;
Expand Down Expand Up @@ -400,8 +406,9 @@ public boolean zoomToFixing(double zoomLevel, int xPixel, int yPixel, Long zoomA
} else {
zoomToAnimator.setDuration(zoomAnimationSpeed);
}

zoomToAnimator.setInterpolator(interpolator);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
zoomToAnimator.setInterpolator(interpolator);
zoomToAnimator.setInterpolator(mInterpolator);

mCurrentAnimator = zoomToAnimator;

zoomToAnimator.start();
return true;
}
Expand Down
Expand Up @@ -480,7 +480,7 @@ public void setTileSource(final ITileSource aTileSource) {
* @param aZoomLevel the zoom level bound by the tile source
* Used to be an int - is a double since 6.0
*/
double setZoomLevel(final double aZoomLevel) {
public double setZoomLevel(final double aZoomLevel) {
final double newZoomLevel = Math.max(getMinZoomLevel(), Math.min(getMaxZoomLevel(), aZoomLevel));
final double curZoomLevel = this.mZoomLevel;

Expand Down