Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ You can change several attributes in the XML file, you have to remove "rv_" if y
* app:rv_framerate [integer def:10] --> Frame rate of the ripple animation
* app:rv_rippleDuration [integer def:400] --> Duration of the ripple animation
* app:rv_ripplePadding [dimension def:0] --> Add a padding to the ripple
* app:rv_rippleDelayClick [boolean def:false] --> "true" means onLick event will be invoked after animation.
* app:rv_color [color def:@android:color/white] --> Color of the ripple
* app:rv_centered [boolean def:false] --> Center ripple in the child view
* app:rv_type [enum (simpleRipple, doubleRipple) def:simpleRipple] --> Simple or double ripple
Expand Down
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'com.android.tools.build:gradle:2.0.+'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -22,3 +22,8 @@ allprojects {
jcenter()
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
Empty file modified gradlew
100644 → 100755
Empty file.
8 changes: 4 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
minSdkVersion 9
targetSdkVersion 22
targetSdkVersion 23
versionCode 9
versionName "1.3"
}
Expand All @@ -23,7 +23,7 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-annotations:22.0.0'
compile 'com.android.support:support-annotations:23.1.1'
}

if (hasProperty("VERSION_NAME"))
Expand Down
111 changes: 58 additions & 53 deletions library/src/main/java/com/andexert/library/RippleView.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public class RippleView extends RelativeLayout {
private Bitmap originBitmap;
private int rippleColor;
private int ripplePadding;
private boolean rippleDelayClick;
private GestureDetector gestureDetector;
private final Runnable runnable = new Runnable() {
@Override
Expand Down Expand Up @@ -105,7 +106,7 @@ public RippleView(Context context, AttributeSet attrs, int defStyle) {
* Method that initializes all fields and sets listeners
*
* @param context Context used to create this view
* @param attrs Attribute used to initialize fields
* @param attrs Attribute used to initialize fields
*/
private void init(final Context context, final AttributeSet attrs) {
if (isInEditMode())
Expand All @@ -123,6 +124,7 @@ private void init(final Context context, final AttributeSet attrs) {
canvasHandler = new Handler();
zoomScale = typedArray.getFloat(R.styleable.RippleView_rv_zoomScale, 1.03f);
zoomDuration = typedArray.getInt(R.styleable.RippleView_rv_zoomDuration, 200);
rippleDelayClick = typedArray.getBoolean(R.styleable.RippleView_rv_rippleDelayClick, true);
typedArray.recycle();
paint = new Paint();
paint.setAntiAlias(true);
Expand All @@ -136,7 +138,9 @@ private void init(final Context context, final AttributeSet attrs) {
public void onLongPress(MotionEvent event) {
super.onLongPress(event);
animateRipple(event);
sendClickEvent(true);
if (!rippleDelayClick) {
sendClickEvent(true);
}
}

@Override
Expand All @@ -163,9 +167,18 @@ public void draw(Canvas canvas) {
timer = 0;
durationEmpty = -1;
timerEmpty = 0;
canvas.restore();
try {
canvas.restore();
}catch(Exception e){
e.printStackTrace();
}
invalidate();
if (onCompletionListener != null) onCompletionListener.onComplete(this);
if (rippleDelayClick) {
sendClickEvent(false);
}
if (onCompletionListener != null) {
onCompletionListener.onComplete(this);
}
return;
} else
canvasHandler.postDelayed(runnable, frameRate);
Expand Down Expand Up @@ -195,8 +208,7 @@ public void draw(Canvas canvas) {
paint.setAlpha((int) (rippleAlpha - ((rippleAlpha) * (((float) timerEmpty * frameRate) / (durationEmpty)))));
else
paint.setAlpha(rippleAlpha);
}
else
} else
paint.setAlpha((int) (rippleAlpha - ((rippleAlpha) * (((float) timer * frameRate) / rippleDuration))));

timer++;
Expand Down Expand Up @@ -273,9 +285,11 @@ private void createAnimation(final float x, final float y) {
public boolean onTouchEvent(MotionEvent event) {
if (gestureDetector.onTouchEvent(event)) {
animateRipple(event);
sendClickEvent(false);
if (!rippleDelayClick) {
sendClickEvent(false);
}
}
return super.onTouchEvent(event);
return rippleDelayClick ? true : super.onTouchEvent(event);
}

@Override
Expand All @@ -301,14 +315,16 @@ private void sendClickEvent(final Boolean isLongClick) {
if (adapterView.getOnItemClickListener() != null)
adapterView.getOnItemClickListener().onItemClick(adapterView, this, position, id);
}
} else {
performClick();
}
}

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));
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);
Expand All @@ -326,16 +342,23 @@ private Bitmap getCircleBitmap(final int radius) {
* @param rippleColor New color resource
*/
@ColorRes
public void setRippleColor(int rippleColor) {
this.rippleColor = getResources().getColor(rippleColor);
}
public void setRippleColor(int rippleColor) {
this.rippleColor = getResources().getColor(rippleColor);
}

public int getRippleColor() {
return rippleColor;
}
public int getRippleColor() {
return rippleColor;
}

public boolean isRippleDelayClick() {
return rippleDelayClick;
}

public void setRippleDelayClick(boolean rippleDelayClick) {
this.rippleDelayClick = rippleDelayClick;
}

public RippleType getRippleType()
{
public RippleType getRippleType() {
return RippleType.values()[rippleType];
}

Expand All @@ -344,13 +367,11 @@ public RippleType getRippleType()
*
* @param rippleType New Ripple type for next animation
*/
public void setRippleType(final RippleType rippleType)
{
public void setRippleType(final RippleType rippleType) {
this.rippleType = rippleType.ordinal();
}

public Boolean isCentered()
{
public Boolean isCentered() {
return isCentered;
}

Expand All @@ -359,13 +380,11 @@ public Boolean isCentered()
*
* @param isCentered
*/
public void setCentered(final Boolean isCentered)
{
public void setCentered(final Boolean isCentered) {
this.isCentered = isCentered;
}

public int getRipplePadding()
{
public int getRipplePadding() {
return ripplePadding;
}

Expand All @@ -374,13 +393,11 @@ public int getRipplePadding()
*
* @param ripplePadding New Ripple padding in pixel, default is 0px
*/
public void setRipplePadding(int ripplePadding)
{
public void setRipplePadding(int ripplePadding) {
this.ripplePadding = ripplePadding;
}

public Boolean isZooming()
{
public Boolean isZooming() {
return hasToZoom;
}

Expand All @@ -389,13 +406,11 @@ public Boolean isZooming()
*
* @param hasToZoom Do the child views have to zoom ? default is False
*/
public void setZooming(Boolean hasToZoom)
{
public void setZooming(Boolean hasToZoom) {
this.hasToZoom = hasToZoom;
}

public float getZoomScale()
{
public float getZoomScale() {
return zoomScale;
}

Expand All @@ -404,13 +419,11 @@ public float getZoomScale()
*
* @param zoomScale Value of scale animation, default is 1.03f
*/
public void setZoomScale(float zoomScale)
{
public void setZoomScale(float zoomScale) {
this.zoomScale = zoomScale;
}

public int getZoomDuration()
{
public int getZoomDuration() {
return zoomDuration;
}

Expand All @@ -419,13 +432,11 @@ public int getZoomDuration()
*
* @param zoomDuration Duration, default is 200ms
*/
public void setZoomDuration(int zoomDuration)
{
public void setZoomDuration(int zoomDuration) {
this.zoomDuration = zoomDuration;
}

public int getRippleDuration()
{
public int getRippleDuration() {
return rippleDuration;
}

Expand All @@ -434,13 +445,11 @@ public int getRippleDuration()
*
* @param rippleDuration Duration, default is 400ms
*/
public void setRippleDuration(int rippleDuration)
{
public void setRippleDuration(int rippleDuration) {
this.rippleDuration = rippleDuration;
}

public int getFrameRate()
{
public int getFrameRate() {
return frameRate;
}

Expand All @@ -449,13 +458,11 @@ public int getFrameRate()
*
* @param frameRate New framerate value, default is 10
*/
public void setFrameRate(int frameRate)
{
public void setFrameRate(int frameRate) {
this.frameRate = frameRate;
}

public int getRippleAlpha()
{
public int getRippleAlpha() {
return rippleAlpha;
}

Expand All @@ -464,8 +471,7 @@ public int getRippleAlpha()
*
* @param rippleAlpha Alpha value between 0 and 255, default is 90
*/
public void setRippleAlpha(int rippleAlpha)
{
public void setRippleAlpha(int rippleAlpha) {
this.rippleAlpha = rippleAlpha;
}

Expand All @@ -487,8 +493,7 @@ public enum RippleType {

int type;

RippleType(int type)
{
RippleType(int type) {
this.type = type;
}
}
Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
<attr name="rv_ripplePadding" format="dimension" />
<attr name="rv_zoom" format="boolean" />
<attr name="rv_zoomScale" format="float" />
<attr name="rv_rippleDelayClick" format="boolean" />

</declare-styleable>
</resources>
16 changes: 8 additions & 8 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
compileSdkVersion 23
buildToolsVersion '23.0.2'

defaultConfig {
minSdkVersion 14
targetSdkVersion 22
targetSdkVersion 23
versionCode 1
versionName '1.0'
}
Expand All @@ -23,10 +23,10 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.github.traex.rippleeffect:library:1.3'
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:palette-v7:22.0.0'
compile 'com.android.support:recyclerview-v7:22.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:palette-v7:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.squareup.picasso:picasso:2.5.1'
compile project (":library")
}
Loading