Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Kevin Woodland kevelbreh

🏠
Working from home
  • OrderIn
  • Cape Town, South Africa
View GitHub Profile
@kevelbreh
kevelbreh / TokenAttachingInterceptor.java
Created Jun 24, 2019
TokenAttachingInterceptor for OkHttpClient
View TokenAttachingInterceptor.java
import android.support.annotation.NonNull;
import com.jakewharton.rxrelay2.BehaviorRelay;
import java.io.IOException;
import javax.inject.Inject;
import javax.inject.Singleton;
import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import timber.log.Timber;
@kevelbreh
kevelbreh / example.js
Created Apr 1, 2017
Calling a function based off of a string value
View example.js
var fn = self[("on_" + command)];
if (typeof fn === "function") {
fn(prefix, args);
} else {
console.log("No handler for: ", "on_internal_" + command);
}
@kevelbreh
kevelbreh / DemoActivity.java
Created May 21, 2016
The menu methods (onCreateOptionsMenu, onPrepareOptionsMenu, onOptionsItemSelected) are never invoked for both controllers. Also, when pressing the default back button, the controller is popped but it's view still lingers on screen.
View DemoActivity.java
package com.kevelbreh.fit.demo;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
@kevelbreh
kevelbreh / StethoTree
Last active Jul 13, 2018
Stetho Timber Logger
View StethoTree
import android.util.Log;
import com.facebook.stetho.inspector.jsonrpc.JsonRpcPeer;
import com.facebook.stetho.inspector.protocol.ChromeDevtoolsMethod;
import org.json.JSONObject;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import timber.log.Timber;
/**
* Log things to console (hacked job).
You can’t perform that action at this time.