363 lines
9.2 KiB
Smali
363 lines
9.2 KiB
Smali
.class public final Lcom/discord/utilities/textprocessing/node/SpoilerNode;
|
|
.super Lcom/discord/simpleast/core/node/Node;
|
|
.source "SpoilerNode.kt"
|
|
|
|
# interfaces
|
|
.implements Lcom/discord/utilities/textprocessing/node/Spoilerable;
|
|
|
|
|
|
# annotations
|
|
.annotation system Ldalvik/annotation/MemberClasses;
|
|
value = {
|
|
Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;
|
|
}
|
|
.end annotation
|
|
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"<T::",
|
|
"Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;",
|
|
">",
|
|
"Lcom/discord/simpleast/core/node/Node<",
|
|
"TT;>;",
|
|
"Lcom/discord/utilities/textprocessing/node/Spoilerable;"
|
|
}
|
|
.end annotation
|
|
|
|
|
|
# instance fields
|
|
.field public final content:Ljava/lang/String;
|
|
|
|
.field public id:I
|
|
|
|
.field public isRevealed:Z
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Ljava/lang/String;)V
|
|
.locals 0
|
|
|
|
if-eqz p1, :cond_0
|
|
|
|
invoke-direct {p0}, Lcom/discord/simpleast/core/node/Node;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->content:Ljava/lang/String;
|
|
|
|
const/4 p1, -0x1
|
|
|
|
iput p1, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->id:I
|
|
|
|
return-void
|
|
|
|
:cond_0
|
|
const-string p1, "content"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
const/4 p1, 0x0
|
|
|
|
throw p1
|
|
.end method
|
|
|
|
.method private final createStyles(Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;)Ljava/util/List;
|
|
.locals 12
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(TT;)",
|
|
"Ljava/util/List<",
|
|
"Ljava/lang/Object;",
|
|
">;"
|
|
}
|
|
.end annotation
|
|
|
|
invoke-interface {p1}, Lcom/discord/utilities/textprocessing/node/BasicRenderContext;->getContext()Landroid/content/Context;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-virtual {p0}, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->isRevealed()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
new-instance v0, Landroid/text/style/BackgroundColorSpan;
|
|
|
|
invoke-interface {p1}, Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;->getSpoilerRevealedColorRes()I
|
|
|
|
move-result p1
|
|
|
|
invoke-direct {v0, p1}, Landroid/text/style/BackgroundColorSpan;-><init>(I)V
|
|
|
|
invoke-static {v0}, Lf/n/a/j/a;->listOf(Ljava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_0
|
|
const/4 v1, 0x3
|
|
|
|
new-array v1, v1, [Ljava/lang/Object;
|
|
|
|
const/4 v2, 0x0
|
|
|
|
new-instance v3, Landroid/text/style/BackgroundColorSpan;
|
|
|
|
invoke-interface {p1}, Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;->getSpoilerColorRes()I
|
|
|
|
move-result v4
|
|
|
|
invoke-direct {v3, v4}, Landroid/text/style/BackgroundColorSpan;-><init>(I)V
|
|
|
|
aput-object v3, v1, v2
|
|
|
|
const/4 v2, 0x1
|
|
|
|
new-instance v3, Landroid/text/style/ForegroundColorSpan;
|
|
|
|
const v4, 0x7f060247
|
|
|
|
invoke-static {v0, v4}, Lcom/discord/utilities/color/ColorCompat;->getColor(Landroid/content/Context;I)I
|
|
|
|
move-result v5
|
|
|
|
invoke-direct {v3, v5}, Landroid/text/style/ForegroundColorSpan;-><init>(I)V
|
|
|
|
aput-object v3, v1, v2
|
|
|
|
const/4 v2, 0x2
|
|
|
|
invoke-interface {p1}, Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;->getSpoilerOnClick()Lkotlin/jvm/functions/Function1;
|
|
|
|
move-result-object p1
|
|
|
|
if-eqz p1, :cond_1
|
|
|
|
new-instance v3, Lcom/discord/utilities/spans/ClickableSpan;
|
|
|
|
invoke-static {v0, v4}, Lcom/discord/utilities/color/ColorCompat;->getColor(Landroid/content/Context;I)I
|
|
|
|
move-result v4
|
|
|
|
invoke-static {v4}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;
|
|
|
|
move-result-object v6
|
|
|
|
const/4 v7, 0x0
|
|
|
|
const/4 v8, 0x0
|
|
|
|
new-instance v9, Lcom/discord/utilities/textprocessing/node/SpoilerNode$createStyles$$inlined$let$lambda$1;
|
|
|
|
invoke-direct {v9, p1, p0, v0}, Lcom/discord/utilities/textprocessing/node/SpoilerNode$createStyles$$inlined$let$lambda$1;-><init>(Lkotlin/jvm/functions/Function1;Lcom/discord/utilities/textprocessing/node/SpoilerNode;Landroid/content/Context;)V
|
|
|
|
const/4 v10, 0x4
|
|
|
|
const/4 v11, 0x0
|
|
|
|
move-object v5, v3
|
|
|
|
invoke-direct/range {v5 .. v11}, Lcom/discord/utilities/spans/ClickableSpan;-><init>(Ljava/lang/Integer;ZLkotlin/jvm/functions/Function1;Lkotlin/jvm/functions/Function1;ILkotlin/jvm/internal/DefaultConstructorMarker;)V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
const/4 v3, 0x0
|
|
|
|
:goto_0
|
|
aput-object v3, v1, v2
|
|
|
|
invoke-static {v1}, Lf/n/a/j/a;->listOfNotNull([Ljava/lang/Object;)Ljava/util/List;
|
|
|
|
move-result-object p1
|
|
|
|
:goto_1
|
|
return-object p1
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public final getContent()Ljava/lang/String;
|
|
.locals 1
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->content:Ljava/lang/String;
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public final getId()I
|
|
.locals 1
|
|
|
|
iget v0, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->id:I
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public isRevealed()Z
|
|
.locals 1
|
|
|
|
iget-boolean v0, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->isRevealed:Z
|
|
|
|
return v0
|
|
.end method
|
|
|
|
.method public render(Landroid/text/SpannableStringBuilder;Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;)V
|
|
.locals 5
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroid/text/SpannableStringBuilder;",
|
|
"TT;)V"
|
|
}
|
|
.end annotation
|
|
|
|
const/4 v0, 0x0
|
|
|
|
if-eqz p1, :cond_4
|
|
|
|
if-eqz p2, :cond_3
|
|
|
|
invoke-virtual {p1}, Landroid/text/SpannableStringBuilder;->length()I
|
|
|
|
move-result v0
|
|
|
|
invoke-virtual {p0}, Lcom/discord/simpleast/core/node/Node;->getChildren()Ljava/util/Collection;
|
|
|
|
move-result-object v1
|
|
|
|
if-eqz v1, :cond_0
|
|
|
|
invoke-interface {v1}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object v1
|
|
|
|
:goto_0
|
|
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v2
|
|
|
|
if-eqz v2, :cond_0
|
|
|
|
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v2
|
|
|
|
check-cast v2, Lcom/discord/simpleast/core/node/Node;
|
|
|
|
invoke-virtual {v2, p1, p2}, Lcom/discord/simpleast/core/node/Node;->render(Landroid/text/SpannableStringBuilder;Ljava/lang/Object;)V
|
|
|
|
goto :goto_0
|
|
|
|
:cond_0
|
|
invoke-virtual {p0}, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->isRevealed()Z
|
|
|
|
move-result v1
|
|
|
|
if-nez v1, :cond_1
|
|
|
|
invoke-virtual {p1}, Landroid/text/SpannableStringBuilder;->length()I
|
|
|
|
move-result v1
|
|
|
|
const-class v2, Lcom/discord/utilities/spans/ClickableSpan;
|
|
|
|
invoke-virtual {p1, v0, v1, v2}, Landroid/text/SpannableStringBuilder;->getSpans(IILjava/lang/Class;)[Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
const-string v2, "builder.getSpans(startIn\u2026lickableSpan::class.java)"
|
|
|
|
invoke-static {v1, v2}, Ly/u/b/j;->checkExpressionValueIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
array-length v2, v1
|
|
|
|
const/4 v3, 0x0
|
|
|
|
:goto_1
|
|
if-ge v3, v2, :cond_1
|
|
|
|
aget-object v4, v1, v3
|
|
|
|
check-cast v4, Lcom/discord/utilities/spans/ClickableSpan;
|
|
|
|
invoke-virtual {p1, v4}, Landroid/text/SpannableStringBuilder;->removeSpan(Ljava/lang/Object;)V
|
|
|
|
add-int/lit8 v3, v3, 0x1
|
|
|
|
goto :goto_1
|
|
|
|
:cond_1
|
|
invoke-direct {p0, p2}, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->createStyles(Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;)Ljava/util/List;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-interface {p2}, Ljava/lang/Iterable;->iterator()Ljava/util/Iterator;
|
|
|
|
move-result-object p2
|
|
|
|
:goto_2
|
|
invoke-interface {p2}, Ljava/util/Iterator;->hasNext()Z
|
|
|
|
move-result v1
|
|
|
|
if-eqz v1, :cond_2
|
|
|
|
invoke-interface {p2}, Ljava/util/Iterator;->next()Ljava/lang/Object;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {p1}, Landroid/text/SpannableStringBuilder;->length()I
|
|
|
|
move-result v2
|
|
|
|
const/16 v3, 0x21
|
|
|
|
invoke-virtual {p1, v1, v0, v2, v3}, Landroid/text/SpannableStringBuilder;->setSpan(Ljava/lang/Object;III)V
|
|
|
|
goto :goto_2
|
|
|
|
:cond_2
|
|
return-void
|
|
|
|
:cond_3
|
|
const-string p1, "renderContext"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
|
|
:cond_4
|
|
const-string p1, "builder"
|
|
|
|
invoke-static {p1}, Ly/u/b/j;->a(Ljava/lang/String;)V
|
|
|
|
throw v0
|
|
.end method
|
|
|
|
.method public bridge synthetic render(Landroid/text/SpannableStringBuilder;Ljava/lang/Object;)V
|
|
.locals 0
|
|
|
|
check-cast p2, Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;
|
|
|
|
invoke-virtual {p0, p1, p2}, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->render(Landroid/text/SpannableStringBuilder;Lcom/discord/utilities/textprocessing/node/SpoilerNode$RenderContext;)V
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public setRevealed(Z)V
|
|
.locals 0
|
|
|
|
iput-boolean p1, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->isRevealed:Z
|
|
|
|
return-void
|
|
.end method
|
|
|
|
.method public final updateState(IZ)V
|
|
.locals 0
|
|
|
|
iput p1, p0, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->id:I
|
|
|
|
invoke-virtual {p0, p2}, Lcom/discord/utilities/textprocessing/node/SpoilerNode;->setRevealed(Z)V
|
|
|
|
return-void
|
|
.end method
|