Skip to content

Instantly share code, notes, and snippets.

Dandre' Allison imminent

View GitHub Profile
@imminent
imminent / OnDestroy.kt
Last active Mar 29, 2018
OnDestroy Property Delegate
View OnDestroy.kt
/**
* 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 Nov 25, 2017
Kotlin actor extensions for Android listeners
View ClickActors.kt
/**
* 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 Nov 23, 2017
OnCreate Property Delegate
View OnCreate.kt
/**
* 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 Apr 28, 2017
Overscrolling with Collapsing Toolbar
View OverscrollingAppBarBehavior.java
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 Jun 3, 2016
A custom NestedScrollView that delays vertical scrolling, providing more leniency to horizontal scrolling
View HorizontalFavoringNestedScrollView.java
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 Apr 24, 2019
Call retrying with Retrofit 2.0
View Api.java
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 Oct 15, 2015
Handling multiple API subdomains with Retrofit 2.0
View Api.java
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 Jun 16, 2015
Makes a Android Google Maps marker animate a bounce
View MapMarkerBounce.java
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 Aug 29, 2015
Workaround to https://code.google.com/p/android/issues/detail?id=60055 caused by paddingStart and paddingEnd on some Samsung devices
View activity_example.xml
<?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 Aug 29, 2015
Invert and Grayscale Transformation using RenderScript
View InvertAndGrayscaleTransformation.java
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;
You can’t perform that action at this time.