# Discrete slide mechanism (with average rating display) for liking posts on a social network app

I'm thinking about implementing a "liking" mechanism for a social network app (using Parse) whereby users select a value from a discrete slider beneath each post. The slide would range from 0-5 and reflect the post's value to users. An example of the slider is below:

https://material.io/guidelines/components/sliders.html#sliders-discrete-slider

Each "Post" ParseObject would have a column (Number) called "likeCount". This column should be updated for each "like". A change listener would wait for a user to release their finger from the slider and then store that value in the Post ParseObject, i.e. first by storing the user's objectId in a column (Array) that stores unique objectIds:

Sting currentUserObjectId = ParseUser.getCurrentUser().getObjectId();


Updating the likeCount on the postObject would work as follows (using something like https://github.com/sonyckovoor/Discrete-Slider/blob/master/sample/src/main/java/in/sc9/samples/discreteslider/MainActivity.java):

@Override
public void onProgressChanged(DiscreteSlider seekBar, int value, boolean fromUser) {

int likeCountInc = value;
postObject.increment("likeCount", likeCountInc)

}


Lastly, I'd set the likeCount TextView in the post itself:

int likeCount_int = yeet.getInt("likeCount").size();
int likedByList_int = yeet.getList("likedBy").size();
int averageLikeValue_int = likeCount_int / likedByList_int;
String averageLikeValue_string = Integer.toString(averageLikeValue_int);
holder.averageLikeValue.setText(averageLikeValue_string);


Would Integer division be a problem here? Is there a more effective implementation for this design?

• I'm torn on this one, this really is more of an architecture question than a code review, isn't it? – Bobby Oct 29 '20 at 12:18
• "Would Integer division be a problem here?" Integer division is always a problem unless explicitly wanted, because "99 / 100" will yield "0", which is most of the time not something one wants. – Bobby Oct 29 '20 at 12:19