FontRequestEmojiCompatConfig


public class FontRequestEmojiCompatConfig extends EmojiCompat.Config


EmojiCompat.Config implementation that asynchronously fetches the required font and the metadata using a FontRequest. FontRequest should be constructed to fetch an EmojiCompat compatible emoji font.

Summary

Nested types

A retry policy implementation that doubles the amount of time in between retries.

Retry policy used when the font provider is not ready to give the font file.

Public constructors

FontRequestEmojiCompatConfig(
    @NonNull Context context,
    @NonNull FontRequest request
)

Public methods

@NonNull FontRequestEmojiCompatConfig

This method is deprecated.

please call setLoadingExecutor instead

@NonNull FontRequestEmojiCompatConfig

Sets the custom executor to be used for initialization.

@NonNull FontRequestEmojiCompatConfig

Sets the retry policy.

Inherited methods

From androidx.emoji2.text.EmojiCompat.Config
final @NonNull EmojiCompat.MetadataRepoLoader

Returns the MetadataRepoLoader.

@NonNull EmojiCompat.Config

Registers an initialization callback.

@NonNull EmojiCompat.Config
registerInitCallback(
    @NonNull Executor executor,
    @NonNull EmojiCompat.InitCallback initCallback
)

Registers an initialization callback.

@NonNull EmojiCompat.Config

Sets the color used as emoji span indicator.

@NonNull EmojiCompat.Config
setEmojiSpanIndicatorEnabled(boolean emojiSpanIndicatorEnabled)

Determines whether a background will be drawn for the emojis that are found and replaced by EmojiCompat.

@NonNull EmojiCompat.Config

The interface that is used by EmojiCompat in order to check if a given emoji can be rendered by the system.

@NonNull EmojiCompat.Config

Determines the strategy to start loading the metadata.

@NonNull EmojiCompat.Config
setReplaceAll(boolean replaceAll)

Determines whether EmojiCompat should replace all the emojis it finds with the EmojiSpans.

@NonNull EmojiCompat.Config

Set the span factory used to actually draw emoji replacements.

@NonNull EmojiCompat.Config
setUseEmojiAsDefaultStyle(boolean useEmojiAsDefaultStyle)

Determines whether EmojiCompat should use the emoji presentation style for emojis that have text style as default.

@NonNull EmojiCompat.Config
setUseEmojiAsDefaultStyle(
    boolean useEmojiAsDefaultStyle,
    @Nullable List<Integer> emojiAsDefaultStyleExceptions
)
@NonNull EmojiCompat.Config

Unregisters a callback that was added before.

Public constructors

FontRequestEmojiCompatConfig

Added in 1.0.0
public FontRequestEmojiCompatConfig(
    @NonNull Context context,
    @NonNull FontRequest request
)
Parameters
@NonNull Context context

Context instance, cannot be null

@NonNull FontRequest request

FontRequest to fetch the font asynchronously, cannot be null

Public methods

setHandler

Added in 1.0.0
Deprecated in 1.0.0
public @NonNull FontRequestEmojiCompatConfig setHandler(@Nullable Handler handler)

Please us setLoadingExecutor instead to set background loading thread. This was deprecated in emoji2 1.0.0-alpha04. If migrating from androidx.emoji please prefer to use an existing background executor for setLoadingExecutor. Note: This method will no longer have any effect if passed null, which is a breaking change from androidx.emoji.

Parameters
@Nullable Handler handler

background thread handler to wrap in an Executor, if null this method will do nothing

setLoadingExecutor

Added in 1.0.0
public @NonNull FontRequestEmojiCompatConfig setLoadingExecutor(@NonNull Executor executor)

Sets the custom executor to be used for initialization. Since font loading is too slow for the main thread, the metadata loader will fetch the fonts on a background thread. By default, FontRequestEmojiCompatConfig will create its own single threaded Executor, which causes a thread to be created. You can pass your own executor to control which thread the font is loaded on, and avoid an extra thread creation.

Parameters
@NonNull Executor executor

background executor for performing font load

setRetryPolicy

Added in 1.0.0
public @NonNull FontRequestEmojiCompatConfig setRetryPolicy(
    @Nullable FontRequestEmojiCompatConfig.RetryPolicy policy
)

Sets the retry policy. {@see RetryPolicy}

Parameters
@Nullable FontRequestEmojiCompatConfig.RetryPolicy policy

The policy to be used when the font provider is not ready to give the font file. Can be null. In case of null, the metadata loader never retries.