mirror of
https://github.com/lizongying/my-tv.git
synced 2026-11-21 02:46:30 +08:00
17
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
package com.lizongying.mytv
|
||||
|
||||
import android.content.res.Resources
|
||||
import android.util.TypedValue
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.Date
|
||||
import java.util.Locale
|
||||
@@ -12,4 +14,20 @@ object Utils {
|
||||
fun getDateTimestamp(): Long {
|
||||
return Date().time / 1000
|
||||
}
|
||||
|
||||
fun dpToPx(dp: Float): Int {
|
||||
return TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
dp,
|
||||
Resources.getSystem().displayMetrics
|
||||
).toInt()
|
||||
}
|
||||
|
||||
fun dpToPx(dp: Int): Int {
|
||||
return TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
dp.toFloat(),
|
||||
Resources.getSystem().displayMetrics
|
||||
).toInt()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user