sujithkanna / SmileyRating

SmileyRating is a simple rating bar for android. It displays animated smileys as rating icon.
Apache License 2.0
1.07k stars 183 forks source link

setNameForSmile returns null object Reference #47

Closed kev7037 closed 4 years ago

kev7037 commented 5 years ago

Hi. I'm trying to change name of Smiles and it throws null object reference; here is my code in a fragment.

final RatingDiaglogClass ratingDiaglogClass = new RatingDiaglogClass(contextHolder, R.style.RatingDialogTheme);
LayoutInflater inflater = (LayoutInflater) contextHolder.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dv = inflater.inflate(R.layout.layout_rating_dialog, null);

ratingDiaglogClass.setContentView(dv);

final SmileRating smileRating = view.findViewById(R.id.smile_rating);
smileRating.setNameForSmile(BaseRating.BAD, "sthElse");

ratingDiaglogClass.show();

This is the error:

Attempt to invoke virtual method 'void com.hsalf.smilerating.SmileRating.setNameForSmile(int, java.lang.String)' on a null object reference

addisonElliott commented 5 years ago

It's been awhile since I've used this library, but as a sanity check, make sure that smileRating is not null first. If it is null, then you're not getting the right view.

addisonElliott commented 5 years ago

@kev7037 What's the status on this issue? Did you resolve it?

kev7037 commented 5 years ago

Yes, I was using it inside a fragment and there was a problem about using views and not about the library. thanks for your useful reply.

One more thing. While I was testing the app on 4K screen device Sony Xperia XZ Premium, while inflating on a fragment, part of the layout wont show up.

photo_2018-12-21_22-13-32

sujithkanna commented 4 years ago

It should not be a problem now. We have released a new version of the library with all the fixes. So it is advised to use the latest classes and apis