<commit_before>package com.bedrock.padder.helper;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

import java.util.HashMap;
import java.util.Map;

import static android.content.Context.POWER_SERVICE;

@TargetApi(14)
public class AnimateHelper {
    private WindowHelper window = new WindowHelper();

    // Fade animations

    public void fade(final int id, final float startAlpha, final float endAlpha, final int delay, final long duration, String handlerName, Activity activity) {
        final AlphaAnimation fade = new AlphaAnimation(startAlpha, endAlpha);
        final View view = activity.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setAlpha(endAlpha);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [GONE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setAlpha(endAlpha);
                Log.i("AnimateHelper",
                        String.valueOf(id) + " fade effect to " +
                                String.valueOf(endAlpha) + "f for 0ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fade.setDuration(duration);
                        view.startAnimation(fade);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                String.valueOf(id) + " fade effect from " +
                                        String.valueOf(startAlpha) + "f to " +
                                        String.valueOf(endAlpha) + "f for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fade.setDuration(duration);
                view.startAnimation(fade);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        String.valueOf(id) + " fade effect from " +
                                String.valueOf(startAlpha) + "f to " +
                                String.valueOf(endAlpha) + "f for " +
                                String.valueOf(duration) + "ms with no delay");
            }

            fade.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                    view.setAlpha(startAlpha);
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    view.setAlpha(endAlpha);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
        }
    }

    public void fadeIn(final int id, final int delay, final long duration, String handlerName, Activity activity) {
        final AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
        final View view = activity.findViewById(id);
        view.setVisibility(View.INVISIBLE);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade IN [VISIBLE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.VISIBLE);
                Log.i("AnimateHelper",
                        String.valueOf(id) + " fade IN effect to 1.0f for 0ms with no delay");
            }
        } else {
            // normal fadeIn IN
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeIn.setDuration(duration);
                        view.startAnimation(fadeIn);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                String.valueOf(id) + " fade IN effect for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeIn.setDuration(duration);
                view.startAnimation(fadeIn);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        String.valueOf(id) + " fade IN effect for " +
                                String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeIn(final View view, final int delay, final long duration, String handlerName, Activity activity) {
        final AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);;
        view.setVisibility(View.INVISIBLE);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper", view.toString() + " fade IN [VISIBLE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.VISIBLE);
                Log.i("AnimateHelper",
                        view.toString() + " fade IN effect to 1.0f for 0ms with no delay");
            }
        } else {
            // normal fadeIn IN
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeIn.setDuration(duration);
                        view.startAnimation(fadeIn);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                view.toString() + " fade IN effect for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeIn.setDuration(duration);
                view.startAnimation(fadeIn);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        view.toString() + " fade IN effect for " +
                                String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeIn(final int id, final int delay, final long duration, String handlerName, View parentView, Activity activity) {
        final AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
        final View view = parentView.findViewById(id);
        view.setVisibility(View.INVISIBLE);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade IN [VISIBLE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.VISIBLE);
                Log.i("AnimateHelper",
                        String.valueOf(id) + " fade IN effect to 1.0f for 0ms with no delay");
            }
        } else {
            // normal fadeIn IN
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeIn.setDuration(duration);
                        view.startAnimation(fadeIn);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                String.valueOf(id) + " fade IN effect for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeIn.setDuration(duration);
                view.startAnimation(fadeIn);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        String.valueOf(id) + " fade IN effect for " +
                                String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOut(final int id, final int delay, final long duration, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = activity.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOut(final int id, final int delay, final long duration, View parentView, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = parentView.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOutInvisible(final int id, final int delay, final long duration, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = activity.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOutInvisible(final int id, final int delay, final long duration, View parentView, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = parentView.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(id) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    // Slide Animations

    public void slideIn(final View view, final int delay, final long duration, String handlerName) {
        final TranslateAnimation slideIn = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0);
        view.setVisibility(View.INVISIBLE);

        slideIn.setInterpolator(new DecelerateInterpolator());

        Map<String, Handler> handlerCreator = new HashMap<>();
        handlerCreator.put(handlerName, new Handler());

        handlerCreator.get(handlerName).postDelayed(new Runnable() {
            @Override<commit_msg>Updated AnimateHelper Logs to view<commit_after>package com.bedrock.padder.helper;

import android.animation.Animator;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.os.Handler;
import android.os.PowerManager;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.view.animation.ScaleAnimation;
import android.view.animation.TranslateAnimation;

import java.util.HashMap;
import java.util.Map;

import static android.content.Context.POWER_SERVICE;

@TargetApi(14)
public class AnimateHelper {
    private WindowHelper window = new WindowHelper();

    // Fade animations

    public void fade(final int id, final float startAlpha, final float endAlpha, final int delay, final long duration, String handlerName, Activity activity) {
        final AlphaAnimation fade = new AlphaAnimation(startAlpha, endAlpha);
        final View view = activity.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setAlpha(endAlpha);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [GONE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setAlpha(endAlpha);
                Log.i("AnimateHelper",
                        String.valueOf(view) + " fade effect to " +
                                String.valueOf(endAlpha) + "f for 0ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fade.setDuration(duration);
                        view.startAnimation(fade);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                String.valueOf(view) + " fade effect from " +
                                        String.valueOf(startAlpha) + "f to " +
                                        String.valueOf(endAlpha) + "f for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fade.setDuration(duration);
                view.startAnimation(fade);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        String.valueOf(view) + " fade effect from " +
                                String.valueOf(startAlpha) + "f to " +
                                String.valueOf(endAlpha) + "f for " +
                                String.valueOf(duration) + "ms with no delay");
            }

            fade.setAnimationListener(new Animation.AnimationListener() {
                @Override
                public void onAnimationStart(Animation animation) {
                    view.setAlpha(startAlpha);
                }

                @Override
                public void onAnimationEnd(Animation animation) {
                    view.setAlpha(endAlpha);
                }

                @Override
                public void onAnimationRepeat(Animation animation) {

                }
            });
        }
    }

    public void fadeIn(final int id, final int delay, final long duration, String handlerName, Activity activity) {
        final AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
        final View view = activity.findViewById(id);
        view.setVisibility(View.INVISIBLE);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade IN [VISIBLE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.VISIBLE);
                Log.i("AnimateHelper",
                        String.valueOf(view) + " fade IN effect to 1.0f for 0ms with no delay");
            }
        } else {
            // normal fadeIn IN
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeIn.setDuration(duration);
                        view.startAnimation(fadeIn);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                String.valueOf(view) + " fade IN effect for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeIn.setDuration(duration);
                view.startAnimation(fadeIn);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        String.valueOf(view) + " fade IN effect for " +
                                String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeIn(final View view, final int delay, final long duration, String handlerName, Activity activity) {
        final AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);;
        view.setVisibility(View.INVISIBLE);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper", view.toString() + " fade IN [VISIBLE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.VISIBLE);
                Log.i("AnimateHelper",
                        view.toString() + " fade IN effect to 1.0f for 0ms with no delay");
            }
        } else {
            // normal fadeIn IN
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeIn.setDuration(duration);
                        view.startAnimation(fadeIn);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                view.toString() + " fade IN effect for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeIn.setDuration(duration);
                view.startAnimation(fadeIn);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        view.toString() + " fade IN effect for " +
                                String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeIn(final int id, final int delay, final long duration, String handlerName, View parentView, Activity activity) {
        final AlphaAnimation fadeIn = new AlphaAnimation(0.0f, 1.0f);
        final View view = parentView.findViewById(id);
        view.setVisibility(View.INVISIBLE);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade IN [VISIBLE] effect for 0ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.VISIBLE);
                Log.i("AnimateHelper",
                        String.valueOf(view) + " fade IN effect to 1.0f for 0ms with no delay");
            }
        } else {
            // normal fadeIn IN
            if (duration > 0) {
                // delay, needs an handler
                Map<String, Handler> handlerCreator = new HashMap<>();
                handlerCreator.put(handlerName, new Handler());

                handlerCreator.get(handlerName).postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeIn.setDuration(duration);
                        view.startAnimation(fadeIn);
                        view.setVisibility(View.VISIBLE);

                        Log.i("AnimateHelper",
                                String.valueOf(view) + " fade IN effect for " +
                                        String.valueOf(duration) + "ms with " +
                                        String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeIn.setDuration(duration);
                view.startAnimation(fadeIn);
                view.setVisibility(View.VISIBLE);

                Log.i("AnimateHelper",
                        String.valueOf(view) + " fade IN effect for " +
                                String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOut(final int id, final int delay, final long duration, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = activity.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOut(final int id, final int delay, final long duration, View parentView, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = parentView.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [GONE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.GONE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.GONE);
                    }
                }, delay + 10);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.GONE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOutInvisible(final int id, final int delay, final long duration, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = activity.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    public void fadeOutInvisible(final int id, final int delay, final long duration, View parentView, Activity activity) {
        final AlphaAnimation fadeOut = new AlphaAnimation(1.0f, 0.0f);
        final View view = parentView.findViewById(id);
        PowerManager powerManager = (PowerManager) activity.getSystemService(POWER_SERVICE);

        if (Build.VERSION.SDK_INT >= 21 && powerManager.isPowerSaveMode()) {
            // power save mode on
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT [INVISIBLE] effect for " + String.valueOf(duration) + "ms with no delay");
            }
        } else {
            // normal fade out
            if (duration > 0) {
                // delay, needs an handler
                Handler handler = new Handler();
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        fadeOut.setDuration(duration);
                        view.startAnimation(fadeOut);
                        view.setVisibility(View.INVISIBLE);

                        Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with " + String.valueOf(delay) + "ms delay");
                    }
                }, delay);
            } else {
                fadeOut.setDuration(duration);
                view.startAnimation(fadeOut);
                view.setVisibility(View.INVISIBLE);
                Log.i("AnimateHelper", String.valueOf(view) + " fade OUT effect for " + String.valueOf(duration) + "ms with no delay");
            }
        }
    }

    // Slide Animations

    public void slideIn(final View view, final int delay, final long duration, String handlerName) {
        final TranslateAnimation slideIn = new TranslateAnimation(Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, 0, Animation.RELATIVE_TO_SELF, -1, Animation.RELATIVE_TO_SELF, 0);
        view.setVisibility(View.INVISIBLE);

        slideIn.setInterpolator(new DecelerateInterpolator());

        Map<String, Handler> handlerCreator = new HashMap<>();
        handlerCreator.put(handlerName, new Handler());

        handlerCreator.get(handlerName).postDelayed(new Runnable() {
            @Override
{'fraction_non_alphanumeric': 0.09903206689932179, 'fraction_numerical': 0.003862952964157942, 'mean_word_length': 1.4613473070066447, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 87, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5216079', 'n_tokens_mistral': 11520, 'n_tokens_neox': 10537, 'n_words': 2557}