Skip to content

Commit

Permalink
Merge pull request #124 from Infomaniak/loadAvatar-disposable
Browse files Browse the repository at this point in the history
Remove unused `Disposable` return value
  • Loading branch information
KevinBoulongne authored Feb 1, 2024
2 parents a007a38 + 0810816 commit cd57493
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/main/java/com/infomaniak/lib/core/utils/Extensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
import coil.ImageLoader
import coil.load
import coil.request.Disposable
import com.github.razir.progressbutton.*
import com.github.razir.progressbutton.DrawableButton.Companion.GRAVITY_CENTER
import com.github.razir.progressbutton.hideProgress
Expand Down Expand Up @@ -314,17 +313,17 @@ fun SharedPreferences.transaction(block: SharedPreferences.Editor.() -> Unit) {
fun ImageView.loadAvatar(
user: User,
imageLoader: ImageLoader = context.simpleImageLoader,
): Disposable = loadAvatar(user.id, user.avatar, user.getInitials(), imageLoader)
) = loadAvatar(user.id, user.avatar, user.getInitials(), imageLoader)

fun ImageView.loadAvatar(
id: Int,
avatarUrl: String?,
initials: String,
imageLoader: ImageLoader = context.simpleImageLoader,
@ColorInt initialsColor: Int = Color.WHITE,
): Disposable {
) {
val backgroundColor = context.getBackgroundColorBasedOnId(id)
return loadAvatar(backgroundColor, avatarUrl, initials, imageLoader, initialsColor)
loadAvatar(backgroundColor, avatarUrl, initials, imageLoader, initialsColor)
}

fun ImageView.loadAvatar(
Expand All @@ -333,13 +332,13 @@ fun ImageView.loadAvatar(
initials: String,
imageLoader: ImageLoader = context.simpleImageLoader,
@ColorInt initialsColor: Int = Color.WHITE,
): Disposable {
) {
val fallback = context.generateInitialsAvatarDrawable(
initials = initials,
background = backgroundColor,
initialsColor = initialsColor,
)
return load(avatarUrl, imageLoader) {
load(avatarUrl, imageLoader) {
error(fallback)
fallback(fallback)
placeholder(fallback)
Expand Down

0 comments on commit cd57493

Please sign in to comment.