Replace: Use of ShapeableImageView instead of ImageView

This commit is contained in:
LooKeR 2021-10-20 00:45:29 +05:30
parent 380faea31e
commit dde437349c
2 changed files with 9 additions and 8 deletions

View File

@ -7,7 +7,6 @@ import android.graphics.drawable.Drawable
import android.os.Bundle
import android.view.ViewGroup
import android.view.WindowManager
import android.widget.ImageView
import androidx.core.view.WindowCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.WindowInsetsControllerCompat
@ -16,6 +15,7 @@ import androidx.fragment.app.FragmentManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager2.widget.MarginPageTransformer
import androidx.viewpager2.widget.ViewPager2
import com.google.android.material.imageview.ShapeableImageView
import com.looker.droidify.R
import com.looker.droidify.database.Database
import com.looker.droidify.entity.Product
@ -174,9 +174,10 @@ class ScreenshotsFragment() : DialogFragment() {
StableRecyclerAdapter<Adapter.ViewType, RecyclerView.ViewHolder>() {
enum class ViewType { SCREENSHOT }
private class ViewHolder(context: Context) : RecyclerView.ViewHolder(ImageView(context)) {
val image: ImageView
get() = itemView as ImageView
private class ViewHolder(context: Context) :
RecyclerView.ViewHolder(ShapeableImageView(context)) {
val image: ShapeableImageView
get() = itemView as ShapeableImageView
val placeholder: Drawable

View File

@ -14,12 +14,12 @@ import android.util.Xml
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.TextView
import androidx.core.content.ContextCompat
import coil.load
import coil.request.ImageRequest
import coil.util.CoilUtils
import com.google.android.material.imageview.ShapeableImageView
import com.looker.droidify.utility.extension.android.Android
import org.xmlpull.v1.XmlPullParser
import kotlin.math.roundToInt
@ -100,10 +100,10 @@ fun ViewGroup.inflate(layoutResId: Int): View {
return LayoutInflater.from(context).inflate(layoutResId, this, false)
}
fun ImageView.load(uri: Uri, builder: ImageRequest.Builder.() -> Unit = {}) {
fun ShapeableImageView.load(uri: Uri, builder: ImageRequest.Builder.() -> Unit = {}) {
this.load(uri = uri, builder = builder)
}
fun ImageView.clear() {
fun ShapeableImageView.clear() {
CoilUtils.clear(this)
}