Skip to content

Instantly share code, notes, and snippets.

@bugraoral
bugraoral / Contact.java
Created May 10, 2016 07:13
Loading contacts with thumbnail images faster. Normally, with any loader fetching 500 contacts with images can take up to 3 seconds. With this task you can load them in ~500ms.
import android.os.Parcel;
import android.os.Parcelable;
import android.support.annotation.IntDef;
import android.text.TextUtils;
import java.io.Serializable;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public class Contact {
@bugraoral
bugraoral / getmesurement.java
Last active August 29, 2015 13:56
Used for getting layout measurements when layout has not been calculated and drawn.
final ViewTreeObserver viewTreeObserver = view.getViewTreeObserver();
if(viewTreeObserver.isAlive()){
viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
@SuppressWarnings("deprecation")
@SuppressLint("NewApi")
public void onGlobalLayout() {
if(Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
view.getViewTreeObserver().removeGlobalOnLayoutListener(this);