Skip to content

Instantly share code, notes, and snippets.

@premacck
premacck / BaseRecyclerView.java
Last active Aug 22, 2018
A Base RecyclerView class for ease in creating Adapters with DiffUtil and dependency injection.
View BaseRecyclerView.java
// TODO: put package information here
import android.app.Activity;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.view.ViewGroup;
import java.util.List;
/**
@premacck
premacck / StatefulRecyclerView.java
Last active Aug 22, 2018
RecyclerView which saves and restores states on application lifecycle changes.
View StatefulRecyclerView.java
// TODO: put package information here
import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
/**
@premacck
premacck / FlippedProgressBar.java
Last active Aug 22, 2018
Android progressBar in reverse direction.
View FlippedProgressBar.java
// TODO: put package information here
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.widget.ProgressBar;
/**
*
* Created by Prem $ on 9/29/2017.
@premacck
premacck / EndlessRecyclerViewScrollListener.java
Last active Aug 22, 2018
Endless RecyclerView scroll listener for simple pagination in Android.
View EndlessRecyclerViewScrollListener.java
// TODO: put package information here
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import org.jetbrains.annotations.Contract;
/**
View VerticalViewPager,java
/**
* Uses a combination of a PageTransformer and swapping X & Y coordinates
* of touch events to create the illusion of a vertically scrolling ViewPager.
*
* Requires API 11+
*
*/
public class VerticalViewPager extends ViewPager {
public VerticalViewPager(Context context) {
@premacck
premacck / BlurAlertDialog.kt
Last active Mar 29, 2019
AlertDialog like DoalogFragment with blur background. Works with BlurKit (https://github.com/CameraKit/blurkit-android) and Anko (https://github.com/Kotlin/anko)
View BlurAlertDialog.kt
// TODO: add package info here
import android.annotation.SuppressLint
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.accessibility.AccessibilityNodeInfo
import androidx.annotation.StringRes
import androidx.annotation.StyleRes
@premacck
premacck / ShimmerLinearLayout.java
Last active Apr 1, 2019
Animating, customizable Shimmer layout to be used as a substitute for LinearLayout
View ShimmerLinearLayout.java
// TODO: put package information here
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@premacck
premacck / ShimmerRelativeLayout.java
Last active Apr 21, 2019
Animating, customizable Shimmer layout to be used as a substitute for RelativeLayout
View ShimmerRelativeLayout.java
// TODO: put package information here
import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
@premacck
premacck / DynamicColorProgress.java
Last active Apr 21, 2019
Android - Circular indeterminate ProgressBar smoothly fading between various material colors
View DynamicColorProgress.java
// TODO: put package information here
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.content.Context;
import android.content.res.ColorStateList;
import android.graphics.Color;
import android.util.AttributeSet;
import android.widget.ProgressBar;
View TooltipExt.kt
/**
* Function to start circular tooltip queue form a fragment
*/
fun Fragment.roundTooltipOf(tooltipItem: TooltipItem, anchor: View?) = if (anchor != null) {
activity?.let { TooltipHandler.prepare(it, tooltipItem, anchor, false) }
} else null
/**
* Function to start rounded rectangular tooltip queue form a fragment
*/