Skip to content

Commit

Permalink
Fix image source
Browse files Browse the repository at this point in the history
Differential Revision: D62874354

fbshipit-source-id: 19a1a162771ff96bdc8b7579c8ffcbc8237b7e7d
  • Loading branch information
Artem Kholodnyi authored and facebook-github-bot committed Sep 18, 2024
1 parent f109583 commit d011dae
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object ImageSourceProvider {
if (uri == null) {
emptySource()
} else {
SingleImageSource(
SingleImageSourceImpl(
uri,
buildMap {
if (extras != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,8 @@ package com.facebook.fresco.vito.source
import android.net.Uri

@Suppress("KtDataClass")
data class SingleImageSource(val uri: Uri, override val extras: Map<String, Any>? = null) :
UriImageSource {
interface SingleImageSource : UriImageSource {
val uri: Uri

fun getExtra(key: String): Any? = extras?.get(key)

fun getStringExtra(key: String): String? = getExtra(key) as? String

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
if (javaClass != other?.javaClass) {
return false
}

val otherImageSource: SingleImageSource = other as SingleImageSource

return imageUri == otherImageSource.imageUri && extras == otherImageSource.extras
}

override fun hashCode(): Int {
var result = imageUri.hashCode()
result = 31 * result + (extras?.hashCode() ?: 0)
return result
}

override val imageUri: Uri = uri
fun getStringExtra(key: String): String?
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package com.facebook.fresco.vito.source

import android.net.Uri

@Suppress("KtDataClass")
data class SingleImageSourceImpl(
override val uri: Uri,
override val extras: Map<String, Any>? = null
) : SingleImageSource {

fun getExtra(key: String): Any? = extras?.get(key)

override fun getStringExtra(key: String): String? = getExtra(key) as? String

override fun equals(other: Any?): Boolean {
if (this === other) {
return true
}
if (javaClass != other?.javaClass) {
return false
}

val otherImageSource: SingleImageSourceImpl = other as SingleImageSourceImpl

return imageUri == otherImageSource.imageUri && extras == otherImageSource.extras
}

override fun hashCode(): Int {
var result = imageUri.hashCode()
result = 31 * result + (extras?.hashCode() ?: 0)
return result
}

override val imageUri: Uri = uri
}

0 comments on commit d011dae

Please sign in to comment.