<commit_before>package ir.parsoa.rippleview ;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.Shader;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.RelativeLayout;

/**
 * Created by Parsoa on 8/31/15.
 */
public class RippleView extends View
{

    private static final String DEBUG_TAG = "RippleView" ;

    private int maxRadius = 80 ;

    private float outerAlpha = 0 ;
    private float innerAlpha = 0 ;

    private float outerRadius = 0 ;
    private float innerRadius = 0 ;

    private int width ;
    private int height ;

    private int rippleColorID ;

    private RippleViewCallback callback ;

    private static final long RIPPLE_DURATION = 300 ;

    private Path outerPath = new Path() ;
    private Paint outerPaint;

    private Path innerPath = new Path() ;
    private Paint innerPaint ;

    // ========================================================================================== \\

    public static void DrawRippleAtPosition(Activity context , int rippleCenterX , int rippleCenterY ,
                                            int rippleRadius , int colorID , ViewGroup rootLayout ,
                                            RippleViewCallback callback)
    {
        RippleView rippleView = new RippleView(context , callback);
        rippleView.setRippleRadius(rippleRadius);
        rootLayout.addView(rippleView);
        rippleView.init(rippleCenterX , rippleCenterY , colorID) ;
    }

    public static void DrawRippleAtPosition(Activity context , int rippleCenterX , int rippleCenterY ,
                                            int colorID , ViewGroup rootLayout , RippleViewCallback callback)
    {
        RippleView rippleView = new RippleView(context , callback);
        rootLayout.addView(rippleView);
        rippleView.init(rippleCenterX , rippleCenterY , colorID) ;
    }

    public static void DrawRippleAtPosition(Activity context , View targetView , int colorID ,
                                            ViewGroup rootLayout , RippleViewCallback callback)
    {
        RippleView rippleView = new RippleView(context , callback);
        rootLayout.addView(rippleView);
        int[] coordinates = new int[2] ;
        targetView.getLocationInWindow(coordinates);
        rippleView.init(coordinates[0] + targetView.getWidth() / 2,
                coordinates[1] + targetView.getHeight() / 2 - getStatusBarHeight(context) , colorID) ;
    }

    private static int getStatusBarHeight(Activity context)
    {
        Rect rectangle= new Rect();
        Window window= context.getWindow();
        window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
        return rectangle.top ;
    }

    // ========================================================================================== \\

    public RippleView(Context context , RippleViewCallback callback)
    {
        super(context);
        this.callback = callback ;
    }

    // ========================================================================================== \\

    public void init(float rippleCenterX , float rippleCenterY , int color)
    {
        rippleColorID = color ;
        init(rippleCenterX , rippleCenterY);
    }

    public void init(float rippleCenterX , float rippleCenterY)
    {
        outerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        outerPaint.setAlpha(100);

        innerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        innerPaint.setAlpha(100);

        width = maxRadius * 2 ;
        height = maxRadius * 2 ;

        setX(rippleCenterX - width / 2);
        setY(rippleCenterY - height / 2);

        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams() ;
        params.width = width ;
        params.height = height ;
        this.setLayoutParams(params);

        startAnimation();
    }

    private void startAnimation()
    {
        OuterRippleAnimator outerRippleAnimator = new OuterRippleAnimator() ;
        outerRippleAnimator.setDuration(RIPPLE_DURATION);
        startAnimation(outerRippleAnimator);

        InnerRippleAnimator innerRippleAnimator = new InnerRippleAnimator() ;
        innerRippleAnimator.setAnimationListener(new Animation.AnimationListener()
        {
            @Override
            public void onAnimationStart(Animation animation)
            {

            }

            @Override
            public void onAnimationEnd(Animation animation)
            {
                if(callback != null)
                {
                    callback.onAnimationFinished();
                }
                ((ViewGroup) getParent()).removeView(RippleView.this);
            }

            @Override
            public void onAnimationRepeat(Animation animation)
            {<commit_msg>bug fix<commit_after>package ir.parsoa.rippleview ;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Path;
import android.graphics.RadialGradient;
import android.graphics.Rect;
import android.graphics.Shader;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.animation.Animation;
import android.view.animation.Transformation;
import android.widget.RelativeLayout;

/**
 * Created by Parsoa on 8/31/15.
 */
public class RippleView extends View
{

    private static final String DEBUG_TAG = "RippleView" ;

    private int maxRadius = 80 ;

    private float outerAlpha = 0 ;
    private float innerAlpha = 0 ;

    private float outerRadius = 0 ;
    private float innerRadius = 0 ;

    private int width ;
    private int height ;

    private int rippleColorID ;

    private RippleViewCallback callback ;

    private static final long RIPPLE_DURATION = 300 ;

    private Path outerPath = new Path() ;
    private Paint outerPaint;

    private Path innerPath = new Path() ;
    private Paint innerPaint ;

    // ========================================================================================== \\

    public static void DrawRippleAtPosition(Activity context , int rippleCenterX , int rippleCenterY ,
                                            int rippleRadius , int colorID , ViewGroup rootLayout ,
                                            RippleViewCallback callback)
    {
        RippleView rippleView = new RippleView(context , callback);
        rippleView.setRippleRadius(rippleRadius);
        rootLayout.addView(rippleView);
        rippleView.init(rippleCenterX , rippleCenterY , colorID) ;
    }

    public static void DrawRippleAtPosition(Activity context , int rippleCenterX , int rippleCenterY ,
                                            int colorID , ViewGroup rootLayout , RippleViewCallback callback)
    {
        RippleView rippleView = new RippleView(context , callback);
        rootLayout.addView(rippleView);
        rippleView.init(rippleCenterX , rippleCenterY , colorID) ;
    }

    public static void DrawRippleAtPosition(Activity context , View targetView , int colorID ,
                                            ViewGroup rootLayout , RippleViewCallback callback)
    {
        RippleView rippleView = new RippleView(context , callback);
        rootLayout.addView(rippleView);
        int[] coordinates = new int[2] ;
        targetView.getLocationInWindow(coordinates);
        rippleView.init(coordinates[0] + targetView.getWidth() / 2,
                coordinates[1] + targetView.getHeight() / 2 - getStatusBarHeight(context), colorID) ;
    }

    private static int getStatusBarHeight(Activity context)
    {
        Rect rectangle= new Rect();
        Window window= context.getWindow();
        window.getDecorView().getWindowVisibleDisplayFrame(rectangle);
        return rectangle.top ;
    }

    // ========================================================================================== \\

    public RippleView(Context context , RippleViewCallback callback)
    {
        super(context);
        this.callback = callback ;
    }

    // ========================================================================================== \\

    public void init(float rippleCenterX , float rippleCenterY , int color)
    {
        rippleColorID = color ;
        init(rippleCenterX , rippleCenterY);
    }

    public void init(float rippleCenterX , float rippleCenterY)
    {
        outerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        outerPaint.setAlpha(100);

        innerPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
        innerPaint.setAlpha(100);

        width = maxRadius * 2 ;
        height = maxRadius * 2 ;

        setX(rippleCenterX - width / 2);
        setY(rippleCenterY - height / 2);

        RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) getLayoutParams() ;
        params.width = width ;
        params.height = height ;
        this.setLayoutParams(params);

        startAnimation();
    }

    private void startAnimation()
    {
        OuterRippleAnimator outerRippleAnimator = new OuterRippleAnimator() ;
        outerRippleAnimator.setDuration(RIPPLE_DURATION);
        startAnimation(outerRippleAnimator);

        InnerRippleAnimator innerRippleAnimator = new InnerRippleAnimator() ;
        innerRippleAnimator.setAnimationListener(new Animation.AnimationListener()
        {
            @Override
            public void onAnimationStart(Animation animation)
            {

            }

            @Override
            public void onAnimationEnd(Animation animation)
            {
                ((ViewGroup) getParent()).removeView(RippleView.this);
                if(callback != null)
                {
                    callback.onAnimationFinished();
                }
            }

            @Override
            public void onAnimationRepeat(Animation animation)
            {
{'fraction_non_alphanumeric': 0.12579602233761145, 'fraction_numerical': 0.005682374840795533, 'mean_word_length': 2.5804980708523324, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2976673', 'n_tokens_mistral': 2773, 'n_tokens_neox': 2482, 'n_words': 583}