Skip to content

Instantly share code, notes, and snippets.

View nschwermann's full-sized avatar
:shipit:

Nathan Schwermann nschwermann

:shipit:
View GitHub Profile
@nschwermann
nschwermann / keybase.md
Created December 3, 2019 06:42
keybase proof

Keybase proof

I hereby claim:

  • I am nschwermann on github.
  • I am nschwermann (https://keybase.io/nschwermann) on keybase.
  • I have a public key ASAff3locbJ9zf46P1nayfMpXzkXVsl3U-RvgYG8KInEwgo

To claim this, I am signing this object:

@nschwermann
nschwermann / CoroutineDialog.kt
Last active February 20, 2019 23:22
CoroutineDialog
abstract class CoroutineDialog<T>(context : Context, private val channel: Channel<DialogMessage<T>>) : AlertDialog(context) {
init {
setOnCancelListener {
channel.offer(DialogMessage.Cancelled)
}
}
fun positiveChannel(text : String, block : (() -> T)? = null) {
setButton(AlertDialog.BUTTON_POSITIVE, text){d, _ ->
@nschwermann
nschwermann / DesignSupport.kt
Last active November 22, 2020 06:38 — forked from mgranberry/DesignSupport.kt
collection of kotlin extensions for android development
package org.jetbrains.anko
import android.app.Activity
import android.support.annotation.StringRes
import android.support.design.widget.*
import android.support.v4.app.Fragment
import android.view.View
import android.view.ViewManager
import java.util.concurrent.atomic.AtomicInteger
@nschwermann
nschwermann / HeaderAdapter
Created December 20, 2014 16:42
RecyclerView HeaderAdapter
import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@nschwermann
nschwermann / ClipRevealFrame
Created December 19, 2014 06:34
CircularReveal backport
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.util.AttributeSet;
import android.widget.FrameLayout;
public class ClipRevealFrame extends FrameLayout{
private Path mRevealPath;
@nschwermann
nschwermann / ProgressView
Last active June 14, 2018 08:39
Material ProgressView
/*
* Copyright (C) 2013 The Android Open Source Project
*
* 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
@nschwermann
nschwermann / IonDataSource.java
Created October 2, 2014 22:16
Custom DataSource for ExoPlayer that uses ION/AndroidAsync
import android.content.Context;
import android.net.Uri;
import android.text.TextUtils;
import com.google.android.exoplayer.C;
import com.google.android.exoplayer.upstream.DataSource;
import com.google.android.exoplayer.upstream.DataSpec;
import com.google.android.exoplayer.upstream.HttpDataSource;
import com.google.android.exoplayer.upstream.TransferListener;
import com.google.android.exoplayer.upstream.UnexpectedLengthException;
@nschwermann
nschwermann / ExampleAdapter.java
Last active December 22, 2016 15:16
GridViewPager example
package schwiz.net.example;
import android.content.Context;
import android.graphics.Color;
import android.support.wearable.view.GridPagerAdapter;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
/**
* Creates a 'ghost' bitmap version of the given source drawable (ideally a BitmapDrawable).
* In the ghost bitmap, the RGB values take on the values from the 'color' argument, while
* the alpha values are derived from the source's grayscaled RGB values. The effect is that
* you can see through darker parts of the source bitmap, while lighter parts show up as
* the given color. The 'invert' argument inverts the computation of alpha values, and looks
* best when the given color is a dark.
*/
private Bitmap createGhostIcon(Drawable src, int color, boolean invert) {
int width = src.getIntrinsicWidth();
/*
* Copyright 2014 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