Skip to content

Instantly share code, notes, and snippets.

@ahmedre
Created October 14, 2014 07:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ahmedre/3a0a8accc7fec2bf1f2e to your computer and use it in GitHub Desktop.
Save ahmedre/3a0a8accc7fec2bf1f2e to your computer and use it in GitHub Desktop.
Ripples using Probe and MostafaGazar's Widgets
package com.cafesalam.experiments.app.ui;
import org.lucasr.probe.Interceptor;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import java.util.WeakHashMap;
/* this class is a Probe Interceptor that gives views a ripple effect
* using https://github.com/MostafaGazar/Widgets.
*/
public class RippleInterceptor extends Interceptor {
private Context mContext;
private WeakHashMap<View, RippleView> mMapping;
public RippleInterceptor(Context context) {
mContext = context;
mMapping = new WeakHashMap<>();
}
@Override
public void onLayout(View view, boolean changed,
int left, int top, int right, int bottom) {
if (!(view instanceof ViewGroup)) {
RippleView rippleView = mMapping.get(view);
if (rippleView == null) {
rippleView = new RippleView(mContext, view);
mMapping.put(view, rippleView);
}
}
super.onLayout(view, changed, left, top, right, bottom);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment