Android Open Source - mcdroid Mc Handler






From Project

Back to project page mcdroid.

License

The source code is released under:

Apache License

If you think the Android project mcdroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/**
 * //from   www.  j a  v a 2  s. co  m
 */
package cn.mibcxb.android.os;

import java.lang.ref.SoftReference;

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

/**
 * @author mibcxb
 *
 */
public class McHandler<T> extends Handler {

    private final SoftReference<T> reference;

    public McHandler(T r) {
        this.reference = new SoftReference<T>(r);
    }

    public McHandler(T r, Callback callback) {
        super(callback);
        this.reference = new SoftReference<T>(r);
    }

    public McHandler(T r, Looper looper) {
        super(looper);
        this.reference = new SoftReference<T>(r);
    }

    public McHandler(T r, Looper looper, Callback callback) {
        super(looper, callback);
        this.reference = new SoftReference<T>(r);
    }

    @Override
    public final void handleMessage(Message msg) {
        T r = reference.get();
        if (r != null) {
            handleMessage(r, msg);
        }
    }

    public void handleMessage(T r, Message msg) {
    }

}




Java Source Code List

cn.mibcxb.acra.CrashReportWriter.java
cn.mibcxb.android.app.McApplication.java
cn.mibcxb.android.os.McHandler.java
cn.mibcxb.android.util.Logger.java
cn.mibcxb.android.util.NetworkWatcher.java
cn.mibcxb.util.McIO.java
cn.mibcxb.util.McMath.java