Skip to content

Commit

Permalink
Reduced the largest- and smallestAvailableImage field getters to two …
Browse files Browse the repository at this point in the history
…lines each in the Profile class.
  • Loading branch information
Iiro Krankka committed Feb 3, 2017
1 parent bfb272b commit 600f538
Showing 1 changed file with 2 additions and 26 deletions.
28 changes: 2 additions & 26 deletions app/src/main/java/com/codemate/koffeemate/data/models/Profile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,34 +29,10 @@ open class Profile(
open var image_512: String? = null
) : RealmObject(), Parcelable {
val largestAvailableImage: String
get() {
var imageUrl: String? = image_512

if (imageUrl.isNullOrBlank()) {
imageUrl = image_192
}

if (imageUrl.isNullOrBlank()) {
imageUrl = image_72
}

return imageUrl ?: ""
}
get() = image_512 ?: image_192 ?: image_72 ?: ""

val smallestAvailableImage: String
get() {
var imageUrl: String? = image_72

if (imageUrl.isNullOrBlank()) {
imageUrl = image_192
}

if (imageUrl.isNullOrBlank()) {
imageUrl = image_512
}

return imageUrl ?: ""
}
get() = image_72 ?: image_192 ?: image_512 ?: ""

companion object {
@JvmField val CREATOR: Parcelable.Creator<Profile> = object : Parcelable.Creator<Profile> {
Expand Down

0 comments on commit 600f538

Please sign in to comment.