use rounded corners imageview instead of rounding it ourselves

This commit is contained in:
tibbi 2022-03-07 10:46:31 +01:00
parent 9052c5183d
commit 5e97a97e5f
3 changed files with 13 additions and 7 deletions

View File

@ -18,7 +18,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.load.resource.bitmap.CenterCrop
import com.bumptech.glide.load.resource.bitmap.FitCenter
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.RequestOptions
@ -50,7 +49,6 @@ import kotlinx.android.synthetic.main.item_thread_success.view.*
class ThreadAdapter(
activity: SimpleActivity, var messages: ArrayList<ThreadItem>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
private var fontSize = activity.getTextSize()
@SuppressLint("MissingPermission")
@ -285,7 +283,7 @@ class ThreadAdapter(
val options = RequestOptions()
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
.placeholder(placeholderDrawable)
.transform(transformation, RoundedCorners(roundedCornersRadius))
.transform(transformation)
var builder = Glide.with(context)
.load(uri)
@ -302,8 +300,10 @@ class ThreadAdapter(
false
})
if (isTallImage) {
builder = builder.override(attachment.width, attachment.width)
builder = if (isTallImage) {
builder.override(attachment.width, attachment.width)
} else {
builder.override(attachment.width, attachment.height)
}
builder.into(imageView.attachment_image)

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
<com.google.android.material.imageview.ShapeableImageView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/attachment_image"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:paddingBottom="@dimen/medium_margin" />
android:paddingBottom="@dimen/medium_margin"
app:shapeAppearanceOverlay="@style/roundedImageView" />

View File

@ -2,4 +2,8 @@
<style name="AppTheme" parent="AppTheme.Base" />
<style name="roundedImageView" parent="">
<item name="cornerFamily">rounded</item>
<item name="cornerSize">@dimen/normal_margin</item>
</style>
</resources>