package com.kaixed.kchat.utils

import android.content.Context

/**
 * @Author: kaixed
 * @Date: 2024/10/24 22:07
 */
object DensityUtil {

    private lateinit var appContext: Context

    fun init(context: Context) {
        appContext = context.applicationContext
    }

    fun dpToPx(dp: Int): Int =
        (appContext.resources.displayMetrics.density * dp).toInt()

    fun pxToDp(px: Int): Int =
        (px / appContext.resources.displayMetrics.density).toInt()
}
