Skip to content

Instantly share code, notes, and snippets.

@jaredsburrows
jaredsburrows / nullability.gradle
Last active October 25, 2018 07:39
Generate "package-info.java" for existing Java packages for Kotlin. Adapted from http://stancalau.ro/java_package-info_generator_gradle/.
// Adapted from http://stancalau.ro/java_package-info_generator_gradle/
def generatedPackageInfoDir = "$buildDir/generated/package-info"
// Handle Android projects
if (project.plugins.hasPlugin("android")) {
android.sourceSets.main.java.srcDirs generatedPackageInfoDir
}
// Handle Java projects
if (project.plugins.hasPlugin("java")) {
@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"])
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 / 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 / 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 / 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 / Rx1TestBase.java
Last active July 28, 2019 04:16
RxAndroid overriding schedulers
import org.junit.After;
import org.junit.Before;
import rx.Scheduler;
import rx.android.plugins.RxAndroidPlugins;
import rx.android.plugins.RxAndroidSchedulersHook;
import rx.schedulers.Schedulers;
/**
* JUnit Tests.
*
import org.junit.After;
import org.junit.Before;
import rx.Scheduler;
import rx.android.plugins.RxAndroidPlugins;
import rx.android.plugins.RxAndroidSchedulersHook;
import rx.schedulers.Schedulers;
/**
* JUnit Tests.
*
@jaredsburrows
jaredsburrows / AnalyticsManager.java
Last active November 26, 2016 22:52
Burrows Apps Libs
import android.content.Context;
import android.os.Bundle;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.firebase.crash.FirebaseCrash;
import com.orhanobut.logger.Logger;
/**
* https://developers.google.com/analytics/devguides/collection/android/v4/advanced?hl=es
* https://github.com/google/iosched/blob/0a90bf8e6b90e9226f8c15b34eb7b1e4bf6d632e/android/src/main/java/com/google/samples/apps/iosched/util/java
* https://github.com/google/iosched/blob/cf1f30b4c752f275518384a9b71404ee501fc473/android/src/main/java/com/google/samples/apps/iosched/ui/BaseActivity.java
@jaredsburrows
jaredsburrows / headers_builder_example.cpp
Last active October 30, 2016 20:15
C++ Builder Examples
// A.h
class A {
public:
int var;
class Builder;
A(Builder* builder);
int getVar();
Builder* newBuilder();
};