mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-03-17 19:58:57 +03:00
Uploads: cleanup
This commit is contained in:
parent
a2b366ebfe
commit
e3ed3e5b05
3 changed files with 8 additions and 3 deletions
|
@ -16,5 +16,7 @@
|
|||
|
||||
package im.vector.riotx.core.ui.model
|
||||
|
||||
import androidx.annotation.Px
|
||||
|
||||
// android.util.Size in API 21+
|
||||
data class Size(val width: Int, val height: Int)
|
||||
data class Size(@Px val width: Int, @Px val height: Int)
|
||||
|
|
|
@ -17,10 +17,12 @@ package im.vector.riotx.core.utils
|
|||
|
||||
import android.content.res.Resources
|
||||
import android.util.TypedValue
|
||||
import androidx.annotation.Px
|
||||
import javax.inject.Inject
|
||||
|
||||
class DimensionConverter @Inject constructor(val resources: Resources) {
|
||||
|
||||
@Px
|
||||
fun dpToPx(dp: Int): Int {
|
||||
return TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
|
@ -29,6 +31,7 @@ class DimensionConverter @Inject constructor(val resources: Resources) {
|
|||
).toInt()
|
||||
}
|
||||
|
||||
@Px
|
||||
fun spToPx(sp: Int): Int {
|
||||
return TypedValue.applyDimension(
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
|
@ -37,7 +40,7 @@ class DimensionConverter @Inject constructor(val resources: Resources) {
|
|||
).toInt()
|
||||
}
|
||||
|
||||
fun pdToDp(px: Int): Int {
|
||||
fun pxToDp(@Px px: Int): Int {
|
||||
return (px.toFloat() / resources.displayMetrics.density).toInt()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ class RoomUploadsMediaFragment @Inject constructor(
|
|||
private fun getNumberOfColumns(): Int {
|
||||
val displayMetrics = DisplayMetrics()
|
||||
requireActivity().windowManager.defaultDisplay.getMetrics(displayMetrics)
|
||||
return dimensionConverter.pdToDp(displayMetrics.widthPixels) / IMAGE_SIZE_DP
|
||||
return dimensionConverter.pxToDp(displayMetrics.widthPixels) / IMAGE_SIZE_DP
|
||||
}
|
||||
|
||||
override fun onDestroyView() {
|
||||
|
|
Loading…
Add table
Reference in a new issue