|
|
@@ -8,6 +8,7 @@ import android.support.constraint.ConstraintLayout;
|
|
|
import android.util.AttributeSet;
|
|
|
import android.util.Log;
|
|
|
import android.view.LayoutInflater;
|
|
|
+import android.view.MotionEvent;
|
|
|
import android.view.View;
|
|
|
import android.widget.Checkable;
|
|
|
import android.widget.ImageView;
|
|
|
@@ -45,27 +46,30 @@ public class LikeCheckbox extends ConstraintLayout implements Checkable {
|
|
|
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
|
|
View view = inflater.inflate(R.layout.checkbox_like, this);
|
|
|
checkImage = view.findViewById(R.id.icon_like);
|
|
|
- checkImage.setOnClickListener(view1 -> {setChecked(!isChecked);});
|
|
|
+ checkImage.setOnTouchListener(new View.OnTouchListener() {
|
|
|
+ @Override
|
|
|
+ public boolean onTouch(View v, MotionEvent event) {
|
|
|
+ if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
|
|
+ setChecked(!isChecked, true);
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void setChecked(boolean isChecked) {
|
|
|
- this.isChecked = isChecked;
|
|
|
- if (isChecked) {
|
|
|
- Log.e("APP# LikeCheckbox | setChecked", "|" + "들어옴" + isChecked);
|
|
|
- checkImage.setImageResource(R.drawable.icon_like_on);
|
|
|
- }
|
|
|
- else {
|
|
|
- checkImage.setImageResource(R.drawable.icon_like_off);
|
|
|
- }
|
|
|
+ setChecked(isChecked, false);
|
|
|
}
|
|
|
|
|
|
- public void setChecked(boolean isChecked, boolean isAnim) {
|
|
|
+ private void setChecked(boolean isChecked, boolean isAnim) {
|
|
|
+ Log.e("APP# LikeCheckbox | setChecked", "|" + "들어옴 " + isChecked + "," + isAnim);
|
|
|
+
|
|
|
this.isChecked = isChecked;
|
|
|
+
|
|
|
if (isChecked) {
|
|
|
if (isAnim) {
|
|
|
- Log.e("APP# LikeCheckbox | setChecked", "|" + "들어옴" + isChecked + "," + isAnim);
|
|
|
LikeAnimation likeAnimation = new LikeAnimation();
|
|
|
likeAnimation.show(checkImage);
|
|
|
}
|