Skip to content

Commit 5e97a97

Browse files
committed
use rounded corners imageview instead of rounding it ourselves
1 parent 9052c51 commit 5e97a97

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

app/src/main/kotlin/com/simplemobiletools/smsmessenger/adapters/ThreadAdapter.kt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import com.bumptech.glide.load.engine.DiskCacheStrategy
1818
import com.bumptech.glide.load.engine.GlideException
1919
import com.bumptech.glide.load.resource.bitmap.CenterCrop
2020
import com.bumptech.glide.load.resource.bitmap.FitCenter
21-
import com.bumptech.glide.load.resource.bitmap.RoundedCorners
2221
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
2322
import com.bumptech.glide.request.RequestListener
2423
import com.bumptech.glide.request.RequestOptions
@@ -50,7 +49,6 @@ import kotlinx.android.synthetic.main.item_thread_success.view.*
5049
class ThreadAdapter(
5150
activity: SimpleActivity, var messages: ArrayList<ThreadItem>, recyclerView: MyRecyclerView, itemClick: (Any) -> Unit
5251
) : MyRecyclerViewAdapter(activity, recyclerView, itemClick) {
53-
private val roundedCornersRadius = resources.getDimension(R.dimen.normal_margin).toInt()
5452
private var fontSize = activity.getTextSize()
5553

5654
@SuppressLint("MissingPermission")
@@ -285,7 +283,7 @@ class ThreadAdapter(
285283
val options = RequestOptions()
286284
.diskCacheStrategy(DiskCacheStrategy.RESOURCE)
287285
.placeholder(placeholderDrawable)
288-
.transform(transformation, RoundedCorners(roundedCornersRadius))
286+
.transform(transformation)
289287

290288
var builder = Glide.with(context)
291289
.load(uri)
@@ -302,8 +300,10 @@ class ThreadAdapter(
302300
false
303301
})
304302

305-
if (isTallImage) {
306-
builder = builder.override(attachment.width, attachment.width)
303+
builder = if (isTallImage) {
304+
builder.override(attachment.width, attachment.width)
305+
} else {
306+
builder.override(attachment.width, attachment.height)
307307
}
308308

309309
builder.into(imageView.attachment_image)
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<ImageView xmlns:android="http://schemas.android.com/apk/res/android"
2+
<com.google.android.material.imageview.ShapeableImageView xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
android:id="@+id/attachment_image"
45
android:layout_width="wrap_content"
56
android:layout_height="wrap_content"
67
android:adjustViewBounds="true"
7-
android:paddingBottom="@dimen/medium_margin" />
8+
android:paddingBottom="@dimen/medium_margin"
9+
app:shapeAppearanceOverlay="@style/roundedImageView" />

app/src/main/res/values/styles.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22

33
<style name="AppTheme" parent="AppTheme.Base" />
44

5+
<style name="roundedImageView" parent="">
6+
<item name="cornerFamily">rounded</item>
7+
<item name="cornerSize">@dimen/normal_margin</item>
8+
</style>
59
</resources>

0 commit comments

Comments
 (0)