mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Like button reacts on click.
This commit is contained in:
parent
1f91d0b9bb
commit
98fcec6779
@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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>
|
Loading…
Reference in New Issue
Block a user