Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
213 views
in Technique[技术] by (71.8m points)

java - android.animation.ObjectAnimator cannot be cast to com.google.android.gms.maps.model.LatLng

guys, I'm, trying to store ObjectAnimator in a Hashmap Like this.

public CustomHashMap<Integer, Marker, Vehicle, ObjectAnimator> vehicles = new CustomHashMap<>();

TypeEvaluator<LatLng> typeEvaluator = (fraction, startValue, endValue) -> new LatLngInterpolator.Spherical().interpolate(fraction, startValue, endValue);
Property<Marker, LatLng> property = Property.of(Marker.class, LatLng.class, "position");
ObjectAnimator ObjectAnm =  ObjectAnimator.ofObject(marker, property, typeEvaluator, new LatLng(Example.Latitude(),Example.Longitude()));
animator.setObjectValues(ObjectAnm);

vehicles.put(JustExample.getId(),marker,JustExampleVehicle,animator);

Now here I stored the Vehicle in the custom hashmap not important I get the object and Now I want to invoke animator.start(), Or whatever. I get an error.

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.kira.client, PID: 18631
java.lang.ClassCastException: android.animation.ObjectAnimator cannot be cast to com.google.android.gms.maps.model.LatLng
    at com.kira.client.VehicleWorkers.-$$Lambda$VehicleQueue$xg6PZ1i-O9wIDm-JBpJPPT-Okio.evaluate(Unknown Source:2)
    at android.animation.KeyframeSet.getValue(KeyframeSet.java:202)
    at android.animation.PropertyValuesHolder.calculateValue(PropertyValuesHolder.java:1017)
    at android.animation.ValueAnimator.animateValue(ValueAnimator.java:1517)
    at android.animation.ObjectAnimator.animateValue(ObjectAnimator.java:987)
    at android.animation.ValueAnimator.setCurrentFraction(ValueAnimator.java:654)
    at android.animation.ValueAnimator.setCurrentPlayTime(ValueAnimator.java:617)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1046)
    at android.animation.ValueAnimator.start(ValueAnimator.java:1065)
    at android.animation.ObjectAnimator.start(ObjectAnimator.java:852)
    at com.kira.client.VehicleWorkers.VehicleQueue.lambda$MoveCar$6$VehicleQueue(VehicleQueue.java:297)
    at com.kira.client.VehicleWorkers.-$$Lambda$VehicleQueue$id1H8VSJ8LcRmeAsr8CmeOXz4oo.run(Unknown Source:8)
    at android.app.Activity.runOnUiThread(Activity.java:6152)
    at com.kira.client.VehicleWorkers.VehicleQueue.MoveCar(VehicleQueue.java:283)
    at com.kira.client.VehicleWorkers.VehicleQueue.lambda$MoveVehiclesQueue$1$VehicleQueue(VehicleQueue.java:154)
    at com.kira.client.VehicleWorkers.-$$Lambda$VehicleQueue$kGEN1oImKXyitaMBa94bxK0IgQY.run(Unknown Source:2)
    at android.os.Handler.handleCallback(Handler.java:789)
    at android.os.Handler.dispatchMessage(Handler.java:98)
    at android.os.Looper.loop(Looper.java:164)
    at android.app.ActivityThread.main(ActivityThread.java:6541)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
question from:https://stackoverflow.com/questions/65833025/android-animation-objectanimator-cannot-be-cast-to-com-google-android-gms-maps-m

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...