Skip to content

Instantly share code, notes, and snippets.

View kmerrell42's full-sized avatar

Kelly Merrell kmerrell42

  • Mercury Intermedia
  • United States
View GitHub Profile
@kmerrell42
kmerrell42 / gist:df17a292d9fc592e5771ad54e8a0e6dd
Created March 17, 2017 18:40
Android LayoutInflater.Factory2 for DI example
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final Picasso picasso = Picasso.with(this);
LayoutInflater.Factory2 customInflaterFactory = new LayoutInflater.Factory2() {
@Override
public View onCreateView(View parent, String name, Context context, AttributeSet attrs) {
return onCreateView(name, context, attrs);
@kmerrell42
kmerrell42 / gist:b4ff31733c562a3262ee9a42f5704a89
Created February 23, 2017 22:08
Using headers from a WebView.load(...) response. Kinda ugly implementation since it requires exposing the networking implementation at the "view" level.
package io.mercury.monkeybutt.webviewintercept;
import android.annotation.TargetApi;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.webkit.WebResourceRequest;
import android.webkit.WebResourceResponse;
import android.webkit.WebView;
@kmerrell42
kmerrell42 / NullObject.java
Created November 10, 2016 18:11
Utility for creating "null objects" out of interfaces
com.my.package.name.util;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
public class NullObject {
private static class NullInvocationHandler implements InvocationHandler {