Skip to content

Commit

Permalink
Image loading changed
Browse files Browse the repository at this point in the history
  • Loading branch information
nono3551 committed Jun 18, 2020
1 parent 55c0a0a commit 100963b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ android {
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0.11"
versionName "1.0.12"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down
21 changes: 19 additions & 2 deletions app/src/main/java/sk/backbone/android/shared/utils/UiUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat
import com.bumptech.glide.Glide
import com.bumptech.glide.request.RequestOptions
import sk.backbone.android.shared.ui.components.SafeClickListener
import java.math.BigDecimal


fun View.setSafeOnClickListener(action: (View) -> Unit) {
Expand Down Expand Up @@ -118,7 +119,23 @@ fun TextView?.setTextAndUpdateVisibility(input: CharSequence?){
this?.text = input
}

fun ImageView.loadResource(url: String?, options: RequestOptions = RequestOptions().apply{ centerCrop() }, defaultImage: Int){
fun ImageView.loadResource(url: String?, defaultImage: Int? = null, options: RequestOptions = RequestOptions().apply{ centerCrop() }){
Glide.with(this).clear(this)
Glide.with(this).load(url).apply(options).placeholder(defaultImage).fallback(defaultImage).into(this)
Glide.with(this).load(url).apply(options).apply {
if (defaultImage != null) {
placeholder(defaultImage).fallback(defaultImage).into(this@loadResource)
}
else {
into(this@loadResource)
}
}
}

fun Int.getResourceStringValue(context: Context) : String{
return context.resources.getString(this)
}

fun BigDecimal.getAsEuros(context: Context): String{
val euroSign = ""
return String.format("$this $euroSign")
}

0 comments on commit 100963b

Please sign in to comment.