package com.zxhl.cms.utils

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

/**
 * Created by gaoleichao on 2018/8/30.
 */
class MainLooper private constructor() {

    private val mHandler: Handler = Handler(Looper.getMainLooper())

    fun post(runnable: Runnable) {
        mHandler.post(runnable)
    }

    fun postDelayed(runnable: Runnable, delay: Long) {
        mHandler.postDelayed(runnable, delay)
    }

    companion object {

        @Volatile private var instance: MainLooper? = null

        fun get(): MainLooper? {
            if (instance == null) {
                synchronized(MainLooper::class.java) {
                    if (instance == null) instance = MainLooper()
                }
            }
            return instance
        }
    }
}