mirror of
https://github.com/nextcloud/android.git
synced 2024-11-26 23:28:42 +03:00
Fix detekt findings
Signed-off-by: Alper Ozturk <alperozturk@lions-macbook.local> Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
b38c54a4c9
commit
7458ba3d60
4 changed files with 10 additions and 9 deletions
|
@ -4,4 +4,4 @@ import android.util.DisplayMetrics
|
|||
|
||||
fun DisplayMetrics.isLowDensityScreen(): Boolean {
|
||||
return this.density < 2
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,4 +7,4 @@ fun LayerDrawable.setLayerSizeWithInsetTop(index: Int, size: Int, margin: Int) {
|
|||
setLayerSize(index, size, size)
|
||||
setLayerInsetTop(index, margin)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,10 +51,8 @@ class GroupfolderListAdapter(
|
|||
}
|
||||
|
||||
private fun getFolderIcon(): LayerDrawable? {
|
||||
val folderDrawable = MimeTypeUtil.getDefaultFolderIcon(context, viewThemeUtils) ?: return null
|
||||
val overlayDrawable = ContextCompat.getDrawable(context, R.drawable.ic_folder_overlay_account_group) ?: return null
|
||||
val drawableUtil = DrawableUtil()
|
||||
return drawableUtil.addDrawableAsOverlay(context, folderDrawable, overlayDrawable)
|
||||
val overlayDrawableId = R.drawable.ic_folder_overlay_account_group
|
||||
return MimeTypeUtil.getFileIcon(false, overlayDrawableId, context, viewThemeUtils)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
|
|
|
@ -19,8 +19,11 @@ class DrawableUtil {
|
|||
fun addDrawableAsOverlay(context: Context, backgroundDrawable: Drawable, overlayDrawable: Drawable): LayerDrawable {
|
||||
val isLowDensityScreen = context.resources.displayMetrics.isLowDensityScreen()
|
||||
|
||||
val overlayIconSize = if (isLowDensityScreen) { 12 } else { 24 }
|
||||
val overlayIconTopMargin = if (isLowDensityScreen) { 3 } else { 6 }
|
||||
val defaultIconSize = 24
|
||||
val defaultIconTopMargin = 6
|
||||
|
||||
val overlayIconSize = if (isLowDensityScreen) { defaultIconSize / 2 } else { defaultIconSize }
|
||||
val overlayIconTopMargin = if (isLowDensityScreen) { defaultIconTopMargin / 2 } else { defaultIconTopMargin }
|
||||
|
||||
val layerDrawable = LayerDrawable(arrayOf(backgroundDrawable, overlayDrawable))
|
||||
layerDrawable.setLayerSizeWithInsetTop(1, overlayIconSize, overlayIconTopMargin)
|
||||
|
@ -28,4 +31,4 @@ class DrawableUtil {
|
|||
|
||||
return layerDrawable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue