package com.zx.ad.utils;

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

/**
 * 工具栏,处理子线程需要丢到主线程逻辑使用
 */
public class ThreadUtils
{
    private static Handler sUiHander = null;

    public static boolean isUIThread()
    {
        final Looper myLooper = Looper.myLooper();
        final Looper mainLooper = Looper.getMainLooper();
        return mainLooper.equals(myLooper);
    }

    static
    {
        sUiHander = new Handler(Looper.getMainLooper());
    }

    public static void runOnUIT(Runnable runnable)
    {
        sUiHander.post(runnable);
    }

    public static void postOnUIDelayed(Runnable r, long delay)
    {
        sUiHander.postDelayed(r, delay);
    }
}
