at y) { ? ? ? ? createAnimation(x, y); ? ? } ? ? ? /** ? ? * Create Ripple animation centered at x, y ? ? * ? ? * @param x Horizontal position of the ripple center ? ? * @param y Vertical position of the ripple center ? ? */ ? ? private void createAnimation(final float x, final float y) { ? ? ? ? if (this.isEnabled() && !animationRunning) { ? ? ? ? ? ? if (hasToZoom) ? ? ? ? ? ? ? ? this.startAnimation(scaleAnimation); ? ? ? ? ? ? ? radiusMax = Math.max(WIDTH, HEIGHT); ? ? ? ? ? ? ? if (rippleType != 2) ? ? ? ? ? ? ? ? radiusMax /= 2; ? ? ? ? ? ? ? radiusMax -= ripplePadding; ? ? ? ? ? ? ? if (isCentered || rippleType == 1) { ? ? ? ? ? ? ? ? this.x = getMeasuredWidth() / 2; ? ? ? ? ? ? ? ? this.y = getMeasuredHeight() / 2; ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? this.x = x; ? ? ? ? ? ? ? ? this.y = y; ? ? ? ? ? ? } ? ? ? ? ? ? ? animationRunning = true; ? ? ? ? ? ? ? if (rippleType == 1 && originBitmap == null) ? ? ? ? ? ? ? ? originBitmap = getDrawingCache(true); ? ? ? ? ? ? ? invalidate(); ? ? ? ? } ? ? } ? ? ? @Override ? ? public boolean onTouchEvent(MotionEvent event) { ? ? ? ? if (gestureDetector.onTouchEvent(event)) { ? ? ? ? ? ? animateRipple(event); ? ? ? ? ? ? sendClickEvent(false); ? ? ? ? } ? ? ? ? return super.onTouchEvent(event); ? ? } ? ? ? @Override ? ? public boolean onInterceptTouchEvent(MotionEvent event) { ? ? ? ? this.onTouchEvent(event); ? ? ? ? return super.onInterceptTouchEvent(event); ? ? } ? ? ? /** ? ? * Send a click event if parent view is a Listview instance ? ? * ? ? * @param isLongClick Is the event a long click ? ? ? */ ? ? private void sendClickEvent(final Boolean isLongClick) { ? ? ? ? if (getParent() instanceof AdapterView) { ? ? ? ? ? ? final AdapterView adapterView = (AdapterView) getParent(); ? ? ? ? ? ? final int position = adapterView.getPositionForView(this); ? ? ? ? ? ? final long id = adapterView.getItemIdAtPosition(position); ? ? ? ? ? ? if (isLongClick) { ? ? ? ? ? ? ? ? if (adapterView.getOnItemLongClickListener() != null) ? ? ? ? ? ? ? ? ? ? adapterView.getOnItemLongClickListener().onItemLongClick(adapterView, this, position, id); ? ? ? ? ? ? } else { ? ? ? ? ? ? ? ? if (adapterView.getOnItemClickListener() != null) ? ? ? ? ? ? ? ? ? ? adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id); ? ? ? ? ? ? } ? ? ? ? } ? ? } ? ? ? private Bitmap getCircleBitmap(final int radius) { ? ? ? ? final Bitmap output = Bitmap.createBitmap(originBitmap.getWidth(), originBitmap.getHeight(), Bitmap.Config.ARGB_8888); ? ? ? ? final Canvas canvas = new Canvas(output); ? ? ? ? final Paint paint = new Paint(); ? ? ? ? final Rect rect = new Rect((int)(x - radius), (int)(y - radius), (int)(x + radius), (int)(y + radius)); ? ? ? ? ? paint.setAntiAlias(true); ? ? ? ? canvas.drawARGB(0, 0, 0, 0); ? ? ? ? canvas.drawCircle(x, y, radius, paint); ? ? ? ? ? paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN)); ? ? ? ? canvas.drawBitmap(originBitmap, rect, rect, paint); ? ? ? ? ? return output; ? ? } ? ? ? /** ? ? * Set Ripple color, default is #FFFFFF ? ? * ? ? * @param rippleColor New color resource ? ? */ ? ? @ColorRes ? ? public void setRippleColor(int rippleColor) { ? ? ? ? this.rippleColor = getResources().getColor(rippleColor); ? ? } ? ? ? public int getRippleColor() { ? ? ? ? return rippleColor; ? ? } ? ? ? public RippleType getRippleType() ? ? { ? ? ? ? return RippleType.values()[rippleType]; ? ? } ? ? ? /** ? ? * Set Ripple type, default is RippleType.SIMPLE ? ? * ? ? * @param rippleType New Ripple type for next animation ? ? */ ? ? public void setRippleType(final RippleType rippleType) ? ? { ? ? ? ? this.rippleType = rippleType.ordinal(); ? ? } ? ? ? public Boolean isCentered() ? ? { ? ? ? ? return isCentered; ? ? } ? ? ? /** ? ? * Set if ri |