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:
Alper Ozturk 2023-10-05 11:03:15 +02:00 committed by alperozturk
parent b38c54a4c9
commit 7458ba3d60
No known key found for this signature in database
GPG key ID: 4E577DC593B59BDF
4 changed files with 10 additions and 9 deletions

View file

@ -4,4 +4,4 @@ import android.util.DisplayMetrics
fun DisplayMetrics.isLowDensityScreen(): Boolean {
return this.density < 2
}
}

View file

@ -7,4 +7,4 @@ fun LayerDrawable.setLayerSizeWithInsetTop(index: Int, size: Int, margin: Int) {
setLayerSize(index, size, size)
setLayerInsetTop(index, margin)
}
}
}

View file

@ -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 {

View file

@ -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
}
}
}