Add generateRippleDrawable for RippleSalon

This commit is contained in:
seven332 committed 2015-05-19 23:35:15 +08:00
1 parent 96f37016f4
commit 368f13190c
1 file changed
+19
@@ -15,6 +15,7 @@
package com.hippo.effect.ripple;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.graphics.Color;
@@ -51,4 +52,22 @@ public final class RippleSalon {
v.setBackground(rippleDrawable);
}
}
public static Drawable generateRippleDrawable(Context context, boolean dark) {
ColorStateList color = ColorStateList.valueOf(
context.getResources().getColor(dark ? R.color.ripple_material_dark : R.color.ripple_material_light));
return generateRippleDrawable(color);
}
public static Drawable generateRippleDrawable(ColorStateList color) {
return generateRippleDrawable(color, null);
}
public static Drawable generateRippleDrawable(ColorStateList color, Drawable content) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
return new RippleDrawable(color, content);
} else {
return new android.graphics.drawable.RippleDrawable(color, content, new ColorDrawable(Color.BLACK));
}
}
}