Skip to content

Instantly share code, notes, and snippets.

View imminent's full-sized avatar

imminent imminent

  • Life360
  • San Francisco
View GitHub Profile
@imminent
imminent / OnDestroy.kt
Last active March 29, 2018 23:21
OnDestroy Property Delegate
/**
* MIT License
*
* Copyright (c) 2018 Dandré Allison
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@imminent
imminent / ClickActors.kt
Created November 25, 2017 18:36
Kotlin actor extensions for Android listeners
/**
* MIT License
*
* Copyright (c) 2017 Dandré Allison
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@imminent
imminent / OnCreate.kt
Last active November 23, 2017 08:37
OnCreate Property Delegate
/**
* MIT License
*
* Copyright (c) 2017 Dandré Allison
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@imminent
imminent / OverscrollingAppBarBehavior.java
Created April 28, 2017 00:55
Overscrolling with Collapsing Toolbar
import android.content.Context;
import android.support.design.widget.AppBarLayout;
import android.support.design.widget.CoordinatorLayout;
import android.util.AttributeSet;
import android.view.View;
@SuppressWarnings("unused")
public class OverscrollingAppBarBehavior extends AppBarLayout.Behavior {
@SuppressWarnings("unused")
@imminent
imminent / HorizontalFavoringNestedScrollView.java
Created June 3, 2016 19:09
A custom NestedScrollView that delays vertical scrolling, providing more leniency to horizontal scrolling
import android.content.Context;
import android.support.v4.view.MotionEventCompat;
import android.support.v4.widget.NestedScrollView;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.MotionEvent;
import android.view.View;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
@imminent
imminent / Api.java
Last active June 13, 2023 02:50
Call retrying with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
@imminent
imminent / Api.java
Created October 15, 2015 16:16
Handling multiple API subdomains with Retrofit 2.0
package com.example.api;
import java.util.Map;
import retrofit.Call;
import retrofit.http.Body;
import retrofit.http.GET;
import retrofit.http.POST;
public interface Api {
@imminent
imminent / MapMarkerBounce.java
Created June 16, 2015 23:44
Makes a Android Google Maps marker animate a bounce
import android.os.Handler;
import android.os.SystemClock;
import android.view.animation.BounceInterpolator;
import android.view.animation.Interpolator;
import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.model.Marker;
/**
* Performs a bounce animation on a {@link Marker} when it is clicked.
@imminent
imminent / activity_example.xml
Last active August 29, 2015 14:12
Workaround to https://code.google.com/p/android/issues/detail?id=60055 caused by paddingStart and paddingEnd on some Samsung devices
<?xml version="1.0" encoding="utf-8"?>
<!-- This goes in layout/ and is an example layout using the workaround. -->
<EditView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/fieldPaddingLeft"
android:paddingRight="@dimen/fieldPaddingRight" />
@imminent
imminent / InvertAndGrayscaleTransformation.java
Last active August 29, 2015 14:11
Invert and Grayscale Transformation using RenderScript
package your.package;
import android.content.Context;
import android.graphics.Bitmap;
import android.support.v8.renderscript.Allocation;
import android.support.v8.renderscript.Element;
import android.support.v8.renderscript.Matrix4f;
import android.support.v8.renderscript.RenderScript;
import android.support.v8.renderscript.ScriptIntrinsicColorMatrix;