package com.android.launcher3.util;

import android.os.Handler;
import android.os.Looper;
import android.os.Message;

import java.lang.ref.WeakReference;

public class WeakHandler<T> extends Handler {

    private WeakReference<T> weakReference;

    public WeakHandler(T weak) {
        super(Looper.getMainLooper());
        weakReference=new WeakReference<T>(weak);
    }



    @Override
    public void dispatchMessage(Message msg) {
        if (weakReference.get()!=null){
            super.dispatchMessage(msg);
        }
    }
}
