package com.miya.fastcashier.util

import android.content.Context
import java.lang.NullPointerException
import java.lang.UnsupportedOperationException

/**
 * 描述: 上下文相关工具类
 */
class ContextUtils private constructor() {
    companion object {
        private var context: Context? = null

        /**
         * 初始化工具类
         *
         * @param context 上下文
         */
        fun init(context: Context) {
            Companion.context = context.applicationContext
        }

        /**
         * 获取ApplicationContext
         *
         * @return ApplicationContext
         */
        fun getContext(): Context? {
            if (context != null) return context
            throw NullPointerException("u should init first")
        }
    }

    init {
        throw UnsupportedOperationException("u can't instantiate me...")
    }
}