DownloadTask.smali

.class public Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;
.super Landroid/os/AsyncTask;


# annotations
.annotation system Ldalvik/annotation/Signature;
    value = {
        "Landroid/os/AsyncTask",
        "<",
        "Lcom/sdk/orion/bean/SpeakerHistory$History;",
        "Ljava/lang/Void;",
        "Ljava/lang/Void;",
        ">;"
    }
.end annotation


# instance fields
.field private mContext:Ljava/lang/ref/WeakReference;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/lang/ref/WeakReference",
            "<",
            "Landroid/content/Context;",
            ">;"
        }
    .end annotation
.end field


# direct methods
.method public constructor <init>(Landroid/content/Context;)V
    .registers 3

    invoke-direct {p0}, Landroid/os/AsyncTask;-><init>()V

    new-instance v0, Ljava/lang/ref/WeakReference;

    invoke-direct {v0, p1}, Ljava/lang/ref/WeakReference;-><init>(Ljava/lang/Object;)V

    iput-object v0, p0, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->mContext:Ljava/lang/ref/WeakReference;

    return-void
.end method


# virtual methods
.method protected bridge synthetic doInBackground([Ljava/lang/Object;)Ljava/lang/Object;
    .registers 3

    check-cast p1, [Lcom/sdk/orion/bean/SpeakerHistory$History;

    invoke-virtual {p0, p1}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->doInBackground([Lcom/sdk/orion/bean/SpeakerHistory$History;)Ljava/lang/Void;

    move-result-object v0

    return-object v0
.end method

.method protected varargs doInBackground([Lcom/sdk/orion/bean/SpeakerHistory$History;)Ljava/lang/Void;
    .registers 13

    const/4 v1, 0x0

    const/4 v2, 0x0

    iget-object v0, p0, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->mContext:Ljava/lang/ref/WeakReference;

    invoke-virtual {v0}, Ljava/lang/ref/WeakReference;->get()Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/content/Context;

    if-nez v0, :cond_d

    :cond_c
    :goto_c
    return-object v2

    :cond_d
    aget-object v5, p1, v1

    new-instance v1, Ljava/lang/StringBuilder;

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

    invoke-static {v0}, Lcom/sdk/orion/ui/baselibrary/config/OrionConstant;->getDecodePath(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v3, v5, Lcom/sdk/orion/bean/SpeakerHistory$History;->historyId:Ljava/lang/String;

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v6

    new-instance v1, Ljava/lang/StringBuilder;

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

    invoke-static {v0}, Lcom/sdk/orion/ui/baselibrary/config/OrionConstant;->getSavePath(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    iget-object v3, v5, Lcom/sdk/orion/bean/SpeakerHistory$History;->historyId:Ljava/lang/String;

    invoke-virtual {v1, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v1

    invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v7

    new-instance v1, Ljava/io/File;

    new-instance v3, Ljava/lang/StringBuilder;

    invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V

    invoke-static {v0}, Lcom/sdk/orion/ui/baselibrary/config/OrionConstant;->getSavePath(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v4

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    iget-object v4, v5, Lcom/sdk/orion/bean/SpeakerHistory$History;->historyId:Ljava/lang/String;

    invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v3

    invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v3

    invoke-direct {v1, v3}, Ljava/io/File;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/io/File;->exists()Z

    move-result v3

    if-eqz v3, :cond_7d

    new-instance v1, Ljava/lang/StringBuilder;

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

    invoke-static {v0}, Lcom/sdk/orion/ui/baselibrary/config/OrionConstant;->getDecodePath(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    iget-object v1, v5, Lcom/sdk/orion/bean/SpeakerHistory$History;->historyId:Ljava/lang/String;

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, v5, v0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onPlayVoice(Lcom/sdk/orion/bean/SpeakerHistory$History;Ljava/lang/String;)V

    invoke-virtual {p0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onSuccess()V

    goto :goto_c

    :cond_7d
    :try_start_7d
    invoke-virtual {v1}, Ljava/io/File;->getParentFile()Ljava/io/File;

    move-result-object v3

    invoke-virtual {v3}, Ljava/io/File;->mkdirs()Z

    move-result v3

    if-eqz v3, :cond_8a

    invoke-virtual {v1}, Ljava/io/File;->createNewFile()Z
    :try_end_8a
    .catch Ljava/lang/Exception; {:try_start_7d .. :try_end_8a} :catch_e1

    :cond_8a
    :goto_8a
    const/4 v3, 0x0

    const/4 v4, 0x0

    :try_start_8c
    new-instance v1, Ljava/net/URL;

    iget-object v8, v5, Lcom/sdk/orion/bean/SpeakerHistory$History;->request:Lcom/sdk/orion/bean/SpeakerHistory$Request;

    iget-object v8, v8, Lcom/sdk/orion/bean/SpeakerHistory$Request;->url:Ljava/lang/String;

    invoke-direct {v1, v8}, Ljava/net/URL;-><init>(Ljava/lang/String;)V

    invoke-virtual {v1}, Ljava/net/URL;->openConnection()Ljava/net/URLConnection;

    move-result-object v1

    check-cast v1, Ljava/net/HttpURLConnection;
    :try_end_9b
    .catch Ljava/lang/Exception; {:try_start_8c .. :try_end_9b} :catch_19f
    .catchall {:try_start_8c .. :try_end_9b} :catchall_17f

    :try_start_9b
    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->connect()V

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v8

    const/16 v9, 0xc8

    if-eq v8, v9, :cond_eb

    new-instance v0, Ljava/lang/StringBuilder;

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

    const-string/jumbo v5, "Server returned HTTP "

    invoke-virtual {v0, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseCode()I

    move-result v5

    invoke-virtual {v0, v5}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v0

    const-string/jumbo v5, " "

    invoke-virtual {v0, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getResponseMessage()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v0, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, v0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onFailed(Ljava/lang/String;)V
    :try_end_d0
    .catch Ljava/lang/Exception; {:try_start_9b .. :try_end_d0} :catch_1a4
    .catchall {:try_start_9b .. :try_end_d0} :catchall_197

    if-eqz v2, :cond_d5

    :try_start_d2
    invoke-virtual {v4}, Ljava/io/OutputStream;->close()V

    :cond_d5
    if-eqz v2, :cond_da

    invoke-virtual {v3}, Ljava/io/InputStream;->close()V
    :try_end_da
    .catch Ljava/io/IOException; {:try_start_d2 .. :try_end_da} :catch_e6

    :cond_da
    :goto_da
    if-eqz v1, :cond_c

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    goto/16 :goto_c

    :catch_e1
    move-exception v1

    invoke-virtual {v1}, Ljava/lang/Exception;->printStackTrace()V

    goto :goto_8a

    :catch_e6
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_da

    :cond_eb
    :try_start_eb
    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->getInputStream()Ljava/io/InputStream;
    :try_end_ee
    .catch Ljava/lang/Exception; {:try_start_eb .. :try_end_ee} :catch_1a4
    .catchall {:try_start_eb .. :try_end_ee} :catchall_197

    move-result-object v4

    :try_start_ef
    new-instance v3, Ljava/io/FileOutputStream;

    invoke-direct {v3, v7}, Ljava/io/FileOutputStream;-><init>(Ljava/lang/String;)V
    :try_end_f4
    .catch Ljava/lang/Exception; {:try_start_ef .. :try_end_f4} :catch_1a9
    .catchall {:try_start_ef .. :try_end_f4} :catchall_19a

    const/16 v8, 0x1000

    :try_start_f6
    new-array v8, v8, [B

    :goto_f8
    invoke-virtual {v4, v8}, Ljava/io/InputStream;->read([B)I

    move-result v9

    const/4 v10, -0x1

    if-eq v9, v10, :cond_13f

    invoke-virtual {p0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->isCancelled()Z

    move-result v10

    if-eqz v10, :cond_11e

    invoke-virtual {v4}, Ljava/io/InputStream;->close()V
    :try_end_108
    .catch Ljava/lang/Exception; {:try_start_f6 .. :try_end_108} :catch_123
    .catchall {:try_start_f6 .. :try_end_108} :catchall_19c

    if-eqz v3, :cond_10d

    :try_start_10a
    invoke-virtual {v3}, Ljava/io/OutputStream;->close()V

    :cond_10d
    if-eqz v4, :cond_112

    invoke-virtual {v4}, Ljava/io/InputStream;->close()V
    :try_end_112
    .catch Ljava/io/IOException; {:try_start_10a .. :try_end_112} :catch_119

    :cond_112
    :goto_112
    if-eqz v1, :cond_c

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    goto/16 :goto_c

    :catch_119
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_112

    :cond_11e
    const/4 v10, 0x0

    :try_start_11f
    invoke-virtual {v3, v8, v10, v9}, Ljava/io/OutputStream;->write([BII)V
    :try_end_122
    .catch Ljava/lang/Exception; {:try_start_11f .. :try_end_122} :catch_123
    .catchall {:try_start_11f .. :try_end_122} :catchall_19c

    goto :goto_f8

    :catch_123
    move-exception v0

    :goto_124
    :try_start_124
    invoke-virtual {v0}, Ljava/lang/Exception;->printStackTrace()V

    invoke-virtual {v0}, Ljava/lang/Exception;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, v0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onFailed(Ljava/lang/String;)V
    :try_end_12e
    .catchall {:try_start_124 .. :try_end_12e} :catchall_19c

    if-eqz v3, :cond_133

    :try_start_130
    invoke-virtual {v3}, Ljava/io/OutputStream;->close()V

    :cond_133
    if-eqz v4, :cond_138

    invoke-virtual {v4}, Ljava/io/InputStream;->close()V
    :try_end_138
    .catch Ljava/io/IOException; {:try_start_130 .. :try_end_138} :catch_17a

    :cond_138
    :goto_138
    if-eqz v1, :cond_c

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    goto/16 :goto_c

    :cond_13f
    :try_start_13f
    new-instance v8, Lcom/orion/speech/utility/b;

    invoke-direct {v8}, Lcom/orion/speech/utility/b;-><init>()V

    invoke-virtual {v8, v7, v6}, Lcom/orion/speech/utility/b;->a(Ljava/lang/String;Ljava/lang/String;)V

    new-instance v6, Ljava/lang/StringBuilder;

    invoke-direct {v6}, Ljava/lang/StringBuilder;-><init>()V

    invoke-static {v0}, Lcom/sdk/orion/ui/baselibrary/config/OrionConstant;->getDecodePath(Landroid/content/Context;)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {v6, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    iget-object v6, v5, Lcom/sdk/orion/bean/SpeakerHistory$History;->historyId:Ljava/lang/String;

    invoke-virtual {v0, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v0

    invoke-virtual {v0}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p0, v5, v0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onPlayVoice(Lcom/sdk/orion/bean/SpeakerHistory$History;Ljava/lang/String;)V

    invoke-virtual {p0}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onSuccess()V
    :try_end_164
    .catch Ljava/lang/Exception; {:try_start_13f .. :try_end_164} :catch_123
    .catchall {:try_start_13f .. :try_end_164} :catchall_19c

    if-eqz v3, :cond_169

    :try_start_166
    invoke-virtual {v3}, Ljava/io/OutputStream;->close()V

    :cond_169
    if-eqz v4, :cond_16e

    invoke-virtual {v4}, Ljava/io/InputStream;->close()V
    :try_end_16e
    .catch Ljava/io/IOException; {:try_start_166 .. :try_end_16e} :catch_175

    :cond_16e
    :goto_16e
    if-eqz v1, :cond_c

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    goto/16 :goto_c

    :catch_175
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_16e

    :catch_17a
    move-exception v0

    invoke-virtual {v0}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_138

    :catchall_17f
    move-exception v0

    move-object v1, v2

    move-object v4, v2

    :goto_182
    if-eqz v2, :cond_187

    :try_start_184
    invoke-virtual {v2}, Ljava/io/OutputStream;->close()V

    :cond_187
    if-eqz v4, :cond_18c

    invoke-virtual {v4}, Ljava/io/InputStream;->close()V
    :try_end_18c
    .catch Ljava/io/IOException; {:try_start_184 .. :try_end_18c} :catch_192

    :cond_18c
    :goto_18c
    if-eqz v1, :cond_191

    invoke-virtual {v1}, Ljava/net/HttpURLConnection;->disconnect()V

    :cond_191
    throw v0

    :catch_192
    move-exception v2

    invoke-virtual {v2}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_18c

    :catchall_197
    move-exception v0

    move-object v4, v2

    goto :goto_182

    :catchall_19a
    move-exception v0

    goto :goto_182

    :catchall_19c
    move-exception v0

    move-object v2, v3

    goto :goto_182

    :catch_19f
    move-exception v0

    move-object v1, v2

    move-object v3, v2

    move-object v4, v2

    goto :goto_124

    :catch_1a4
    move-exception v0

    move-object v3, v2

    move-object v4, v2

    goto/16 :goto_124

    :catch_1a9
    move-exception v0

    move-object v3, v2

    goto/16 :goto_124
.end method

.method public onFailed(Ljava/lang/String;)V
    .registers 2

    return-void
.end method

.method public onPlayVoice(Lcom/sdk/orion/bean/SpeakerHistory$History;Ljava/lang/String;)V
    .registers 3

    return-void
.end method

.method protected bridge synthetic onPostExecute(Ljava/lang/Object;)V
    .registers 2

    check-cast p1, Ljava/lang/Void;

    invoke-virtual {p0, p1}, Lcom/sdk/orion/ui/baselibrary/utils/DownloadTask;->onPostExecute(Ljava/lang/Void;)V

    return-void
.end method

.method protected onPostExecute(Ljava/lang/Void;)V
    .registers 2

    invoke-super {p0, p1}, Landroid/os/AsyncTask;->onPostExecute(Ljava/lang/Object;)V

    return-void
.end method

.method public onSuccess()V
    .registers 1

    return-void
.end method