.class Lcom/moji/mjweather/aqi/AqiCameraActivity$1;
.super Lcom/moji/tool/thread/wrapper/MJRunnable;
.source "AqiCameraActivity.java"


# annotations
.annotation system Ldalvik/annotation/EnclosingMethod;
    value = Lcom/moji/mjweather/aqi/AqiCameraActivity;->a(Ljava/lang/String;)V
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x0
    name = null
.end annotation


# instance fields
.field final synthetic a:Ljava/lang/String;

.field final synthetic b:Lcom/moji/mjweather/aqi/AqiCameraActivity;


# direct methods
.method constructor <init>(Lcom/moji/mjweather/aqi/AqiCameraActivity;Lcom/moji/tool/thread/ThreadPriority;Ljava/lang/String;)V
    .locals 0

    .line 126
    iput-object p1, p0, Lcom/moji/mjweather/aqi/AqiCameraActivity$1;->b:Lcom/moji/mjweather/aqi/AqiCameraActivity;

    iput-object p3, p0, Lcom/moji/mjweather/aqi/AqiCameraActivity$1;->a:Ljava/lang/String;

    invoke-direct {p0, p2}, Lcom/moji/tool/thread/wrapper/MJRunnable;-><init>(Lcom/moji/tool/thread/ThreadPriority;)V

    return-void
.end method


# virtual methods
.method public run()V
    .locals 7

    .line 131
    new-instance v0, Landroid/graphics/BitmapFactory$Options;

    invoke-direct {v0}, Landroid/graphics/BitmapFactory$Options;-><init>()V

    const/4 v1, 0x1

    .line 132
    iput-boolean v1, v0, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    .line 133
    iget-object v1, p0, Lcom/moji/mjweather/aqi/AqiCameraActivity$1;->a:Ljava/lang/String;

    invoke-static {v1, v0}, Landroid/graphics/BitmapFactory;->decodeFile(Ljava/lang/String;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    .line 134
    iget v1, v0, Landroid/graphics/BitmapFactory$Options;->outWidth:I

    .line 135
    iget v0, v0, Landroid/graphics/BitmapFactory$Options;->outHeight:I

    const/high16 v2, 0x3f800000    # 1.0f

    int-to-float v3, v0

    const/high16 v4, 0x43f00000    # 480.0f

    cmpl-float v5, v3, v4

    if-gtz v5, :cond_0

    int-to-float v5, v1

    cmpl-float v5, v5, v4

    if-lez v5, :cond_2

    :cond_0
    div-float v2, v3, v4

    int-to-float v5, v1

    div-float/2addr v5, v4

    cmpg-float v4, v2, v5

    if-gez v4, :cond_1

    goto :goto_0

    :cond_1
    move v2, v5

    :cond_2
    :goto_0
    const-string v4, "AqiCameraActivity"

    .line 147
    new-instance v5, Ljava/lang/StringBuilder;

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

    const-string v6, "uploadImg origin: "

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

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

    const-string v6, "  "

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

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

    const-string v0, "  "

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

    iget-object v0, p0, Lcom/moji/mjweather/aqi/AqiCameraActivity$1;->a:Ljava/lang/String;

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

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

    move-result-object v0

    invoke-static {v4, v0}, Lcom/moji/tool/log/MJLogger;->b(Ljava/lang/String;Ljava/lang/String;)V

    int-to-float v0, v1

    div-float/2addr v0, v2

    float-to-int v0, v0

    div-float/2addr v3, v2

    float-to-int v1, v3

    const-string v3, "AqiCameraActivity"

    .line 152
    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "uploadImg target: "

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

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

    const-string v5, "  "

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

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

    const-string v5, "  "

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

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

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

    move-result-object v2

    invoke-static {v3, v2}, Lcom/moji/tool/log/MJLogger;->b(Ljava/lang/String;Ljava/lang/String;)V

    const/4 v2, 0x0

    .line 158
    :try_start_0
    invoke-static {}, Lcom/moji/tool/AppDelegate;->a()Landroid/content/Context;

    move-result-object v3

    invoke-static {v3}, Lcom/squareup/picasso/Picasso;->a(Landroid/content/Context;)Lcom/squareup/picasso/Picasso;

    move-result-object v3

    new-instance v4, Ljava/lang/StringBuilder;

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

    const-string v5, "file://"

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

    iget-object v5, p0, Lcom/moji/mjweather/aqi/AqiCameraActivity$1;->a:Ljava/lang/String;

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

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

    move-result-object v4

    invoke-virtual {v3, v4}, Lcom/squareup/picasso/Picasso;->a(Ljava/lang/String;)Lcom/squareup/picasso/RequestCreator;

    move-result-object v3

    invoke-virtual {v3, v0, v1}, Lcom/squareup/picasso/RequestCreator;->a(II)Lcom/squareup/picasso/RequestCreator;

    move-result-object v3

    sget-object v4, Lcom/squareup/picasso/MemoryPolicy;->NO_CACHE:Lcom/squareup/picasso/MemoryPolicy;

    const/4 v5, 0x0

    new-array v5, v5, [Lcom/squareup/picasso/MemoryPolicy;

    invoke-virtual {v3, v4, v5}, Lcom/squareup/picasso/RequestCreator;->a(Lcom/squareup/picasso/MemoryPolicy;[Lcom/squareup/picasso/MemoryPolicy;)Lcom/squareup/picasso/RequestCreator;

    move-result-object v3

    invoke-virtual {v3}, Lcom/squareup/picasso/RequestCreator;->i()Landroid/graphics/Bitmap;

    move-result-object v3

    const-wide/16 v4, 0x12c

    .line 159
    invoke-static {v3, v4, v5}, Lcom/moji/tool/BitmapTool;->a(Landroid/graphics/Bitmap;J)[B

    move-result-object v3

    .line 160
    new-instance v4, Ljava/io/File;

    invoke-static {}, Lcom/moji/mjweather/aqi/AqiCameraActivity;->a()Ljava/lang/String;

    move-result-object v5

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

    .line 161
    new-instance v5, Ljava/io/FileOutputStream;

    invoke-direct {v5, v4}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_3
    .catchall {:try_start_0 .. :try_end_0} :catchall_1

    .line 162
    :try_start_1
    invoke-virtual {v5, v3}, Ljava/io/FileOutputStream;->write([B)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_2
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    .line 169
    :try_start_2
    invoke-virtual {v5}, Ljava/io/FileOutputStream;->close()V
    :try_end_2
    .catch Ljava/io/IOException; {:try_start_2 .. :try_end_2} :catch_1

    .line 176
    invoke-virtual {v4}, Ljava/io/File;->exists()Z

    move-result v2

    if-nez v2, :cond_3

    return-void

    .line 177
    :cond_3
    new-instance v2, Lcom/moji/http/upload/UploadImage;

    const-string v3, "http://snsup.moji.com/snsupload/upload/json/upload"

    invoke-direct {v2, v4, v3}, Lcom/moji/http/upload/UploadImage;-><init>(Ljava/io/File;Ljava/lang/String;)V

    .line 178
    invoke-virtual {v2}, Lcom/moji/http/upload/UploadImage;->f()Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Ljava/lang/String;

    .line 180
    invoke-static {v2}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v3

    if-nez v3, :cond_4

    .line 182
    :try_start_3
    new-instance v3, Lcom/google/gson/GsonBuilder;

    invoke-direct {v3}, Lcom/google/gson/GsonBuilder;-><init>()V

    invoke-virtual {v3}, Lcom/google/gson/GsonBuilder;->create()Lcom/google/gson/Gson;

    move-result-object v3

    .line 183
    const-class v4, Lcom/moji/http/snsforum/entity/UploadResult;

    invoke-virtual {v3, v2, v4}, Lcom/google/gson/Gson;->fromJson(Ljava/lang/String;Ljava/lang/Class;)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lcom/moji/http/snsforum/entity/UploadResult;

    if-eqz v2, :cond_4

    .line 184
    iget-object v3, v2, Lcom/moji/http/snsforum/entity/UploadResult;->path:Ljava/lang/String;

    invoke-static {v3}, Landroid/text/TextUtils;->isEmpty(Ljava/lang/CharSequence;)Z

    move-result v3

    if-nez v3, :cond_4

    .line 185
    iget-object v3, p0, Lcom/moji/mjweather/aqi/AqiCameraActivity$1;->b:Lcom/moji/mjweather/aqi/AqiCameraActivity;

    iget-object v2, v2, Lcom/moji/http/snsforum/entity/UploadResult;->path:Ljava/lang/String;

    invoke-static {v3, v2, v0, v1}, Lcom/moji/mjweather/aqi/AqiCameraActivity;->a(Lcom/moji/mjweather/aqi/AqiCameraActivity;Ljava/lang/String;II)V
    :try_end_3
    .catch Ljava/lang/Exception; {:try_start_3 .. :try_end_3} :catch_0

    goto :goto_1

    :catch_0
    move-exception v0

    const-string v1, "AqiCameraActivity"

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

    move-result-object v0

    invoke-static {v1, v0}, Lcom/moji/tool/log/MJLogger;->e(Ljava/lang/String;Ljava/lang/String;)V

    :cond_4
    :goto_1
    return-void

    :catch_1
    move-exception v0

    const-string v1, "AqiCameraActivity"

    .line 171
    invoke-virtual {v0}, Ljava/io/IOException;->getMessage()Ljava/lang/String;

    move-result-object v0

    invoke-static {v1, v0}, Lcom/moji/tool/log/MJLogger;->e(Ljava/lang/String;Ljava/lang/String;)V

    return-void

    :catchall_0
    move-exception v0

    move-object v2, v5

    goto :goto_3

    :catch_2
    move-exception v0

    move-object v2, v5

    goto :goto_2

    :catchall_1
    move-exception v0

    goto :goto_3

    :catch_3
    move-exception v0

    :goto_2
    :try_start_4
    const-string v1, "AqiCameraActivity"

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

    move-result-object v0

    invoke-static {v1, v0}, Lcom/moji/tool/log/MJLogger;->e(Ljava/lang/String;Ljava/lang/String;)V
    :try_end_4
    .catchall {:try_start_4 .. :try_end_4} :catchall_1

    if-eqz v2, :cond_5

    .line 169
    :try_start_5
    invoke-virtual {v2}, Ljava/io/FileOutputStream;->close()V

    :cond_5
    return-void

    :goto_3
    if-eqz v2, :cond_6

    invoke-virtual {v2}, Ljava/io/FileOutputStream;->close()V
    :try_end_5
    .catch Ljava/io/IOException; {:try_start_5 .. :try_end_5} :catch_1

    .line 174
    :cond_6
    throw v0
.end method
