Skip to content

Instantly share code, notes, and snippets.

@megamind-android
Created December 9, 2011 16:16
Show Gist options
  • Select an option

  • Save megamind-android/1452170 to your computer and use it in GitHub Desktop.

Select an option

Save megamind-android/1452170 to your computer and use it in GitHub Desktop.
private static void display(int total, int friends, boolean user) {
String message = "";
String text;
if(friends>1){
text = "friends";
}
else {
text="friend";
}
int remaining = total - friends - (user?1:0);
//TODO: Logic to populate messsage.
if(friends!=0 && total!=0){
if(user && total>friends){
if(remaining!=0){
message ="you,"+friends+ text+" and "+remaining+" others like this";
}
else{
message ="you and "+friends+text+" like this";
}
}
else if(!user && remaining!=0){
message =friends+ text+" and "+remaining+" others like this";
}
else if(!user && remaining==0){
message =friends+text+" like this";
}
}
else if(total!=0 && friends==0 && user){
message ="you and "+remaining+" others like this";
}
else if(total!=0 && friends==0 && !user){
message = remaining+" others like this";
}
else if(remaining==0){
message ="none like this";
}
else if(remaining==-1){
message ="you like this";
}
System.out.println("Total "+total+", friends "+friends+", user "+user+", message: "+message);
}
@rajiv-singaseni
Copy link

This gist is useful to parse the Facebook like text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment