Skip to content

Instantly share code, notes, and snippets.

View liufuxin's full-sized avatar

LiuFuXin liufuxin

View GitHub Profile
@liufuxin
liufuxin / Singleton.java
Created February 26, 2018 06:36
Singleton
/**
* Singleton helper class for lazily initialization.
*/
public abstract class Singleton<T> {
private T mInstance;
protected abstract T create();
public final T get() {
@liufuxin
liufuxin / OomExceptionHandler.java
Created January 21, 2016 08:08 — forked from pyricau/OomExceptionHandler.java
Dump the heap on OutOfMemoryError crashes in your debug builds.
import android.content.Context;
import android.os.Debug;
import java.io.File;
public class OomExceptionHandler implements Thread.UncaughtExceptionHandler {
private static final String FILENAME = "out-of-memory.hprof";
public static void install(Context context) {
Thread.UncaughtExceptionHandler defaultHandler = Thread.getDefaultUncaughtExceptionHandler();
@liufuxin
liufuxin / FRelativeLayout.java
Created December 29, 2015 07:42 — forked from shakalaca/FRelativeLayout.java
RelativeLayout with foreground like FrameLayout does.
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.NinePatchDrawable;
import android.util.AttributeSet;
import android.widget.RelativeLayout;
public class FRelativeLayout extends RelativeLayout {