Rabbit-R1/android (non root)/java/sources/androidx/compose/foundation/text/StringHelpers_androidKt.java
2024-05-21 17:08:36 -04:00

58 lines
2.5 KiB
Java

package androidx.compose.foundation.text;
import androidx.emoji2.text.EmojiCompat;
import java.text.BreakIterator;
import kotlin.Metadata;
import kotlin.jvm.internal.Intrinsics;
/* compiled from: StringHelpers.android.kt */
@Metadata(d1 = {"\u0000\u0014\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\b\n\u0002\u0010\u000e\n\u0002\b\u0003\u001a\n\u0010\u0000\u001a\u0004\u0018\u00010\u0001H\u0002\u001a\u0014\u0010\u0002\u001a\u00020\u0003*\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0003H\u0000\u001a\u0014\u0010\u0006\u001a\u00020\u0003*\u00020\u00042\u0006\u0010\u0005\u001a\u00020\u0003H\u0000¨\u0006\u0007"}, d2 = {"getEmojiCompatIfLoaded", "Landroidx/emoji2/text/EmojiCompat;", "findFollowingBreak", "", "", "index", "findPrecedingBreak", "foundation_release"}, k = 2, mv = {1, 8, 0}, xi = 48)
/* loaded from: classes.dex */
public final class StringHelpers_androidKt {
public static final int findPrecedingBreak(String str, int i) {
Intrinsics.checkNotNullParameter(str, "<this>");
EmojiCompat emojiCompatIfLoaded = getEmojiCompatIfLoaded();
Integer num = null;
if (emojiCompatIfLoaded != null) {
Integer valueOf = Integer.valueOf(emojiCompatIfLoaded.getEmojiStart(str, Math.max(0, i - 1)));
if (valueOf.intValue() != -1) {
num = valueOf;
}
}
if (num != null) {
return num.intValue();
}
BreakIterator characterInstance = BreakIterator.getCharacterInstance();
characterInstance.setText(str);
return characterInstance.preceding(i);
}
public static final int findFollowingBreak(String str, int i) {
Intrinsics.checkNotNullParameter(str, "<this>");
EmojiCompat emojiCompatIfLoaded = getEmojiCompatIfLoaded();
Integer num = null;
if (emojiCompatIfLoaded != null) {
Integer valueOf = Integer.valueOf(emojiCompatIfLoaded.getEmojiEnd(str, i));
if (valueOf.intValue() != -1) {
num = valueOf;
}
}
if (num != null) {
return num.intValue();
}
BreakIterator characterInstance = BreakIterator.getCharacterInstance();
characterInstance.setText(str);
return characterInstance.following(i);
}
private static final EmojiCompat getEmojiCompatIfLoaded() {
if (!EmojiCompat.isConfigured()) {
return null;
}
EmojiCompat emojiCompat = EmojiCompat.get();
if (emojiCompat.getLoadState() == 1) {
return emojiCompat;
}
return null;
}
}