All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
main.com.sceyt.chatuikit.persistence.mappers.LinkMappers.kt Maven / Gradle / Ivy
package com.sceyt.chatuikit.persistence.mappers
import com.sceyt.chat.models.link.LinkDetails
import com.sceyt.chatuikit.data.models.messages.LinkPreviewDetails
import com.sceyt.chatuikit.persistence.entity.link.LinkDetailsEntity
fun LinkDetails.toLinkDetailsEntity(link: String, thumb: String?): LinkDetailsEntity {
val image = images.getOrNull(0)
return LinkDetailsEntity(
link = link,
url = url,
title = title,
description = description,
siteName = site_name,
faviconUrl = favicon?.url,
imageUrl = image?.url,
imageWidth = image?.width?.toIntOrNull(),
imageHeight = image?.height?.toIntOrNull(),
thumb = thumb
)
}
fun LinkPreviewDetails.toLinkDetailsEntity() = LinkDetailsEntity(
link = link,
url = url,
title = title,
description = description,
siteName = siteName,
faviconUrl = faviconUrl,
imageUrl = imageUrl,
imageWidth = imageWidth,
imageHeight = imageHeight,
thumb = thumb
)
fun LinkDetails.toLinkPreviewDetails(link: String): LinkPreviewDetails {
val image = images.getOrNull(0)
return LinkPreviewDetails(
link = link,
url = url,
title = title,
description = description,
siteName = site_name,
faviconUrl = favicon?.url,
imageUrl = image?.url,
imageWidth = image?.width?.toIntOrNull(),
imageHeight = image?.height?.toIntOrNull(),
thumb = null,
hideDetails = false
)
}
fun LinkDetailsEntity.toLinkPreviewDetails(hideDetails: Boolean): LinkPreviewDetails = LinkPreviewDetails(
link = link,
url = url,
title = title,
description = description,
siteName = siteName,
faviconUrl = faviconUrl,
imageUrl = imageUrl,
imageWidth = imageWidth,
imageHeight = imageHeight,
thumb = thumb,
hideDetails = hideDetails
)