Skip to content

Instantly share code, notes, and snippets.

View natuanorg's full-sized avatar
🏠
Working from home

Tuan Nguyen natuanorg

🏠
Working from home
View GitHub Profile
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#FFEBEE</color>
<color name="md_red_100">#FFCDD2</color>
<color name="md_red_200">#EF9A9A</color>
@natuanorg
natuanorg / KeyBoardUtis
Created March 17, 2015 17:26
Hide keyboard on touch outside of textfield
private Rect mRect = new Rect();
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
final int action = MotionEventCompat.getActionMasked(ev);
int[] location = new int[2];
edtSearch.getLocationOnScreen(location);
mRect.left = location[0];
mRect.top = location[1];
mRect.right = location[0] + edtSearch.getWidth();
@natuanorg
natuanorg / ExceptionHandler
Created January 30, 2015 07:26
ExceptionHandler
public class ExceptionHandler implements
java.lang.Thread.UncaughtExceptionHandler {
private final Activity myContext;
private final String LINE_SEPARATOR = "\n";
private final String TAG = "ExceptionHandler";
public ExceptionHandler(Activity context) {
myContext = context;
}
/**
* Sub-class of ImageView which automatically notifies the drawable when it is
* being displayed.
*/
public class RecyclingImageView extends ImageView {
public RecyclingImageView(Context context) {
super(context);
}
/**
* A BitmapDrawable that keeps track of whether it is being displayed or cached.
* When the drawable is no longer being displayed or cached,
* {@link android.graphics.Bitmap#recycle() recycle()} will be called on this drawable's bitmap.
*/
public class RecyclingBitmapDrawable extends BitmapDrawable {
static final String TAG = "CountingBitmapDrawable";
private int mCacheRefCount = 0;
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- google's material design colours from
http://www.google.com/design/spec/style/color.html#color-ui-color-palette -->
<!--reds-->
<color name="md_red_50">#fde0dc</color>
<color name="md_red_100">#f9bdbb</color>
<color name="md_red_200">#f69988</color>
public class FragmentObserver extends Observable {
@Override
public void notifyObservers() {
setChanged(); // Set the changed flag to true, otherwise observers won't be notified.
super.notifyObservers();
}
}