Skip to content

Commit

Permalink
Make classes internal and use application context
Browse files Browse the repository at this point in the history
  • Loading branch information
jeslat committed Feb 14, 2024
1 parent 17aa31c commit 3712b3d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,14 @@ sealed class SelectableAsset {
val rowAsset: RowAsset,
) : SelectableAsset() {
@Deprecated("Use primary constructor providing a RowAsset object instead")
constructor(id: Int) : this(RowAsset.DrawableIdAsset(id))
constructor(@DrawableRes id: Int) : this(RowAsset.DrawableIdAsset(id))
}

data class LargeIcon(
val rowAsset: RowAsset,
) : SelectableAsset() {
@Deprecated("Use primary constructor providing a RowAsset object instead")
constructor(id: Int) : this(RowAsset.DrawableIdAsset(id))
constructor(@DrawableRes id: Int) : this(RowAsset.DrawableIdAsset(id))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ internal sealed class ListElementViewData(

enum class RowActionStyleViewData { Default, Destructive }

sealed class SelectableListAssetViewData {
internal sealed class SelectableListAssetViewData {
data class Image(val asset: RowAssetViewData) : SelectableListAssetViewData()
data class SmallImage(val asset: RowAssetViewData) : SelectableListAssetViewData()
data class SmallIcon(val asset: RowAssetViewData) : SelectableListAssetViewData()
data class LargeIcon(val asset: RowAssetViewData) : SelectableListAssetViewData()
}

sealed class InformativeIconViewData {
internal sealed class InformativeIconViewData {
data object Bullet : InformativeIconViewData()
data class Icon(val asset: RowAssetViewData) : InformativeIconViewData()
data class SmallIcon(val asset: RowAssetViewData) : InformativeIconViewData()
Expand All @@ -56,7 +56,7 @@ interface OnClickListener {
fun onClicked(id: String)
}

sealed class RowAssetViewData {
internal sealed class RowAssetViewData {
data class UrlAsset(val url: String) : RowAssetViewData()
data class DrawableIdAsset(@DrawableRes val id: Int) : RowAssetViewData()
data class DrawableAsset(val drawableRes: Drawable) : RowAssetViewData()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import coil.request.Options
* otherwise the data would be represented using ASCII encoding.
* Link to Spec: https://datatracker.ietf.org/doc/html/rfc2397
*/
class Base64DataUrlFetcher(
internal class Base64DataUrlFetcher(
private val base64Data: String,
private val resources: Resources,
) : Fetcher {
Expand All @@ -43,7 +43,7 @@ class Base64DataUrlFetcher(
null
}

class Factory(
internal class Factory(
private val resources: Resources,
) : Fetcher.Factory<Uri> {
override fun create(data: Uri, options: Options, imageLoader: ImageLoader): Fetcher? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.content.Context
import coil.ImageLoader
import coil.decode.SvgDecoder

object ImageLoaderProvider {
internal object ImageLoaderProvider {

private var imageLoader: ImageLoader? = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import androidx.appcompat.content.res.AppCompatResources
import coil.request.ImageRequest
import com.telefonica.mistica.sheet.children.list.RowAssetViewData

fun ImageView.loadRowAsset(rowAsset: RowAssetViewData) {
internal fun ImageView.loadRowAsset(rowAsset: RowAssetViewData) {
when (rowAsset) {
is RowAssetViewData.DrawableAsset -> this.setImageDrawable(rowAsset.drawableRes)
is RowAssetViewData.DrawableIdAsset -> this.setImageDrawable(AppCompatResources.getDrawable(this.context, rowAsset.id))
is RowAssetViewData.UrlAsset -> this.loadUrl(rowAsset.url)
}
}

fun ImageView.loadUrl(
internal fun ImageView.loadUrl(
url: String,
builder: ImageRequest.Builder.() -> Unit = {},
) {
Expand All @@ -24,5 +24,5 @@ fun ImageView.loadUrl(
.apply(builder)
.build()

ImageLoaderProvider.get(context).enqueue(request)
ImageLoaderProvider.get(context.applicationContext).enqueue(request)
}

0 comments on commit 3712b3d

Please sign in to comment.