Skip to content

Instantly share code, notes, and snippets.

@jaredsburrows
jaredsburrows / ErrorUtils.java
Created June 14, 2017 19:02
Retrofit 2 ErrorUtils to replace RetrofitError from Retrofit 1
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import javax.net.ssl.HttpsURLConnection;
import retrofit2.Response;
import retrofit2.adapter.rxjava.HttpException;
public final class ErrorUtils {
@jaredsburrows
jaredsburrows / RestAdapter.java
Created August 18, 2017 15:46
RestAdapter from Retrofit 1
/*
* Copyright (C) 2012 Square, 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
@jaredsburrows
jaredsburrows / RetrofitError.java
Created August 18, 2017 15:47
RetrofitError from Retrofit 1
/*
* Copyright (C) 2012 Square, 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
@jaredsburrows
jaredsburrows / gist:ef4cbbf8a8a7d8b3ea9f1560daec93c0
Created September 12, 2017 05:54
Mockito 2 + LinkedIn Dexmaker + Multidex
androidTestCompile(extra["junit"])
androidTestCompile(extra["truth"])
androidTestCompile(extra["mockitoKotlin"] as String) { exclude(group = "net.bytebuddy") } // DexMaker has it"s own MockMaker
androidTestCompile(extra["mockitoCore"] as String) { exclude(group = "net.bytebuddy") } // DexMaker has it"s own MockMaker
androidTestCompile(extra["dexmakerMockito"] as String) { exclude(group = "net.bytebuddy") } // DexMaker has it"s own MockMaker
androidTestCompile(extra["runner"])
androidTestCompile(extra["espressoCore"])
androidTestCompile(extra["espressoIntents"])
androidTestCompile(extra["espressoContrib"] as String) { exclude(group = "com.android.support") }
androidTestCompile(extra["mockwebserver"])
@jaredsburrows
jaredsburrows / BstPreOrder.java
Created January 28, 2018 21:27
Unit test with System.out
import api.TreeNode;
public final class BstPreOrder {
public static void printPreOrder(TreeNode<Integer> node) {
if (node == null) {
return;
}
System.out.print(node.value + " ");
printPreOrder(node.left);
apply {
plugin("com.android.application")
plugin("jacoco")
plugin("com.github.kt3k.coveralls")
plugin("io.gitlab.arturbosch.detekt")
}
// Creates tasks based on the application build variant (productFlavor + buildType = variant)
android.applicationVariants.all { variant ->
def variantName = variant.name.capitalize()
language: android
env:
global:
- ADB_INSTALL_TIMEOUT=8
jdk:
- oraclejdk8
before_install:
@jaredsburrows
jaredsburrows / JsonApiConverter.java
Created December 15, 2015 09:33 — forked from Gregadeaux/JsonApiConverter.java
JSONAPI Converter for RetroFit with RxJava and RetroLambda
package ai.cometandroid.network;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.internal.LinkedHashTreeMap;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import android.support.annotation.Nullable;
import okhttp3.ResponseBody;
import retrofit2.Converter;
import retrofit2.Retrofit;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
/**
* https://github.com/square/retrofit/issues/1554#issuecomment-178633697
@jaredsburrows
jaredsburrows / Retry.kt
Created September 18, 2018 22:14
Test Retry Rule
@Retention(AnnotationRetention.RUNTIME)
annotation class Retry(
val retryCount: Int = -1
)