Giter Site home page Giter Site logo

Comments (9)

sujithkanna avatar sujithkanna commented on May 17, 2024 1

It is because the view is not inflated yet fully, so try posting it using runnable.

smileyRating.post(new Runnable() {
            @Override
            public void run() {
                smileRating.setSelectedSmile(BaseRating.TERRIBLE,true);
            }
        });

Can you try this?

Thank you :D

from smileyrating.

sujithkanna avatar sujithkanna commented on May 17, 2024

Are you sure it is null pointer? or IndexOutOfBounds exception

from smileyrating.

sujithkanna avatar sujithkanna commented on May 17, 2024

Can you post the stackTrace of the error too?

from smileyrating.

 avatar commented on May 17, 2024

I guess mTouchPoints should be 5 (smilies) but it contains 0 because they were never created. I think.
Here is the stacktrace
--------- beginning of crash
09-16 08:35:36.497 3992-3992/com.update.update E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.update.update, PID: 3992
java.lang.NullPointerException: Attempt to read from field 'float com.hsalf.smilerating.BaseRating$Point.x' on a null object reference
at com.hsalf.smilerating.SmileRating$2.onAnimationStart(SmileRating.java:194)
at android.animation.ValueAnimator.notifyStartListeners(ValueAnimator.java:1048)
at android.animation.ValueAnimator.start(ValueAnimator.java:1110)
at android.animation.ValueAnimator.start(ValueAnimator.java:1117)
at com.hsalf.smilerating.SmileRating.setSelectedSmile(SmileRating.java:565)
at com.hsalf.smilerating.SmileRating.setSelectedSmile(SmileRating.java:545)
at com.update.update.DateRatingAdapter.onBindViewHolder(DateRatingAdapter.java:49) -> holder.srRating.setSelectedSmile(5,true);

from smileyrating.

 avatar commented on May 17, 2024

I hope the above will be enough but if you need more info from me, let me know

from smileyrating.

yinqingh avatar yinqingh commented on May 17, 2024

I got the same error

from smileyrating.

 avatar commented on May 17, 2024

@LeooonH It seems that we're the only ones to get this error... I wonder what the problem is. Waiting for @sujithkanna response.

from smileyrating.

BRKNCD avatar BRKNCD commented on May 17, 2024

Hi all,
I want to ask why when I set true for the animation it gives me java.lang.NullPointerException: Attempt to read from field 'float com.hsalf.smilerating.BaseRating$Point.x' on a null object reference

My code (simplyfied):

public class scoreActivity extends AppCompatActivity{

    SmileRating smileRating;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.score_layout);
        smileRating = (SmileRating) findViewById(R.id.smile_rating);
        smileRating.setIndicator(true);

// this works
        smileRating.setSelectedSmile(BaseRating.TERRIBLE);

// this one doesn't works
//      smileRating.setSelectedSmile(BaseRating.TERRIBLE,true);
    }

What am I doing wrong?

Thank you for your AWESOME work! :D

from smileyrating.

benoffi7 avatar benoffi7 commented on May 17, 2024

solution by @sujithkanna works! same problem with animate and the snippet works fine

from smileyrating.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.