Skip to content

Instantly share code, notes, and snippets.

/*
* Copyright 2016 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@suclike
suclike / CircularFragReveal.java
Created March 13, 2018 00:15 — forked from tinmegali/CircularFragReveal.java
Add a circular Reveal and Unreveal transition animation to a Android Fragment
import android.animation.Animator;
import android.animation.TimeInterpolator;
import android.annotation.TargetApi;
import android.graphics.Color;
import android.os.Build;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewAnimationUtils;
@suclike
suclike / .aliases
Created March 9, 2018 12:15 — forked from willmendesneto/.aliases
.aliases
################################################################################
# Default Aliases
################################################################################
# Easier navigation: .., ..., ...., ....., ~ and -
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
@suclike
suclike / InstagramLikeColorTransition.txt
Created March 9, 2018 10:07 — forked from deepak786/InstagramLikeColorTransition.txt
Instagram Like Gradient Color Transition in Android
/******This Gist explains how to create instagram like Gradient color transition in android.******/
1. Create some gradient color drawables inside drawable Folder.
a) color1.xml
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:startColor="#c44e4e"
android:endColor="#dcb9b9"
android:angle="0"/>
@suclike
suclike / RxBus1.java
Created February 11, 2018 18:16 — forked from jaredsburrows/RxBus1.java
RxBus for RxJava 1 and RxJava 2
import rx.Observable;
import rx.subjects.PublishSubject;
import rx.subjects.SerializedSubject;
import rx.subjects.Subject;
/**
* @author <a href="mailto:jaredsburrows@gmail.com">Jared Burrows</a>
*/
public final class RxBus {
private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create());
@suclike
suclike / EndlessRecyclerOnScrollListener.java
Created January 23, 2018 16:59 — forked from mustafasevgi/EndlessRecyclerOnScrollListener.java
RecyclerView position helper to get first and last visible positions
/**
* Custom Scroll listener for RecyclerView.
* Based on implementation https://gist.github.com/ssinss/e06f12ef66c51252563e
*/
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = "EndlessScrollListener";
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
@suclike
suclike / StatefulRecyclerView.java
Created January 23, 2018 15:54 — forked from FrantisekGazo/StatefulRecyclerView.java
Retain & restore recycler view scroll position
package eu.f3rog.ui.custom;
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;
/**
@suclike
suclike / PaintView.java
Created January 9, 2018 10:19 — forked from ErikHellman/PaintView.java
A very simple example of using multi-touch on Android to build a custom View for finger painting. This example uses the Path class from the android.graphics package. Feel free to use this code as you wish for your own multi-touch apps.
public class PaintView extends View {
public static final int MAX_FINGERS = 5;
private Path[] mFingerPaths = new Path[MAX_FINGERS];
private Paint mFingerPaint;
private ArrayList<Path> mCompletedPaths;
private RectF mPathBounds = new RectF();
public PaintView(Context context) {
super(context);
}
internal class CoroutineLifecycleListener(private val deferred: Deferred<*>) : LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun cancelCoroutine() {
deferred.cancel()
}
}
internal var POOL = newFixedThreadPoolContext(2, "loader")
fun <T> LifecycleOwner.load(loader: () -> T): Deferred<T> {
@suclike
suclike / DebouncingOnClickListener.java
Created January 8, 2018 15:45 — forked from blipinsk/DebouncingOnClickListener.java
[Medium] Butterknife's DebouncingOnClickListener as interface
public interface DebouncingOnClickListener extends View.OnClickListener {
Enabled enabled = new Enabled(true);
Runnable ENABLE_AGAIN = () -> enabled.set(true);
void doClick(View v);
@Override
default void onClick(View v) {