Java Question Android ValueAnimator

Discussion in 'Libraries developers questions' started by Johan Schoeman, Jul 12, 2015.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed 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: Jul 12, 2015
  2. Roycefer

    Roycefer Well-Known Member Licensed 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.
    Johan Schoeman likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice