apkfuckery/com.discord/smali/com/miguelgaeta/spanner/Spanner.smali
2019-02-04 21:05:16 +01:00

769 lines
23 KiB
Smali

.class public Lcom/miguelgaeta/spanner/Spanner;
.super Ljava/lang/Object;
.source "Spanner.java"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/miguelgaeta/spanner/Spanner$Replacement;,
Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;,
Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
}
.end annotation
# instance fields
.field private final matchStrategies:Ljava/util/List;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/List",
"<",
"Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;",
">;"
}
.end annotation
.end field
.field private final replacements:Ljava/util/List;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/List",
"<",
"Lcom/miguelgaeta/spanner/Spanner$Replacement;",
">;"
}
.end annotation
.end field
.field private sourceString:Ljava/lang/String;
# direct methods
.method public constructor <init>(Landroid/content/Context;I)V
.locals 1
.param p1, "context" # Landroid/content/Context;
.param p2, "stringResId" # I
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const-string v0, ""
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->matchStrategies:Ljava/util/List;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
invoke-virtual {p1, p2}, Landroid/content/Context;->getString(I)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
return-void
.end method
.method public varargs constructor <init>(Landroid/content/Context;I[Ljava/lang/Object;)V
.locals 1
.param p1, "context" # Landroid/content/Context;
.param p2, "stringResId" # I
.param p3, "args" # [Ljava/lang/Object;
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const-string v0, ""
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->matchStrategies:Ljava/util/List;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
invoke-virtual {p1, p2}, Landroid/content/Context;->getString(I)Ljava/lang/String;
move-result-object v0
invoke-static {v0, p3}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
return-void
.end method
.method public constructor <init>(Ljava/lang/String;)V
.locals 1
.param p1, "sourceString" # Ljava/lang/String;
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const-string v0, ""
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->matchStrategies:Ljava/util/List;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
iput-object p1, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
return-void
.end method
.method public varargs constructor <init>(Ljava/lang/String;[Ljava/lang/Object;)V
.locals 1
.param p1, "sourceString" # Ljava/lang/String;
.param p2, "args" # [Ljava/lang/Object;
.prologue
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
const-string v0, ""
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->matchStrategies:Ljava/util/List;
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
invoke-static {p1, p2}, Ljava/lang/String;->format(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
move-result-object v0
iput-object v0, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
return-void
.end method
.method private static buildSpannableString(Ljava/lang/String;Ljava/util/Collection;)Landroid/text/SpannableString;
.locals 9
.param p0, "sourceString" # Ljava/lang/String;
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/lang/String;",
"Ljava/util/Collection",
"<",
"Lcom/miguelgaeta/spanner/Spanner$Replacement;",
">;)",
"Landroid/text/SpannableString;"
}
.end annotation
.prologue
.local p1, "replacements":Ljava/util/Collection;, "Ljava/util/Collection<Lcom/miguelgaeta/spanner/Spanner$Replacement;>;"
new-instance v3, Landroid/text/SpannableString;
invoke-direct {v3, p0}, Landroid/text/SpannableString;-><init>(Ljava/lang/CharSequence;)V
.local v3, "spannableString":Landroid/text/SpannableString;
:try_start_0
invoke-interface {p1}, Ljava/util/Collection;->iterator()Ljava/util/Iterator;
move-result-object v4
:cond_0
invoke-interface {v4}, Ljava/util/Iterator;->hasNext()Z
move-result v5
if-eqz v5, :cond_1
invoke-interface {v4}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v2
check-cast v2, Lcom/miguelgaeta/spanner/Spanner$Replacement;
.local v2, "replacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
iget-object v5, v2, Lcom/miguelgaeta/spanner/Spanner$Replacement;->replacementSpans:Ljava/util/List;
invoke-interface {v5}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v5
:goto_0
invoke-interface {v5}, Ljava/util/Iterator;->hasNext()Z
move-result v6
if-eqz v6, :cond_0
invoke-interface {v5}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v0
check-cast v0, Landroid/text/style/CharacterStyle;
.local v0, "characterStyle":Landroid/text/style/CharacterStyle;
iget v6, v2, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
iget v7, v2, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
const/16 v8, 0x21
invoke-virtual {v3, v0, v6, v7, v8}, Landroid/text/SpannableString;->setSpan(Ljava/lang/Object;III)V
:try_end_0
.catch Ljava/lang/IndexOutOfBoundsException; {:try_start_0 .. :try_end_0} :catch_0
goto :goto_0
.end local v0 # "characterStyle":Landroid/text/style/CharacterStyle;
.end local v2 # "replacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
:catch_0
move-exception v1
.local v1, "e":Ljava/lang/IndexOutOfBoundsException;
const-string v4, "Spanner"
const-string v5, "Span cannot be applied, index out of bounds."
invoke-static {v4, v5, v1}, Landroid/util/Log;->i(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Throwable;)I
.end local v1 # "e":Ljava/lang/IndexOutOfBoundsException;
:cond_1
return-object v3
.end method
.method private computeStartIndexWithSpans(IIILcom/miguelgaeta/spanner/Spanner$Replacement;)I
.locals 6
.param p1, "startIndex" # I
.param p2, "startIndexOffset" # I
.param p3, "endIndex" # I
.param p4, "replacement" # Lcom/miguelgaeta/spanner/Spanner$Replacement;
.prologue
new-instance v3, Ljava/lang/StringBuilder;
iget-object v4, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
invoke-direct {v3, v4}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V
iget-object v4, p4, Lcom/miguelgaeta/spanner/Spanner$Replacement;->replacementString:Ljava/lang/String;
invoke-virtual {v3, p1, p3, v4}, Ljava/lang/StringBuilder;->replace(IILjava/lang/String;)Ljava/lang/StringBuilder;
move-result-object v3
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
iput-object v3, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
iget-object v3, p4, Lcom/miguelgaeta/spanner/Spanner$Replacement;->replacementString:Ljava/lang/String;
invoke-virtual {v3}, Ljava/lang/String;->length()I
move-result v3
add-int v0, p1, v3
.local v0, "endIndexUpdated":I
sub-int v3, p3, p1
sub-int v4, v0, p1
sub-int v2, v3, v4
.local v2, "offset":I
if-eqz v2, :cond_2
iget-object v3, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
invoke-interface {v3}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v3
:cond_0
:goto_0
invoke-interface {v3}, Ljava/util/Iterator;->hasNext()Z
move-result v4
if-eqz v4, :cond_2
invoke-interface {v3}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v1
check-cast v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;
.local v1, "existingReplacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
if-le v4, p1, :cond_1
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
sub-int/2addr v4, p2
iput v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
if-le v4, v0, :cond_1
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
sub-int v5, v2, p2
sub-int/2addr v4, v5
iput v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
:cond_1
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
if-le v4, p1, :cond_0
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
sub-int/2addr v4, p2
iput v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
if-le v4, v0, :cond_0
iget v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
sub-int v5, v2, p2
sub-int/2addr v4, v5
iput v4, v1, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
goto :goto_0
.end local v1 # "existingReplacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
:cond_2
iput p1, p4, Lcom/miguelgaeta/spanner/Spanner$Replacement;->start:I
iput v0, p4, Lcom/miguelgaeta/spanner/Spanner$Replacement;->end:I
iget-object v3, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
invoke-interface {v3, p4}, Ljava/util/List;->add(Ljava/lang/Object;)Z
return v0
.end method
# virtual methods
.method public addMarkdownBoldStrategy()Lcom/miguelgaeta/spanner/Spanner;
.locals 3
.prologue
new-instance v0, Lcom/miguelgaeta/spanner/Spanner$5;
invoke-direct {v0, p0}, Lcom/miguelgaeta/spanner/Spanner$5;-><init>(Lcom/miguelgaeta/spanner/Spanner;)V
const-string v1, "***"
const-string v2, "***"
invoke-virtual {p0, v0, v1, v2}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
new-instance v0, Lcom/miguelgaeta/spanner/Spanner$6;
invoke-direct {v0, p0}, Lcom/miguelgaeta/spanner/Spanner$6;-><init>(Lcom/miguelgaeta/spanner/Spanner;)V
const-string v1, "**"
const-string v2, "**"
invoke-virtual {p0, v0, v1, v2}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
return-object p0
.end method
.method public addMarkdownStrategy()Lcom/miguelgaeta/spanner/Spanner;
.locals 6
.prologue
const/4 v4, 0x1
invoke-virtual {p0}, Lcom/miguelgaeta/spanner/Spanner;->addMarkdownBoldStrategy()Lcom/miguelgaeta/spanner/Spanner;
new-instance v0, Lcom/miguelgaeta/spanner/Spanner$1;
invoke-direct {v0, p0}, Lcom/miguelgaeta/spanner/Spanner$1;-><init>(Lcom/miguelgaeta/spanner/Spanner;)V
const-string v1, "*"
const-string v2, "*"
invoke-virtual {p0, v0, v1, v2}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
new-instance v0, Lcom/miguelgaeta/spanner/Spanner$2;
invoke-direct {v0, p0}, Lcom/miguelgaeta/spanner/Spanner$2;-><init>(Lcom/miguelgaeta/spanner/Spanner;)V
const-string v1, "~~"
const-string v2, "~~"
invoke-virtual {p0, v0, v1, v2}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
new-instance v0, Lcom/miguelgaeta/spanner/Spanner$3;
invoke-direct {v0, p0}, Lcom/miguelgaeta/spanner/Spanner$3;-><init>(Lcom/miguelgaeta/spanner/Spanner;)V
const-string v1, "__"
const-string v2, "__"
invoke-virtual {p0, v0, v1, v2}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
new-instance v1, Lcom/miguelgaeta/spanner/Spanner$4;
invoke-direct {v1, p0}, Lcom/miguelgaeta/spanner/Spanner$4;-><init>(Lcom/miguelgaeta/spanner/Spanner;)V
const-string v2, "_"
const-string v3, "_"
move-object v0, p0
move v5, v4
invoke-virtual/range {v0 .. v5}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;ZZ)Lcom/miguelgaeta/spanner/Spanner;
return-object p0
.end method
.method public addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
.locals 1
.param p1, "onMatchListener" # Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
.param p2, "start" # Ljava/lang/String;
.prologue
const/4 v0, 0x0
invoke-virtual {p0, p1, p2, v0}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
move-result-object v0
return-object v0
.end method
.method public addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner;
.locals 1
.param p1, "onMatchListener" # Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
.param p2, "start" # Ljava/lang/String;
.param p3, "end" # Ljava/lang/String;
.prologue
const/4 v0, 0x1
invoke-virtual {p0, p1, p2, p3, v0}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;Z)Lcom/miguelgaeta/spanner/Spanner;
move-result-object v0
return-object v0
.end method
.method public addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;Z)Lcom/miguelgaeta/spanner/Spanner;
.locals 6
.param p1, "onMatchListener" # Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
.param p2, "start" # Ljava/lang/String;
.param p3, "end" # Ljava/lang/String;
.param p4, "endRequired" # Z
.prologue
const/4 v5, 0x0
move-object v0, p0
move-object v1, p1
move-object v2, p2
move-object v3, p3
move v4, p4
invoke-virtual/range {v0 .. v5}, Lcom/miguelgaeta/spanner/Spanner;->addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;ZZ)Lcom/miguelgaeta/spanner/Spanner;
move-result-object v0
return-object v0
.end method
.method public addReplacementStrategy(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;ZZ)Lcom/miguelgaeta/spanner/Spanner;
.locals 8
.param p1, "onMatchListener" # Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
.param p2, "start" # Ljava/lang/String;
.param p3, "end" # Ljava/lang/String;
.param p4, "endRequired" # Z
.param p5, "endWithWhitespaceOrEOL" # Z
.prologue
iget-object v7, p0, Lcom/miguelgaeta/spanner/Spanner;->matchStrategies:Ljava/util/List;
new-instance v0, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;
const/4 v6, 0x0
move-object v1, p1
move-object v2, p2
move-object v3, p3
move v4, p4
move v5, p5
invoke-direct/range {v0 .. v6}, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;-><init>(Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;Ljava/lang/String;Ljava/lang/String;ZZLcom/miguelgaeta/spanner/Spanner$1;)V
invoke-interface {v7, v0}, Ljava/util/List;->add(Ljava/lang/Object;)Z
return-object p0
.end method
.method public toSpannableString()Landroid/text/SpannableString;
.locals 12
.prologue
const/4 v11, -0x1
iget-object v7, p0, Lcom/miguelgaeta/spanner/Spanner;->matchStrategies:Ljava/util/List;
invoke-interface {v7}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v7
:goto_0
invoke-interface {v7}, Ljava/util/Iterator;->hasNext()Z
move-result v8
if-eqz v8, :cond_8
invoke-interface {v7}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v3
check-cast v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;
.local v3, "matchStrategy":Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;
const/4 v5, 0x0
.local v5, "startIndex":I
:cond_0
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
iget-object v9, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->start:Ljava/lang/String;
invoke-virtual {v8, v9, v5}, Ljava/lang/String;->indexOf(Ljava/lang/String;I)I
move-result v5
if-eq v5, v11, :cond_1
iget-object v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->start:Ljava/lang/String;
invoke-virtual {v8}, Ljava/lang/String;->length()I
move-result v6
.local v6, "startIndexOffset":I
iget-object v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->end:Ljava/lang/String;
if-nez v8, :cond_2
add-int v0, v5, v6
.local v0, "endIndex":I
iget-object v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->onMatchListener:Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
iget-object v9, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->start:Ljava/lang/String;
invoke-interface {v8, v9}, Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;->call(Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner$Replacement;
move-result-object v4
.local v4, "replacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
invoke-direct {p0, v5, v6, v0, v4}, Lcom/miguelgaeta/spanner/Spanner;->computeStartIndexWithSpans(IIILcom/miguelgaeta/spanner/Spanner$Replacement;)I
move-result v5
.end local v0 # "endIndex":I
.end local v4 # "replacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
.end local v6 # "startIndexOffset":I
:cond_1
:goto_1
if-ne v5, v11, :cond_0
goto :goto_0
.restart local v6 # "startIndexOffset":I
:cond_2
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
iget-object v9, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->end:Ljava/lang/String;
add-int v10, v5, v6
invoke-virtual {v8, v9, v10}, Ljava/lang/String;->indexOf(Ljava/lang/String;I)I
move-result v0
.restart local v0 # "endIndex":I
if-ne v0, v11, :cond_6
iget-boolean v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->endRequired:Z
if-nez v8, :cond_6
const/4 v1, 0x1
.local v1, "isEOLMatch":Z
:goto_2
if-eqz v1, :cond_3
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
invoke-virtual {v8}, Ljava/lang/String;->length()I
move-result v0
:cond_3
iget-boolean v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->endWithWhitespaceOrEOL:Z
if-eqz v8, :cond_4
if-eq v0, v11, :cond_4
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
invoke-virtual {v8}, Ljava/lang/String;->length()I
move-result v8
add-int/lit8 v8, v8, -0x1
if-eq v0, v8, :cond_4
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
add-int/lit8 v9, v0, 0x1
invoke-virtual {v8, v9}, Ljava/lang/String;->charAt(I)C
move-result v8
invoke-static {v8}, Ljava/lang/Character;->isWhitespace(C)Z
move-result v8
if-nez v8, :cond_4
const/4 v0, -0x1
:cond_4
if-eq v0, v11, :cond_7
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
add-int v9, v5, v6
invoke-virtual {v8, v9, v0}, Ljava/lang/String;->substring(II)Ljava/lang/String;
move-result-object v2
.local v2, "match":Ljava/lang/String;
iget-object v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->onMatchListener:Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;
invoke-interface {v8, v2}, Lcom/miguelgaeta/spanner/Spanner$OnMatchListener;->call(Ljava/lang/String;)Lcom/miguelgaeta/spanner/Spanner$Replacement;
move-result-object v4
.restart local v4 # "replacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
if-nez v1, :cond_5
iget-object v8, v3, Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;->end:Ljava/lang/String;
invoke-virtual {v8}, Ljava/lang/String;->length()I
move-result v8
add-int/2addr v0, v8
:cond_5
invoke-direct {p0, v5, v6, v0, v4}, Lcom/miguelgaeta/spanner/Spanner;->computeStartIndexWithSpans(IIILcom/miguelgaeta/spanner/Spanner$Replacement;)I
move-result v5
goto :goto_1
.end local v1 # "isEOLMatch":Z
.end local v2 # "match":Ljava/lang/String;
.end local v4 # "replacement":Lcom/miguelgaeta/spanner/Spanner$Replacement;
:cond_6
const/4 v1, 0x0
goto :goto_2
.restart local v1 # "isEOLMatch":Z
:cond_7
const/4 v5, -0x1
goto :goto_1
.end local v0 # "endIndex":I
.end local v1 # "isEOLMatch":Z
.end local v3 # "matchStrategy":Lcom/miguelgaeta/spanner/Spanner$MatchStrategy;
.end local v5 # "startIndex":I
.end local v6 # "startIndexOffset":I
:cond_8
iget-object v7, p0, Lcom/miguelgaeta/spanner/Spanner;->sourceString:Ljava/lang/String;
iget-object v8, p0, Lcom/miguelgaeta/spanner/Spanner;->replacements:Ljava/util/List;
invoke-static {v7, v8}, Lcom/miguelgaeta/spanner/Spanner;->buildSpannableString(Ljava/lang/String;Ljava/util/Collection;)Landroid/text/SpannableString;
move-result-object v7
return-object v7
.end method