Skip to content

Instantly share code, notes, and snippets.

View adamcmwilson's full-sized avatar

Adam Wilson adamcmwilson

View GitHub Profile
@adamcmwilson
adamcmwilson / Example.java
Created January 13, 2017 05:44
Chained Api calls with RxJava
public class Example {
private String auth_token;
private void chainApiCalls() throws Exception {
api.getToken()
.doOnNext(token -> auth_token = token)
.flatMap(api::getPersonNumber)
.flatMap(person_number -> api.getUserInfo(auth_token, person_number))
.doOnCompleted(() -> auth_token = null)
@adamcmwilson
adamcmwilson / BundleUtils
Created January 22, 2015 20:34
Bundle Key/Value Debug Logging
import android.os.Bundle;
import com.nuvyyo.android.slipstream.exovideoplayer.BuildConfig;
public class BundleUtils {
public static void logBundleKeys(Bundle args) {
try {
if (BuildConfig.DEBUG)
for (String key : args.keySet()) {
final Object value = args.get(key);
@adamcmwilson
adamcmwilson / GMSUtil
Last active August 29, 2015 14:11
Google Play Services Update Check
import android.content.Context;
import com.google.android.gms.common.ConnectionResult;
import com.google.android.gms.common.GooglePlayServicesUtil;
public class GMSUtil {
public static PlayServicesState getPlayServicesState(Context context) {
String message = "";
@adamcmwilson
adamcmwilson / DateTimeIntervalPhraser
Created June 21, 2014 02:55
Creates an English phrase for time intervals such as "in 2 weeks" or "5 minutes ago"
public static class DateTimeIntervalPhraser {
public static class Values {
public static final Long SECOND = 1000l;
public static final Long MINUTE = 60 * SECOND;
public static final Long HOUR = 60 * MINUTE;
public static final Long DAY = 24 * HOUR;
public static final Long WEEK = 7 * DAY;
public static final Long YEAR = 365 * DAY;