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