RequestFuture.smali

.class public Lcom/mopub/volley/toolbox/RequestFuture;
.super Ljava/lang/Object;
.source "SourceFile"

# interfaces
.implements Lcom/mopub/volley/Response$ErrorListener;
.implements Lcom/mopub/volley/Response$Listener;
.implements Ljava/util/concurrent/Future;


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "<T:",
        "Ljava/lang/Object;",
        ">",
        "Ljava/lang/Object;",
        "Lcom/mopub/volley/Response$ErrorListener;",
        "Lcom/mopub/volley/Response$Listener<",
        "TT;>;",
        "Ljava/util/concurrent/Future<",
        "TT;>;"
    }
.end annotation


# instance fields
.field private mException:Lcom/mopub/volley/VolleyError;

.field private mRequest:Lcom/mopub/volley/Request;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Lcom/mopub/volley/Request<",
            "*>;"
        }
    .end annotation
.end field

.field private mResult:Ljava/lang/Object;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "TT;"
        }
    .end annotation
.end field

.field private mResultReceived:Z


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

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

    const/4 v0, 0x0

    .line 57
    iput-boolean v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResultReceived:Z

    return-void
.end method

.method private declared-synchronized doGet(Ljava/lang/Long;)Ljava/lang/Object;
    .registers 7
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/Long;",
            ")TT;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/InterruptedException;,
            Ljava/util/concurrent/ExecutionException;,
            Ljava/util/concurrent/TimeoutException;
        }
    .end annotation

    monitor-enter p0

    .line 102
    :try_start_1
    iget-object v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mException:Lcom/mopub/volley/VolleyError;

    if-nez v0, :cond_3e

    .line 106
    iget-boolean v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResultReceived:Z

    if-eqz v0, :cond_d

    .line 107
    iget-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResult:Ljava/lang/Object;
    :try_end_b
    .catchall {:try_start_1 .. :try_end_b} :catchall_46

    monitor-exit p0

    return-object p1

    :cond_d
    const-wide/16 v0, 0x0

    if-nez p1, :cond_15

    .line 111
    :try_start_11
    invoke-virtual {p0, v0, v1}, Ljava/lang/Object;->wait(J)V

    goto :goto_24

    .line 112
    :cond_15
    invoke-virtual {p1}, Ljava/lang/Long;->longValue()J

    move-result-wide v2

    cmp-long v4, v2, v0

    if-lez v4, :cond_24

    .line 113
    invoke-virtual {p1}, Ljava/lang/Long;->longValue()J

    move-result-wide v0

    invoke-virtual {p0, v0, v1}, Ljava/lang/Object;->wait(J)V

    .line 116
    :cond_24
    :goto_24
    iget-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mException:Lcom/mopub/volley/VolleyError;

    if-nez p1, :cond_36

    .line 120
    iget-boolean p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResultReceived:Z

    if-eqz p1, :cond_30

    .line 124
    iget-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResult:Ljava/lang/Object;
    :try_end_2e
    .catchall {:try_start_11 .. :try_end_2e} :catchall_46

    monitor-exit p0

    return-object p1

    .line 121
    :cond_30
    :try_start_30
    new-instance p1, Ljava/util/concurrent/TimeoutException;

    invoke-direct {p1}, Ljava/util/concurrent/TimeoutException;-><init>()V

    throw p1

    .line 117
    :cond_36
    new-instance p1, Ljava/util/concurrent/ExecutionException;

    iget-object v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mException:Lcom/mopub/volley/VolleyError;

    invoke-direct {p1, v0}, Ljava/util/concurrent/ExecutionException;-><init>(Ljava/lang/Throwable;)V

    throw p1

    .line 103
    :cond_3e
    new-instance p1, Ljava/util/concurrent/ExecutionException;

    iget-object v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mException:Lcom/mopub/volley/VolleyError;

    invoke-direct {p1, v0}, Ljava/util/concurrent/ExecutionException;-><init>(Ljava/lang/Throwable;)V

    throw p1
    :try_end_46
    .catchall {:try_start_30 .. :try_end_46} :catchall_46

    :catchall_46
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public static newFuture()Lcom/mopub/volley/toolbox/RequestFuture;
    .registers 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "<E:",
            "Ljava/lang/Object;",
            ">()",
            "Lcom/mopub/volley/toolbox/RequestFuture<",
            "TE;>;"
        }
    .end annotation

    .line 62
    new-instance v0, Lcom/mopub/volley/toolbox/RequestFuture;

    invoke-direct {v0}, Lcom/mopub/volley/toolbox/RequestFuture;-><init>()V

    return-object v0
.end method


# virtual methods
.method public declared-synchronized cancel(Z)Z
    .registers 3

    monitor-enter p0

    .line 73
    :try_start_1
    iget-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mRequest:Lcom/mopub/volley/Request;
    :try_end_3
    .catchall {:try_start_1 .. :try_end_3} :catchall_18

    const/4 v0, 0x0

    if-nez p1, :cond_8

    .line 74
    monitor-exit p0

    return v0

    .line 77
    :cond_8
    :try_start_8
    invoke-virtual {p0}, Lcom/mopub/volley/toolbox/RequestFuture;->isDone()Z

    move-result p1

    if-nez p1, :cond_16

    .line 78
    iget-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mRequest:Lcom/mopub/volley/Request;

    invoke-virtual {p1}, Lcom/mopub/volley/Request;->cancel()V
    :try_end_13
    .catchall {:try_start_8 .. :try_end_13} :catchall_18

    const/4 p1, 0x1

    .line 79
    monitor-exit p0

    return p1

    .line 81
    :cond_16
    monitor-exit p0

    return v0

    :catchall_18
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public get()Ljava/lang/Object;
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()TT;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/InterruptedException;,
            Ljava/util/concurrent/ExecutionException;
        }
    .end annotation

    const/4 v0, 0x0

    .line 88
    :try_start_1
    invoke-direct {p0, v0}, Lcom/mopub/volley/toolbox/RequestFuture;->doGet(Ljava/lang/Long;)Ljava/lang/Object;

    move-result-object v0
    :try_end_5
    .catch Ljava/util/concurrent/TimeoutException; {:try_start_1 .. :try_end_5} :catch_6

    return-object v0

    :catch_6
    move-exception v0

    .line 90
    new-instance v1, Ljava/lang/AssertionError;

    invoke-direct {v1, v0}, Ljava/lang/AssertionError;-><init>(Ljava/lang/Object;)V

    throw v1
.end method

.method public get(JLjava/util/concurrent/TimeUnit;)Ljava/lang/Object;
    .registers 5
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(J",
            "Ljava/util/concurrent/TimeUnit;",
            ")TT;"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/InterruptedException;,
            Ljava/util/concurrent/ExecutionException;,
            Ljava/util/concurrent/TimeoutException;
        }
    .end annotation

    .line 97
    sget-object v0, Ljava/util/concurrent/TimeUnit;->MILLISECONDS:Ljava/util/concurrent/TimeUnit;

    invoke-virtual {v0, p1, p2, p3}, Ljava/util/concurrent/TimeUnit;->convert(JLjava/util/concurrent/TimeUnit;)J

    move-result-wide p1

    invoke-static {p1, p2}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object p1

    invoke-direct {p0, p1}, Lcom/mopub/volley/toolbox/RequestFuture;->doGet(Ljava/lang/Long;)Ljava/lang/Object;

    move-result-object p1

    return-object p1
.end method

.method public isCancelled()Z
    .registers 2

    .line 129
    iget-object v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mRequest:Lcom/mopub/volley/Request;

    if-nez v0, :cond_6

    const/4 v0, 0x0

    return v0

    .line 132
    :cond_6
    invoke-virtual {v0}, Lcom/mopub/volley/Request;->isCanceled()Z

    move-result v0

    return v0
.end method

.method public declared-synchronized isDone()Z
    .registers 2

    monitor-enter p0

    .line 137
    :try_start_1
    iget-boolean v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResultReceived:Z

    if-nez v0, :cond_13

    iget-object v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mException:Lcom/mopub/volley/VolleyError;

    if-nez v0, :cond_13

    invoke-virtual {p0}, Lcom/mopub/volley/toolbox/RequestFuture;->isCancelled()Z

    move-result v0
    :try_end_d
    .catchall {:try_start_1 .. :try_end_d} :catchall_15

    if-eqz v0, :cond_10

    goto :goto_13

    :cond_10
    const/4 v0, 0x0

    :goto_11
    monitor-exit p0

    return v0

    :cond_13
    :goto_13
    const/4 v0, 0x1

    goto :goto_11

    :catchall_15
    move-exception v0

    monitor-exit p0

    goto :goto_19

    :goto_18
    throw v0

    :goto_19
    goto :goto_18
.end method

.method public declared-synchronized onErrorResponse(Lcom/mopub/volley/VolleyError;)V
    .registers 2

    monitor-enter p0

    .line 149
    :try_start_1
    iput-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mException:Lcom/mopub/volley/VolleyError;

    .line 150
    invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V
    :try_end_6
    .catchall {:try_start_1 .. :try_end_6} :catchall_8

    .line 151
    monitor-exit p0

    return-void

    :catchall_8
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public declared-synchronized onResponse(Ljava/lang/Object;)V
    .registers 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(TT;)V"
        }
    .end annotation

    monitor-enter p0

    const/4 v0, 0x1

    .line 142
    :try_start_2
    iput-boolean v0, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResultReceived:Z

    .line 143
    iput-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mResult:Ljava/lang/Object;

    .line 144
    invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V
    :try_end_9
    .catchall {:try_start_2 .. :try_end_9} :catchall_b

    .line 145
    monitor-exit p0

    return-void

    :catchall_b
    move-exception p1

    monitor-exit p0

    throw p1
.end method

.method public setRequest(Lcom/mopub/volley/Request;)V
    .registers 2
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Lcom/mopub/volley/Request<",
            "*>;)V"
        }
    .end annotation

    .line 68
    iput-object p1, p0, Lcom/mopub/volley/toolbox/RequestFuture;->mRequest:Lcom/mopub/volley/Request;

    return-void
.end method