mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Update comment like buttons style.
This commit is contained in:
parent
639c5bbc08
commit
1096b98bd6
@ -96,6 +96,7 @@ class CommentsAdapter extends ArrayAdapter<Comment> {
|
|||||||
|
|
||||||
//Update comment likes
|
//Update comment likes
|
||||||
LikeButtonView like = view.findViewById(R.id.like_button);
|
LikeButtonView like = view.findViewById(R.id.like_button);
|
||||||
|
like.setSmallButton(true);
|
||||||
like.setNumberLikes(comment.getLikes());
|
like.setNumberLikes(comment.getLikes());
|
||||||
like.setIsLiking(comment.isLiking());
|
like.setIsLiking(comment.isLiking());
|
||||||
like.setUpdateListener(new LikeButtonView.OnLikeUpdateListener() {
|
like.setUpdateListener(new LikeButtonView.OnLikeUpdateListener() {
|
||||||
|
@ -48,6 +48,11 @@ public class LikeButtonView extends FrameLayout implements View.OnClickListener
|
|||||||
*/
|
*/
|
||||||
private int numberLikes = 0;
|
private int numberLikes = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display mode : small
|
||||||
|
*/
|
||||||
|
private boolean mSmallButton = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Like Update listener
|
* Like Update listener
|
||||||
*/
|
*/
|
||||||
@ -139,14 +144,25 @@ public class LikeButtonView extends FrameLayout implements View.OnClickListener
|
|||||||
this.mUpdateListener = updateListener;
|
this.mUpdateListener = updateListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set whether the like button should appear as a small button or not
|
||||||
|
*
|
||||||
|
* @param smallButton TRUE if the button is a small button / FALSE else
|
||||||
|
*/
|
||||||
|
public void setSmallButton(boolean smallButton) {
|
||||||
|
this.mSmallButton = smallButton;
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Refresh the like view
|
* Refresh the like view
|
||||||
*/
|
*/
|
||||||
private void refresh(){
|
private void refresh(){
|
||||||
|
|
||||||
|
if(!mSmallButton) {
|
||||||
|
|
||||||
//Update the image
|
//Update the image
|
||||||
mLikeImage.setImageDrawable(UiUtils.getDrawable(getContext(),
|
mLikeImage.setImageDrawable(UiUtils.getDrawable(getContext(), R.drawable.like_up));
|
||||||
mIsLiking ? R.drawable.like_down : R.drawable.like_up));
|
|
||||||
|
|
||||||
//Update the text
|
//Update the text
|
||||||
String text = UiUtils.getString(getContext(), mIsLiking ? R.string.like_view_liking :
|
String text = UiUtils.getString(getContext(), mIsLiking ? R.string.like_view_liking :
|
||||||
@ -158,6 +174,18 @@ public class LikeButtonView extends FrameLayout implements View.OnClickListener
|
|||||||
mLikeText.setText(text);
|
mLikeText.setText(text);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
|
||||||
|
//Update the text
|
||||||
|
mLikeText.setText(numberLikes > 0 ? ""+numberLikes : "");
|
||||||
|
|
||||||
|
//Update the image
|
||||||
|
mLikeImage.setImageDrawable(UiUtils.getDrawable(getContext(),
|
||||||
|
mIsLiking ? R.drawable.like_down : R.drawable.like_up));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
|
Loading…
Reference in New Issue
Block a user