Stop using deprecated method.

This commit is contained in:
Benoit Marty 2022-08-24 17:30:36 +02:00 committed by Benoit Marty
parent 3f3c83a43d
commit 24e4f94e61
1 changed files with 8 additions and 5 deletions

View File

@ -82,15 +82,18 @@ class RoomUploadsMediaFragment :
controller.listener = this
}
@Suppress("DEPRECATION")
private fun getNumberOfColumns(): Int {
val displayMetrics = DisplayMetrics()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
requireContext().display?.getMetrics(displayMetrics)
val screenWidthInPx = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val a = requireActivity().windowManager.currentWindowMetrics
a.bounds.width()
} else {
val displayMetrics = DisplayMetrics()
@Suppress("DEPRECATION")
requireActivity().windowManager.defaultDisplay.getMetrics(displayMetrics)
displayMetrics.widthPixels
}
return dimensionConverter.pxToDp(displayMetrics.widthPixels) / IMAGE_SIZE_DP
val screenWidthInDp = dimensionConverter.pxToDp(screenWidthInPx)
return screenWidthInDp / IMAGE_SIZE_DP
}
override fun onDestroyView() {