77 lines
3.2 KiB
Java
77 lines
3.2 KiB
Java
|
package com.discord.utilities.textprocessing.node;
|
||
|
|
||
|
import android.content.Context;
|
||
|
import android.text.SpannableStringBuilder;
|
||
|
import androidx.annotation.AttrRes;
|
||
|
import com.discord.simpleast.core.node.Node;
|
||
|
import com.discord.utilities.color.ColorCompat;
|
||
|
import com.discord.utilities.spans.ClickableSpan;
|
||
|
import com.discord.utilities.string.StringUtilsKt;
|
||
|
import com.discord.utilities.textprocessing.node.UrlNode.RenderContext;
|
||
|
import d0.z.d.m;
|
||
|
import kotlin.Unit;
|
||
|
import kotlin.jvm.functions.Function1;
|
||
|
import kotlin.jvm.functions.Function3;
|
||
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
||
|
/* compiled from: UrlNode.kt */
|
||
|
public final class UrlNode<T extends RenderContext> extends Node<T> {
|
||
|
private final String mask;
|
||
|
private final String url;
|
||
|
|
||
|
/* compiled from: UrlNode.kt */
|
||
|
public interface RenderContext extends BasicRenderContext {
|
||
|
@AttrRes
|
||
|
int getLinkColorAttrResId();
|
||
|
|
||
|
Function3<Context, String, String, Unit> getOnClickUrl();
|
||
|
|
||
|
Function1<String, Unit> getOnLongPressUrl();
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
||
|
public UrlNode(String str, String str2) {
|
||
|
super(null, 1, null);
|
||
|
m.checkNotNullParameter(str, "url");
|
||
|
this.url = str;
|
||
|
this.mask = str2;
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: this call moved to the top of the method (can break code semantics) */
|
||
|
public /* synthetic */ UrlNode(String str, String str2, int i, DefaultConstructorMarker defaultConstructorMarker) {
|
||
|
this(str, (i & 2) != 0 ? null : str2);
|
||
|
}
|
||
|
|
||
|
public static final /* synthetic */ String access$getMask$p(UrlNode urlNode) {
|
||
|
return urlNode.mask;
|
||
|
}
|
||
|
|
||
|
public final String getUrl() {
|
||
|
return this.url;
|
||
|
}
|
||
|
|
||
|
public void render(SpannableStringBuilder spannableStringBuilder, T t) {
|
||
|
m.checkNotNullParameter(spannableStringBuilder, "builder");
|
||
|
m.checkNotNullParameter(t, "renderContext");
|
||
|
try {
|
||
|
String punyCodeASCIIUrl = StringUtilsKt.toPunyCodeASCIIUrl(this.url);
|
||
|
Object clickableSpan = new ClickableSpan(Integer.valueOf(ColorCompat.getThemedColor(t.getContext(), t.getLinkColorAttrResId())), false, new UrlNode$render$style$1(t, punyCodeASCIIUrl), new UrlNode$render$style$2(this, t, punyCodeASCIIUrl));
|
||
|
int length = spannableStringBuilder.length();
|
||
|
String str = this.mask;
|
||
|
if (str != null) {
|
||
|
punyCodeASCIIUrl = str;
|
||
|
}
|
||
|
spannableStringBuilder.append((CharSequence) punyCodeASCIIUrl);
|
||
|
spannableStringBuilder.setSpan(clickableSpan, length, spannableStringBuilder.length(), 33);
|
||
|
} catch (Exception unused) {
|
||
|
spannableStringBuilder.append(this.url);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX DEBUG: Multi-variable search result rejected for r0v0, resolved type: com.discord.utilities.textprocessing.node.UrlNode<T extends com.discord.utilities.textprocessing.node.UrlNode$RenderContext> */
|
||
|
/* JADX WARN: Multi-variable type inference failed */
|
||
|
@Override // com.discord.simpleast.core.node.Node
|
||
|
public /* bridge */ /* synthetic */ void render(SpannableStringBuilder spannableStringBuilder, Object obj) {
|
||
|
render(spannableStringBuilder, (SpannableStringBuilder) ((RenderContext) obj));
|
||
|
}
|
||
|
}
|