AuthFailHandler.smali

.class public Lcom/sandboxol/center/web/http/AuthFailHandler;
.super Ljava/lang/Object;
.source "AuthFailHandler.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;,
        Lcom/sandboxol/center/web/http/AuthFailHandler$AuthFailHandlerWrap;
    }
.end annotation


# static fields
.field private static final FAIL_TIME_OUT:I = 0x13

.field private static final FAIL_TOPPED:I = 0x14


# instance fields
.field private events:Ljava/util/List;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/List<",
            "Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;",
            ">;"
        }
    .end annotation
.end field

.field private isExcuting:Z


# direct methods
.method public constructor <init>()V
    .registers 2

    .line 1
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    const/4 v0, 0x0

    .line 2
    iput-boolean v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->isExcuting:Z

    .line 3
    new-instance v0, Ljava/util/ArrayList;

    invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V

    iput-object v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->events:Ljava/util/List;

    return-void
.end method

.method static synthetic access$100(Lcom/sandboxol/center/web/http/AuthFailHandler;Lcom/sandboxol/common/entity/AuthTokenResponse;Z)V
    .registers 3

    .line 1
    invoke-direct {p0, p1, p2}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onAuthSuccess(Lcom/sandboxol/common/entity/AuthTokenResponse;Z)V

    return-void
.end method

.method static synthetic access$200(Lcom/sandboxol/center/web/http/AuthFailHandler;)V
    .registers 1

    .line 1
    invoke-direct {p0}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onAuthError()V

    return-void
.end method

.method public static getInstance()Lcom/sandboxol/center/web/http/AuthFailHandler;
    .registers 1

    .line 1
    # getter for: Lcom/sandboxol/center/web/http/AuthFailHandler$AuthFailHandlerWrap;->authFailHandler:Lcom/sandboxol/center/web/http/AuthFailHandler;
    invoke-static {}, Lcom/sandboxol/center/web/http/AuthFailHandler$AuthFailHandlerWrap;->access$000()Lcom/sandboxol/center/web/http/AuthFailHandler;

    move-result-object v0

    return-object v0
.end method

.method private onAuthError()V
    .registers 4

    .line 1
    sget-object v0, Lcom/sandboxol/messager/MessageMediator;->INSTANCE:Lcom/sandboxol/messager/MessageMediator;

    const-string v1, "token.repeat.login"

    invoke-virtual {v0, v1}, Lcom/sandboxol/messager/MessageMediator;->sendMsg0(Ljava/lang/String;)V

    .line 2
    invoke-static {}, Lcom/sandboxol/center/entity/AccountCenter;->newInstance()Lcom/sandboxol/center/entity/AccountCenter;

    move-result-object v0

    iget-object v0, v0, Lcom/sandboxol/center/entity/AccountCenter;->login:Landroidx/databinding/ObservableField;

    const/4 v1, 0x0

    invoke-static {v1}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v2

    invoke-virtual {v0, v2}, Landroidx/databinding/ObservableField;->set(Ljava/lang/Object;)V

    .line 3
    iget-object v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->events:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    .line 4
    iput-boolean v1, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->isExcuting:Z

    return-void
.end method

.method private onAuthSuccess(Lcom/sandboxol/common/entity/AuthTokenResponse;Z)V
    .registers 5

    const-string v0, "hostflow"

    const-string v1, "AuthFailedHandler fetch authToken success"

    .line 1
    invoke-static {v0, v1}, Landroid/util/Log;->d(Ljava/lang/String;Ljava/lang/String;)I

    if-nez p2, :cond_1a

    .line 2
    invoke-static {}, Lcom/sandboxol/center/AccountManager;->getInstance()Lcom/sandboxol/center/AccountManager;

    move-result-object p2

    invoke-static {}, Lcom/sandboxol/common/base/app/BaseApplication;->getContext()Landroid/content/Context;

    move-result-object v0

    new-instance v1, Lcom/sandboxol/center/web/http/a;

    invoke-direct {v1, p0}, Lcom/sandboxol/center/web/http/a;-><init>(Lcom/sandboxol/center/web/http/AuthFailHandler;)V

    invoke-virtual {p2, v0, p1, v1}, Lcom/sandboxol/center/AccountManager;->onAuthTokenWithDomainFetched(Landroid/content/Context;Lcom/sandboxol/common/entity/AuthTokenResponse;Lrx/functions/Action0;)V

    goto :goto_20

    .line 3
    :cond_1a
    invoke-direct {p0}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onRetry()V

    const/4 p1, 0x0

    .line 4
    iput-boolean p1, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->isExcuting:Z

    :goto_20
    return-void
.end method

.method private onRelogin(Lretrofit2/HttpException;Lcom/sandboxol/common/base/web/OnResponseListener;)V
    .registers 5

    .line 1
    sget-object v0, Lcom/sandboxol/messager/MessageMediator;->INSTANCE:Lcom/sandboxol/messager/MessageMediator;

    const-string v1, "token.repeat.login"

    invoke-virtual {v0, v1}, Lcom/sandboxol/messager/MessageMediator;->sendMsg0(Ljava/lang/String;)V

    if-eqz p2, :cond_10

    .line 2
    invoke-virtual {p1}, Lretrofit2/HttpException;->code()I

    move-result p1

    invoke-virtual {p2, p1}, Lcom/sandboxol/common/base/web/OnResponseListener;->onServerError(I)V

    :cond_10
    return-void
.end method

.method private onRetry()V
    .registers 4

    .line 1
    iget-object v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->events:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;

    move-result-object v0

    :goto_6
    invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z

    move-result v1

    if-eqz v1, :cond_1d

    invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;

    move-result-object v1

    check-cast v1, Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;

    .line 2
    iget-object v2, v1, Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;->listener:Lcom/sandboxol/common/base/web/OnResponseListener;

    invoke-virtual {v2}, Lcom/sandboxol/common/base/web/OnResponseListener;->retry()V

    .line 3
    iget-object v1, v1, Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;->replyCommand:Lcom/sandboxol/common/command/ReplyCommand;

    invoke-virtual {v1}, Lcom/sandboxol/common/command/ReplyCommand;->execute()V

    goto :goto_6

    .line 4
    :cond_1d
    iget-object v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->events:Ljava/util/List;

    invoke-interface {v0}, Ljava/util/List;->clear()V

    return-void
.end method

.method private onRetryAuth(Lcom/sandboxol/common/command/ReplyCommand;Lcom/sandboxol/common/base/web/OnResponseListener;)V
    .registers 5

    if-eqz p1, :cond_e

    if-eqz p2, :cond_e

    .line 1
    iget-object v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->events:Ljava/util/List;

    new-instance v1, Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;

    invoke-direct {v1, p0, p1, p2}, Lcom/sandboxol/center/web/http/AuthFailHandler$RetryEvent;-><init>(Lcom/sandboxol/center/web/http/AuthFailHandler;Lcom/sandboxol/common/command/ReplyCommand;Lcom/sandboxol/common/base/web/OnResponseListener;)V

    invoke-interface {v0, v1}, Ljava/util/List;->add(Ljava/lang/Object;)Z

    .line 2
    :cond_e
    iget-boolean p1, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->isExcuting:Z

    if-eqz p1, :cond_13

    return-void

    :cond_13
    const/4 p1, 0x1

    .line 3
    iput-boolean p1, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->isExcuting:Z

    .line 4
    invoke-static {}, Lcom/sandboxol/center/router/moduleApplication/BaseModuleApp;->isGarenaChannel()Z

    move-result p1

    if-eqz p1, :cond_29

    .line 5
    invoke-static {}, Lcom/sandboxol/common/base/app/BaseApplication;->getContext()Landroid/content/Context;

    move-result-object p1

    new-instance p2, Lcom/sandboxol/center/web/http/AuthFailHandler$1;

    invoke-direct {p2, p0}, Lcom/sandboxol/center/web/http/AuthFailHandler$1;-><init>(Lcom/sandboxol/center/web/http/AuthFailHandler;)V

    invoke-static {p1, p2}, Lcom/sandboxol/center/web/UserApi;->authTokenV2(Landroid/content/Context;Lcom/sandboxol/common/base/web/OnResponseListener;)V

    goto :goto_35

    .line 6
    :cond_29
    invoke-static {}, Lcom/sandboxol/common/base/app/BaseApplication;->getContext()Landroid/content/Context;

    move-result-object p1

    new-instance p2, Lcom/sandboxol/center/web/http/AuthFailHandler$2;

    invoke-direct {p2, p0}, Lcom/sandboxol/center/web/http/AuthFailHandler$2;-><init>(Lcom/sandboxol/center/web/http/AuthFailHandler;)V

    invoke-static {p1, p2}, Lcom/sandboxol/center/web/LoginTempApi;->authToken(Landroid/content/Context;Lcom/sandboxol/common/base/web/OnResponseListener;)V

    :goto_35
    return-void
.end method


# virtual methods
.method public synthetic a()V
    .registers 2

    .line 1
    invoke-direct {p0}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onRetry()V

    const/4 v0, 0x0

    .line 2
    iput-boolean v0, p0, Lcom/sandboxol/center/web/http/AuthFailHandler;->isExcuting:Z

    return-void
.end method

.method public addExceptionEvent(Lretrofit2/HttpException;Lcom/sandboxol/common/command/ReplyCommand;Lcom/sandboxol/common/base/web/OnResponseListener;)V
    .registers 6

    .line 1
    :try_start_0
    invoke-virtual {p1}, Lretrofit2/HttpException;->response()Lretrofit2/Response;

    move-result-object v0

    invoke-virtual {v0}, Lretrofit2/Response;->code()I

    move-result v0

    const/16 v1, 0x13

    if-ne v0, v1, :cond_10

    .line 2
    invoke-direct {p0, p2, p3}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onRetryAuth(Lcom/sandboxol/common/command/ReplyCommand;Lcom/sandboxol/common/base/web/OnResponseListener;)V

    goto :goto_23

    :cond_10
    const/16 p2, 0x14

    if-ne v0, p2, :cond_18

    .line 3
    invoke-direct {p0, p1, p3}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onRelogin(Lretrofit2/HttpException;Lcom/sandboxol/common/base/web/OnResponseListener;)V

    goto :goto_23

    .line 4
    :cond_18
    invoke-direct {p0, p1, p3}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onRelogin(Lretrofit2/HttpException;Lcom/sandboxol/common/base/web/OnResponseListener;)V
    :try_end_1b
    .catch Ljava/lang/NullPointerException; {:try_start_0 .. :try_end_1b} :catch_1c

    goto :goto_23

    :catch_1c
    move-exception p2

    .line 5
    invoke-virtual {p2}, Ljava/lang/NullPointerException;->printStackTrace()V

    .line 6
    invoke-direct {p0, p1, p3}, Lcom/sandboxol/center/web/http/AuthFailHandler;->onRelogin(Lretrofit2/HttpException;Lcom/sandboxol/common/base/web/OnResponseListener;)V

    :goto_23
    return-void
.end method