Skip to content

Instantly share code, notes, and snippets.

Ryan Harter rharter

  • Chicago
Block or report user

Report or block rharter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rharter
rharter / InjectableActivityTestRule.kt
Last active Mar 22, 2019
Test Rule that allows you to use Dagger Android's automatic lifecycle based injection without making your Application class `open`, or overriding it in tests.
View InjectableActivityTestRule.kt
package com.pixite.pigment.testing
import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
@rharter
rharter / config.yaml
Created May 24, 2018
Example Circle CI config file
View config.yaml
version: 2.0
defaults: &defaults
docker:
- image: menny/android_ndk:latest
working_directory: ~/pigment
environment:
_JAVA_OPTIONS: "-Xmx1400m -XX:ParallelGCThreads=2 -XX:ConcGCThreads=2 -XX:ParallelGCThreads=2 -Djava.util.concurrent.ForkJoinPool.common.parallelism=2"
TERM: dumb
@rharter
rharter / LiveEvent.kt
Last active May 11, 2018
LiveData that only delivers new events to observers.
View LiveEvent.kt
import android.arch.lifecycle.LifecycleOwner
import android.arch.lifecycle.MediatorLiveData
import android.arch.lifecycle.Observer
open class LiveEvent<T>() : MediatorLiveData<T>() {
constructor(initialValue: T): this() {
value = initialValue
}
@rharter
rharter / ViewCompatExt.kt
Last active Feb 4, 2018
Extension methods to easily provide all functionality in ViewCompat. This makes it super easy to see when there is a compat method available in code completion right alongside the framework methods.
View ViewCompatExt.kt
import android.content.ClipData
import android.graphics.Paint
import android.os.Build
import android.os.Bundle
import android.support.v4.view.*
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat
import android.support.v4.view.accessibility.AccessibilityNodeProviderCompat
import android.view.*
/**
@rharter
rharter / SharedPreferenceLiveData.kt
Last active Jun 24, 2019
Creates LiveData objects that observe a value in SharedPreferences while they have active listeners.
View SharedPreferenceLiveData.kt
import android.arch.lifecycle.LiveData
import android.content.SharedPreferences
abstract class SharedPreferenceLiveData<T>(val sharedPrefs: SharedPreferences,
val key: String,
val defValue: T) : LiveData<T>() {
private val preferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == this.key) {
value = getValueFromPreferences(key, defValue)
@rharter
rharter / copy_res.sh
Created Dec 6, 2016
Bash script to copy all versions of an Android resource from one project directory into another, preserving version qualifiers.
View copy_res.sh
#!/bin/bash
function usage {
name=$0
echo "Usage: $name"
echo ""
echo "Searches for and copies all versions of an Android resource"
echo "(currently only drawables) from one project directory into "
echo "another, preserving version qualifiers."
echo ""
View keybase.md

Keybase proof

I hereby claim:

  • I am rharter on github.
  • I am rharter (https://keybase.io/rharter) on keybase.
  • I have a public key ASC2PVpf79-TV0qyzGGs0SalYN6fNpE0cnhm0vTLNMsWFwo

To claim this, I am signing this object:

@rharter
rharter / RevealDrawable.java
Created Apr 3, 2015
A Drawable that transitions between two child Drawables based on this Drawable's current level value. The idea here is that the center value (5000) will show the 'selected' Drawable, and any other value will show a transitional value between the 'selected' Drawable and the 'unselected' Drawable.
View RevealDrawable.java
package com.pixite.fragment.widget;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.ColorFilter;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Drawable.Callback;
import android.view.Gravity;
View ThemeableMediaRouteActionProvider.java
package com.ryanharter.mediaroute.widgets;
import android.content.Context;
import android.support.v7.app.MediaRouteActionProvider;
import android.support.v7.app.MediaRouteButton;
/**
* A MediaRouteActionProvider that allows the use of a ThemeableMediaRouteButton.
*/
public class ThemeableMediaRouteActionProvider extends MediaRouteActionProvider {
View gist:9c99318faf116317d426
public Observable<Show> getShows() {
return authClient.getAuthString()
.flatMap(token -> contentApi.getShows(token, selectedMediaServer))
.flatMap(shows -> Observable.from(shows.getShows()))
.flatMap(this::getImdbId);
}
public Observable<Show> getImdbId(Show show) {
return omdbApi.searchByTitle(show.getTitle())
.flatMap(movie -> {
You can’t perform that action at this time.