This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################ | |
| # Default Aliases | |
| ################################################################################ | |
| # Easier navigation: .., ..., ...., ....., ~ and - | |
| alias ..="cd .." | |
| alias ...="cd ../.." | |
| alias ....="cd ../../.." | |
| alias .....="cd ../../../.." |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /******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"/> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import rx.Observable; | |
| import rx.subjects.PublishSubject; | |
| import rx.subjects.SerializedSubject; | |
| import rx.subjects.Subject; | |
| /** | |
| * @author <a href="mailto:[email protected]">Jared Burrows</a> | |
| */ | |
| public final class RxBus { | |
| private final Subject<Object, Object> bus = new SerializedSubject<>(PublishSubject.create()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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> { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) { |