.class public Lcom/moji/weathersence/sceneegg/SceneEggUpdater;
.super Ljava/lang/Object;
.source "SceneEggUpdater.java"


# static fields
.field private static final a:Ljava/lang/Object;


# direct methods
.method static constructor <clinit>()V
    .locals 1

    .line 29
    new-instance v0, Ljava/lang/Object;

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

    sput-object v0, Lcom/moji/weathersence/sceneegg/SceneEggUpdater;->a:Ljava/lang/Object;

    return-void
.end method

.method public constructor <init>()V
    .locals 0

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

    return-void
.end method

.method static synthetic a(Lcom/moji/weathersence/sceneegg/SceneEggUpdater;Ljava/lang/String;)Ljava/util/List;
    .locals 0

    .line 28
    invoke-direct {p0, p1}, Lcom/moji/weathersence/sceneegg/SceneEggUpdater;->b(Ljava/lang/String;)Ljava/util/List;

    move-result-object p0

    return-object p0
.end method

.method static synthetic a(Lcom/moji/weathersence/sceneegg/SceneEggUpdater;)V
    .locals 0

    .line 28
    invoke-direct {p0}, Lcom/moji/weathersence/sceneegg/SceneEggUpdater;->b()V

    return-void
.end method

.method private b(Ljava/lang/String;)Ljava/util/List;
    .locals 3
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            ")",
            "Ljava/util/List<",
            "Ljava/lang/Long;",
            ">;"
        }
    .end annotation

    .line 72
    invoke-static {p1}, Lcom/moji/weathersence/sceneegg/MatchModel;->readFromJson(Ljava/lang/String;)Lcom/moji/weathersence/sceneegg/MatchModel;

    move-result-object p1

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

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

    if-eqz p1, :cond_0

    .line 74
    iget-object v1, p1, Lcom/moji/weathersence/sceneegg/MatchModel;->egg_list:Ljava/util/List;

    if-eqz v1, :cond_0

    iget-object v1, p1, Lcom/moji/weathersence/sceneegg/MatchModel;->egg_list:Ljava/util/List;

    invoke-interface {v1}, Ljava/util/List;->size()I

    move-result v1

    if-lez v1, :cond_0

    .line 75
    iget-object p1, p1, Lcom/moji/weathersence/sceneegg/MatchModel;->egg_list:Ljava/util/List;

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

    move-result-object p1

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

    move-result v1

    if-eqz v1, :cond_0

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

    move-result-object v1

    check-cast v1, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;

    .line 76
    iget v1, v1, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_id:I

    int-to-long v1, v1

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

    move-result-object v1

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

    goto :goto_0

    :cond_0
    return-object v0
.end method

.method private b()V
    .locals 13

    .line 101
    sget-object v0, Lcom/moji/weathersence/sceneegg/SceneEggUpdater;->a:Ljava/lang/Object;

    monitor-enter v0

    :try_start_0
    const-string v1, "SceneEggUpdater"

    const-string v2, "downloadResource: "

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

    .line 104
    new-instance v1, Lcom/moji/weathersence/data/WeatherScenePreference;

    invoke-direct {v1}, Lcom/moji/weathersence/data/WeatherScenePreference;-><init>()V

    invoke-virtual {v1}, Lcom/moji/weathersence/data/WeatherScenePreference;->e()Ljava/lang/String;

    move-result-object v1

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

    move-result v2

    if-eqz v2, :cond_0

    .line 106
    monitor-exit v0

    return-void

    .line 110
    :cond_0
    new-instance v2, Ljava/lang/StringBuilder;

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

    invoke-static {}, Lcom/moji/weathersence/sceneegg/SceneEggPath;->a()Ljava/lang/String;

    move-result-object v3

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

    invoke-static {v1}, Lcom/moji/tool/MD5Util;->b(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v3

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

    const-string v3, ".json"

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

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

    move-result-object v2

    const-string v3, "SceneEggUpdater"

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

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

    const-string v5, "downloadResource: "

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

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

    const-string v1, "path "

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

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

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

    move-result-object v1

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

    .line 113
    invoke-static {v2}, Lcom/moji/weathersence/sceneegg/MatchModel;->readFromJson(Ljava/lang/String;)Lcom/moji/weathersence/sceneegg/MatchModel;

    move-result-object v1

    .line 114
    invoke-static {}, Lcom/moji/weathersence/sceneegg/SceneDaoImpl;->a()Lcom/moji/weathersence/sceneegg/SceneDaoImpl;

    move-result-object v2

    if-eqz v1, :cond_5

    .line 115
    iget-object v3, v1, Lcom/moji/weathersence/sceneegg/MatchModel;->egg_list:Ljava/util/List;

    if-eqz v3, :cond_5

    iget-object v3, v1, Lcom/moji/weathersence/sceneegg/MatchModel;->egg_list:Ljava/util/List;

    invoke-interface {v3}, Ljava/util/List;->size()I

    move-result v3

    if-lez v3, :cond_5

    .line 116
    iget-object v1, v1, Lcom/moji/weathersence/sceneegg/MatchModel;->egg_list:Ljava/util/List;

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

    move-result-object v1

    :cond_1
    :goto_0
    invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z

    move-result v3

    if-eqz v3, :cond_5

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

    move-result-object v3

    check-cast v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;

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

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

    invoke-static {}, Lcom/moji/tool/FilePathUtil;->o()Ljava/lang/String;

    move-result-object v5

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

    iget-object v5, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_resource:Ljava/lang/String;

    invoke-static {v5}, Lcom/moji/tool/MD5Util;->b(Ljava/lang/String;)Ljava/lang/String;

    move-result-object v5

    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

    .line 118
    iget-wide v5, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->start_time:J

    invoke-static {}, Lcom/moji/weathersence/sceneegg/SceneEggMatch;->a()J

    move-result-wide v7

    const/4 v9, 0x0

    sub-long/2addr v5, v7

    const-wide/32 v7, 0x5265c00

    const/4 v9, 0x0

    const/4 v10, 0x1

    cmp-long v11, v5, v7

    if-gez v11, :cond_2

    const/4 v5, 0x1

    goto :goto_1

    :cond_2
    const/4 v5, 0x0

    .line 119
    :goto_1
    iget-wide v6, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->end_time:J

    invoke-static {}, Lcom/moji/weathersence/sceneegg/SceneEggMatch;->a()J

    move-result-wide v11

    cmp-long v8, v6, v11

    if-lez v8, :cond_3

    const/4 v9, 0x1

    :cond_3
    const-string v6, "SceneEggUpdater"

    .line 120
    new-instance v7, Ljava/lang/StringBuilder;

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

    const-string v8, "code "

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

    iget-object v8, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_resource:Ljava/lang/String;

    invoke-virtual {v8}, Ljava/lang/String;->hashCode()I

    move-result v8

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

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

    move-result-object v7

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

    .line 123
    invoke-direct {p0, v4}, Lcom/moji/weathersence/sceneegg/SceneEggUpdater;->c(Ljava/lang/String;)Z

    move-result v6

    const-string v7, "SceneEggUpdater"

    .line 125
    new-instance v8, Ljava/lang/StringBuilder;

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

    const-string v10, "isdownload "

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

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

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

    move-result-object v8

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

    const-string v7, "SceneEggUpdater"

    .line 126
    new-instance v8, Ljava/lang/StringBuilder;

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

    const-string v10, "folder  "

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

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

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

    move-result-object v8

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

    if-eqz v5, :cond_1

    if-eqz v9, :cond_1

    if-nez v6, :cond_4

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

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

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

    sget-object v6, Ljava/io/File;->separator:Ljava/lang/String;

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

    const-string v6, "egg.zip"

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

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

    move-result-object v5
    :try_end_0
    .catchall {:try_start_0 .. :try_end_0} :catchall_0

    .line 133
    :try_start_1
    invoke-static {}, Lcom/moji/download/MJDownLoadManager;->a()Lcom/moji/download/MJDownLoadManager;

    move-result-object v6

    new-instance v7, Lcom/moji/download/MJDownloadRequest;

    iget-object v8, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_resource:Ljava/lang/String;

    invoke-direct {v7, v8, v5}, Lcom/moji/download/MJDownloadRequest;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    invoke-virtual {v6, v7}, Lcom/moji/download/MJDownLoadManager;->b(Lcom/moji/download/MJDownloadRequest;)Z

    move-result v6

    if-eqz v6, :cond_1

    .line 135
    new-instance v6, Ljava/lang/StringBuilder;

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

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

    sget-object v7, Ljava/io/File;->separator:Ljava/lang/String;

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

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

    move-result-object v6

    invoke-static {v5, v6}, Lcom/moji/tool/FileTool;->d(Ljava/lang/String;Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 137
    iget-object v3, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_resource:Ljava/lang/String;

    invoke-virtual {v3}, Ljava/lang/String;->hashCode()I

    move-result v3

    int-to-long v5, v3

    new-instance v3, Ljava/lang/StringBuilder;

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

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

    sget-object v7, Ljava/io/File;->separator:Ljava/lang/String;

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

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

    move-result-object v3

    invoke-interface {v2, v5, v6, v3}, Lcom/moji/weathersence/sceneegg/SceneEggDao;->a(JLjava/lang/String;)J
    :try_end_1
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
    .catchall {:try_start_1 .. :try_end_1} :catchall_0

    goto/16 :goto_0

    :catch_0
    move-exception v3

    :try_start_2
    const-string v5, "SceneEggUpdater"

    .line 141
    invoke-static {v5, v3}, Lcom/moji/tool/log/MJLogger;->a(Ljava/lang/String;Ljava/lang/Throwable;)V

    .line 142
    invoke-static {v4}, Lcom/moji/tool/FileTool;->e(Ljava/lang/String;)Z

    goto/16 :goto_0

    .line 146
    :cond_4
    iget-object v5, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_resource:Ljava/lang/String;

    invoke-virtual {v5}, Ljava/lang/String;->hashCode()I

    move-result v5

    int-to-long v5, v5

    invoke-interface {v2, v5, v6}, Lcom/moji/weathersence/sceneegg/SceneEggDao;->a(J)Ljava/lang/String;

    move-result-object v5

    .line 147
    invoke-virtual {v4, v5}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v5

    if-nez v5, :cond_1

    .line 148
    iget-object v3, v3, Lcom/moji/weathersence/sceneegg/MatchModel$EggList;->eggs_resource:Ljava/lang/String;

    invoke-virtual {v3}, Ljava/lang/String;->hashCode()I

    move-result v3

    int-to-long v5, v3

    invoke-interface {v2, v5, v6, v4}, Lcom/moji/weathersence/sceneegg/SceneEggDao;->a(JLjava/lang/String;)J

    goto/16 :goto_0

    .line 156
    :cond_5
    monitor-exit v0

    return-void

    :catchall_0
    move-exception v1

    monitor-exit v0
    :try_end_2
    .catchall {:try_start_2 .. :try_end_2} :catchall_0

    throw v1
.end method

.method private c(Ljava/lang/String;)Z
    .locals 0

    .line 160
    invoke-static {p1}, Lcom/moji/weathersence/sceneegg/SceneEggMatch;->b(Ljava/lang/String;)Z

    move-result p1

    return p1
.end method


# virtual methods
.method public a()V
    .locals 3

    .line 84
    invoke-static {}, Lcom/moji/tool/DeviceTool;->W()Z

    move-result v0

    if-eqz v0, :cond_0

    return-void

    .line 87
    :cond_0
    invoke-static {}, Lcom/moji/tool/thread/MJThreadManager;->a()Lcom/moji/tool/thread/MJThreadManager;

    move-result-object v0

    new-instance v1, Lcom/moji/weathersence/sceneegg/SceneEggUpdater$2;

    sget-object v2, Lcom/moji/tool/thread/ThreadPriority;->NORMAL:Lcom/moji/tool/thread/ThreadPriority;

    invoke-direct {v1, p0, v2}, Lcom/moji/weathersence/sceneegg/SceneEggUpdater$2;-><init>(Lcom/moji/weathersence/sceneegg/SceneEggUpdater;Lcom/moji/tool/thread/ThreadPriority;)V

    sget-object v2, Lcom/moji/tool/thread/ThreadType;->IO_THREAD:Lcom/moji/tool/thread/ThreadType;

    invoke-virtual {v0, v1, v2}, Lcom/moji/tool/thread/MJThreadManager;->a(Lcom/moji/tool/thread/wrapper/MJRunnable;Lcom/moji/tool/thread/ThreadType;)V

    return-void
.end method

.method public a(Ljava/lang/String;)V
    .locals 3

    .line 34
    invoke-static {}, Lcom/moji/tool/DeviceTool;->W()Z

    move-result v0

    if-eqz v0, :cond_0

    return-void

    :cond_0
    const-string v0, "SceneEggUpdater"

    const-string v1, "update"

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

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

    move-result v0

    if-eqz v0, :cond_1

    return-void

    :cond_1
    const-string v0, "SceneEggUpdater"

    .line 41
    new-instance v1, Ljava/lang/StringBuilder;

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

    const-string v2, "update url "

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

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

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

    move-result-object v1

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

    .line 42
    invoke-static {}, Lcom/moji/tool/thread/MJThreadManager;->a()Lcom/moji/tool/thread/MJThreadManager;

    move-result-object v0

    new-instance v1, Lcom/moji/weathersence/sceneegg/SceneEggUpdater$1;

    sget-object v2, Lcom/moji/tool/thread/ThreadPriority;->NORMAL:Lcom/moji/tool/thread/ThreadPriority;

    invoke-direct {v1, p0, v2, p1}, Lcom/moji/weathersence/sceneegg/SceneEggUpdater$1;-><init>(Lcom/moji/weathersence/sceneegg/SceneEggUpdater;Lcom/moji/tool/thread/ThreadPriority;Ljava/lang/String;)V

    sget-object p1, Lcom/moji/tool/thread/ThreadType;->IO_THREAD:Lcom/moji/tool/thread/ThreadType;

    invoke-virtual {v0, v1, p1}, Lcom/moji/tool/thread/MJThreadManager;->a(Lcom/moji/tool/thread/wrapper/MJRunnable;Lcom/moji/tool/thread/ThreadType;)V

    return-void
.end method
