Skip to content

Instantly share code, notes, and snippets.

public class ScratchView extends View {
private static final float DRAWING_PAINT_STROKE_WIDTH = 75f;
private static final int DRAWING_MOVE_TOLERANCE = 10;
private static final double SCRATCHED_RATIO = 90.0;
private static final float DEFAULT_SCALE = 1f;
private Path mDrawingPath;
private Paint mDrawingPaint;
private Paint mBitmapPaint;
private Canvas mDrawingCanvas;
public class ViewAnimationUtils {
public static AnimatorSet createLinearReveal(final View viewToReveal, final int offsetWidth, final int offsetHeight, final int duration) {
viewToReveal.clearAnimation();
final int targetWidth = viewToReveal.getMeasuredWidth();
final int targetHeight = viewToReveal.getMeasuredHeight();
viewToReveal.getLayoutParams().height = offsetHeight;
viewToReveal.requestLayout();
@murdly
murdly / Shimmer.java
Created March 24, 2018 18:04
Shine effect
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.GradientDrawable;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewPropertyAnimator;
import static android.graphics.drawable.GradientDrawable.LINEAR_GRADIENT;
@murdly
murdly / Crossfader.kt
Last active January 19, 2021 08:19
Cross fading images across requests with Glide library.
import android.content.Context
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
import android.view.ViewGroup
import android.view.animation.AnimationUtils
import android.widget.ImageView
import android.widget.ViewSwitcher
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.GlideException