-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
com.facebook.react.views.text.frescosupport.FrescoBasedReactTextInlin…
…eImageViewManager.java (#47561) Summary: Pull Request resolved: #47561 Convert Java to Kotlin Changelog: [Android][Breaking] changed visibility of FrescoBasedReactTextInlineImageViewManager to internal Reviewed By: javache Differential Revision: D65606954
- Loading branch information
1 parent
6dd4195
commit c3f602b
Showing
3 changed files
with
58 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
...m/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageViewManager.java
This file was deleted.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
...com/facebook/react/views/text/frescosupport/FrescoBasedReactTextInlineImageViewManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* 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.react.views.text.frescosupport | ||
|
||
import android.view.View | ||
import com.facebook.common.references.CloseableReference | ||
import com.facebook.drawee.backends.pipeline.Fresco | ||
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder | ||
import com.facebook.imagepipeline.image.CloseableImage | ||
import com.facebook.imagepipeline.image.ImageInfo | ||
import com.facebook.imagepipeline.request.ImageRequest | ||
import com.facebook.react.module.annotations.ReactModule | ||
import com.facebook.react.uimanager.BaseViewManager | ||
import com.facebook.react.uimanager.ThemedReactContext | ||
|
||
/** | ||
* Manages Images embedded in Text nodes using Fresco. Since they are used only as a virtual nodes | ||
* any type of native view operation will throw an [IllegalStateException]. | ||
*/ | ||
@ReactModule(name = FrescoBasedReactTextInlineImageViewManager.REACT_CLASS) | ||
internal class FrescoBasedReactTextInlineImageViewManager | ||
@JvmOverloads | ||
constructor( | ||
private val draweeControllerBuilder: AbstractDraweeControllerBuilder<*, *, *, *>? = null, | ||
private val callerContext: Any? = null | ||
) : BaseViewManager<View, FrescoBasedReactTextInlineImageShadowNode>() { | ||
|
||
override fun getName(): String = REACT_CLASS | ||
|
||
public override fun createViewInstance(context: ThemedReactContext): View { | ||
throw IllegalStateException("RCTTextInlineImage doesn't map into a native view") | ||
} | ||
|
||
override fun createShadowNodeInstance(): FrescoBasedReactTextInlineImageShadowNode { | ||
@Suppress("UNCHECKED_CAST") // Unsafe cast necessary as this java class used raw generics | ||
val builder = | ||
draweeControllerBuilder | ||
as? | ||
AbstractDraweeControllerBuilder< | ||
*, ImageRequest, CloseableReference<CloseableImage>, ImageInfo> | ||
?: Fresco.newDraweeControllerBuilder() | ||
return FrescoBasedReactTextInlineImageShadowNode(builder, callerContext) | ||
} | ||
|
||
override fun getShadowNodeClass(): Class<FrescoBasedReactTextInlineImageShadowNode> = | ||
FrescoBasedReactTextInlineImageShadowNode::class.java | ||
|
||
override fun updateExtraData(root: View, extraData: Any) = Unit | ||
|
||
public companion object { | ||
public const val REACT_CLASS: String = "RCTTextInlineImage" | ||
} | ||
} |