Created
October 14, 2014 07:15
-
-
Save ahmedre/3a0a8accc7fec2bf1f2e to your computer and use it in GitHub Desktop.
Ripples using Probe and MostafaGazar's Widgets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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