Java Question Android ValueAnimator

Johan Schoeman

Expert
Licensed User
Longtime User
One of the Github projects that I have wrapped recently uses the Android ValueAnimator class (import android.animation.ValueAnimator). On line 168 of the Github project the following line of code appears:

mArrowLineToHorizontalLineAnimatedValue = (float) valueAnimator.getAnimatedValue();

The above line of code does however NOT compile with SLC.

I found a solution on Stackoverflow and changed the line of code to:

mArrowLineToDotAnimatedValue = ((Float) (valueAnimator.getAnimatedValue())).floatValue();

This line of code WORKED. Surely the author of this Github project was somehow able to compile the project into an app. Why did it "possibly" work for him but SLC generates an error with the same line of code?
 
Last edited:

Roycefer

Well-Known Member
Licensed User
Longtime User
What Java version are you using? I think Java 6 doesn't permit casting Objects to primitives whereas Javas 7 and 8 allow that through implicit auto-unboxing.
 
Top