Like button reacts on click.

This commit is contained in:
Pierre 2018-04-04 18:16:33 +02:00
parent 1f91d0b9bb
commit 98fcec6779
2 changed files with 16 additions and 3 deletions

View File

@ -123,7 +123,7 @@ public class LikeButtonView extends FrameLayout implements View.OnClickListener
*
* @return TRUE if the user is liking / FALSE else
*/
public boolean ismIsLiking() {
public boolean isIsLiking() {
return mIsLiking;
}
@ -141,7 +141,7 @@ public class LikeButtonView extends FrameLayout implements View.OnClickListener
R.string.like_view_like);
if(numberLikes > 0)
text += "(" + numberLikes + ")";
text += " (" + numberLikes + ")";
mLikeText.setText(text);
@ -150,5 +150,18 @@ public class LikeButtonView extends FrameLayout implements View.OnClickListener
@Override
public void onClick(View v) {
//Check if the user want to like or dislike component
if(mIsLiking){
mIsLiking = false;
numberLikes--;
}
else {
mIsLiking = true;
numberLikes++;
}
//Refresh display
refresh();
}
}

View File

@ -21,7 +21,7 @@
android:id="@+id/like_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_gravity="center_vertical"
tools:text="Like" />
</LinearLayout>