Skip to content

Instantly share code, notes, and snippets.

View AndrewReitz's full-sized avatar

Andrew Reitz AndrewReitz

View GitHub Profile
@AndrewReitz
AndrewReitz / settings.gradle.kts
Last active December 6, 2021 23:19
settings.gradle pluginManagement
pluginManagement {
repositories {
gradlePluginPortal()
google()
jcenter()
maven { url = uri("https://maven.fabric.io/public") }
}
resolutionStrategy {
eachPlugin {
@AndrewReitz
AndrewReitz / README.md
Created November 15, 2017 21:50
ZarZaring the Groovy Jar for Android 26+
  1. Download JarJar jar
  2. In the same folder download the grooid jar you want to use. This was tested with 2.4.12 jar
  3. Again, in the same folder create a file called rules.txt
  4. In rules.txt put "zap org.codehaus.groovy.vmplugin.v7.IndyInterface"
  5. Run java -jar jarjar-1.3.jar process rules.txt groovy-2.4.12-grooid.jar groovy-android.jar
  6. Now add newly created jar file to your android project.
@AndrewReitz
AndrewReitz / Animal.java
Created October 24, 2017 15:06
Kotlin Kapt Error
package com.andrew;
// move this below other imports
// or do not resolve statically and error goes away.
import static com.andrew.Animal.Legs.FOUR;
import com.google.auto.value.AutoValue;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@AndrewReitz
AndrewReitz / configLoader.gradle
Created October 6, 2017 18:31
Gradle Property / Configuration Loader
/**
* Grabs a configuration value from configuration property or system properties (in that order) if
* one exits. Otherwise the default value will be used. If a default value is not provided an empty
* string will be used.
*
* @param values Map containing the property name to look for (propertyName), the system environment
* variable name to look for (environmentPropertyName), and the default value if any to use
* if a value was not found.
* @return the first found value, project property, then system, then default value. If no default
* value was provided an empty string will be returned.
[ratpack-compute-27-6] ERROR ratpack.exec.Execution - Uncaught execution exception
ratpack.registry.NotInRegistryException: No object for type 'ratpack.handling.Context' in registry
at ratpack.registry.Registry.get(Registry.java:136)
at ratpack.registry.Registry.get(Registry.java:120)
at ratpack.retrofit.internal.RatpackCallFactory$RatpackCall.promise(RatpackCallFactory.java:83)
at ratpack.retrofit.internal.RatpackCallFactory$RatpackCall.enqueue(RatpackCallFactory.java:70)
at retrofit2.OkHttpCall.enqueue(OkHttpCall.java:101)
at ratpack.retrofit.internal.RatpackCallAdapterFactory$SimpleCallAdapter.lambda$adapt$0(RatpackCallAdapterFactory.java:135)
at ratpack.exec.internal.DefaultExecution.lambda$null$1(DefaultExecution.java:119)
at ratpack.exec.internal.DefaultExecution$SingleEventExecStream.exec(DefaultExecution.java:423)
@AndrewReitz
AndrewReitz / ImmutableList.java
Last active December 25, 2018 22:56
Immutable List Stuff
import android.support.annotation.NonNull;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;
@AndrewReitz
AndrewReitz / KeyboardHider.java
Last active May 19, 2017 15:03
KeyboardHider (Android)
/**
* Provides a simple way to hide a keyboard, because google didn't
*/
@Singleton
public final class KeyboardHider {
private final InputMethodManager inputMethodManager;
@Inject KeyboardHider(InputMethodManager inputMethodManager) {
this.inputMethodManager = checkNotNull(inputMethodManager, "inputMethodManager == null");
@AndrewReitz
AndrewReitz / ImmutableList.java
Created March 20, 2017 15:18
Simple Java Immutable List
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.RandomAccess;
import static com.fernandocejas.arrow.checks.Preconditions.checkNotNull;

Keybase proof

I hereby claim:

  • I am AndrewReitz on github.
  • I am areitz (https://keybase.io/areitz) on keybase.
  • I have a public key whose fingerprint is 6513 2A0E 64C9 3BC1 EDB4 BA62 0221 9C76 97C0 FB6E

To claim this, I am signing this object:

@AndrewReitz
AndrewReitz / DrawableStartButton.java
Created February 7, 2017 16:05
DrawableStartButton, and Icon Drawable for Android
/** A button that allows you to add a drawable to the start of the text. */
public class DrawableStartButton extends FrameLayout {
/** The textview that sits on top of the framelayout that contains the image and the text. */
@BindView(R.id.drawable_start_textview) TextView textview;
public DrawableStartButton(Context context, AttributeSet attrs) {
// Trick the framelayout to look like a button
this(context, attrs, R.attr.drawableStartButton);
}