I'm displaying a list of food orders using a RecyclerView. Each view item has a RatingBar, so client can submit rating for the order.
Problem: When client scrolls down and goes back up, the value of the RatingBar shown on an order item changes (no other data changes).
Example:
Initial State:
After I scroll all the way down, and come back up:
Value of the rating bar of the second item gets updated automatically.
No where in the code are we updating the value of RatingBar programatically. Based on our expected behaviour, it should only change when user clicks on it.
Project code:
https://github.com/uOttawaSEGA2022/project-group-4/tree/lastissue
Link to code where RecyclerView and the adapters are defined:
Activity Class | Adapter | Order Item View | Orders List Screen
Solutions tried:
Used ListView, RecyclerView, RecyclerView with ListAdapter - same issue in all
Tried setting a change listener on rating bar, and could see that it's getting changed dynamically on scroll even without any user interaction.
holder.ratingBar.setOnRatingBarChangeListener(new RatingBar.OnRatingBarChangeListener() {
@Override
public void onRatingChanged(RatingBar ratingBar, float rating, boolean fromUser) {
if (fromUser) {
Log.d("ratingBarUpdate", "User updated Rating bar: " + ratingBar.getId());
} else {
Log.e("ratingBarUpdate", "Rating bar updated programmatically: " + ratingBar.getId());
}
}
});
I'm aware, RecyclerView (and ListView etc.) dynamically update existing view items to display data on scroll. The problem is on scrolling back up, the data is incorrect (or not updated correctly).
Is there any way to fix this? Or any other way to display such information which help avoid this problem?

