Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

No need to expose Disposable #67

Merged
merged 1 commit into from
Mar 23, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import coil.decode.ImageDecoderDecoder
import coil.decode.SvgDecoder
import coil.loadAny
import coil.request.CachePolicy
import coil.request.Disposable
import coil.request.ImageRequest
import coil.size.Scale
import coil.transform.CircleCropTransformation
Expand Down Expand Up @@ -46,17 +45,20 @@ object ImageLoader {
errorDrawable: Drawable? = null,
@IntRange(from = 0) cornerRadius: Int = 0,
useCache: Boolean = true
): Disposable =
) {
imageView.loadBase(data, placeholderDrawable, errorDrawable, cornerRadius, useCache)
}

fun loadCircleCrop(
imageView: ImageView,
data: Any?,
placeholderDrawable: Drawable? = null,
errorDrawable: Drawable? = null,
useCache: Boolean = true
): Disposable = imageView.loadBase(data, placeholderDrawable, errorDrawable, 0, useCache) {
transformations(CircleCropTransformation())
) {
imageView.loadBase(data, placeholderDrawable, errorDrawable, 0, useCache) {
transformations(CircleCropTransformation())
}
}

fun loadCenterCrop(
Expand All @@ -66,10 +68,11 @@ object ImageLoader {
errorDrawable: Drawable? = null,
@IntRange(from = 0) cornerRadius: Int = 0,
useCache: Boolean = true
): Disposable =
) {
imageView.loadBase(data, placeholderDrawable, errorDrawable, cornerRadius, useCache) {
scale(Scale.FIT)
}
}

suspend fun getDrawable(
data: Any?,
Expand Down Expand Up @@ -101,12 +104,14 @@ object ImageLoader {
@IntRange(from = 0) cornerRadius: Int,
useCache: Boolean,
builder: ImageRequest.Builder.() -> Unit = {}
): Disposable = loadAny(data) {
placeholder(placeholderDrawable)
error(errorDrawable)
if (cornerRadius > 0) transformations(RoundedCornersTransformation(cornerRadius.toFloat()))
loadWithCache(useCache)
builder()
) {
loadAny(data) {
placeholder(placeholderDrawable)
error(errorDrawable)
if (cornerRadius > 0) transformations(RoundedCornersTransformation(cornerRadius.toFloat()))
loadWithCache(useCache)
builder()
}
Comment on lines +107 to +114
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just impl Coil in common module now, can't access Disposable in other submodules.

implementation(libs.bundles.coil)

}
}

Expand Down