.class public Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;
.super Landroid/service/quicksettings/TileService;
.source "MJQSWeatherTileService.java"


# annotations
.annotation build Landroid/annotation/TargetApi;
    value = 0x18
.end annotation


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

    .line 24
    invoke-direct {p0}, Landroid/service/quicksettings/TileService;-><init>()V

    return-void
.end method

.method private a(Landroid/service/quicksettings/Tile;)V
    .locals 10

    if-nez p1, :cond_0

    return-void

    :cond_0
    const-string v0, "MJQSWeatherTileService"

    const-string v1, "updateTile: "

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

    .line 47
    invoke-static {}, Lcom/moji/weatherprovider/provider/WeatherProvider;->b()Lcom/moji/weatherprovider/provider/WeatherProvider;

    move-result-object v0

    invoke-static {}, Lcom/moji/areamanagement/MJAreaManager;->a()Lcom/moji/common/area/AreaInfo;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/moji/weatherprovider/provider/WeatherProvider;->a(Lcom/moji/common/area/AreaInfo;)Lcom/moji/weatherprovider/data/Weather;

    move-result-object v0

    const v1, 0x7f0e00b7

    const/4 v2, 0x1

    if-eqz v0, :cond_6

    .line 48
    iget-object v3, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    if-eqz v3, :cond_6

    iget-object v3, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    iget-object v3, v3, Lcom/moji/weatherprovider/data/Detail;->mCondition:Lcom/moji/weatherprovider/data/Condition;

    if-eqz v3, :cond_6

    .line 49
    new-instance v3, Lcom/moji/base/WeatherDrawable;

    iget-object v4, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    iget-object v4, v4, Lcom/moji/weatherprovider/data/Detail;->mCondition:Lcom/moji/weatherprovider/data/Condition;

    iget v4, v4, Lcom/moji/weatherprovider/data/Condition;->mIcon:I

    invoke-direct {v3, v4}, Lcom/moji/base/WeatherDrawable;-><init>(I)V

    .line 50
    iget-object v4, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    invoke-virtual {v4}, Lcom/moji/weatherprovider/data/Detail;->isDay()Z

    move-result v4

    invoke-virtual {v3, v4}, Lcom/moji/base/WeatherDrawable;->a(Z)I

    move-result v3

    invoke-static {p0, v3}, Landroid/graphics/drawable/Icon;->createWithResource(Landroid/content/Context;I)Landroid/graphics/drawable/Icon;

    move-result-object v3

    invoke-virtual {p1, v3}, Landroid/service/quicksettings/Tile;->setIcon(Landroid/graphics/drawable/Icon;)V

    .line 52
    iget-object v3, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    const/16 v4, -0x64

    if-eqz v3, :cond_1

    iget-object v3, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    iget-object v3, v3, Lcom/moji/weatherprovider/data/Detail;->mCondition:Lcom/moji/weatherprovider/data/Condition;

    if-eqz v3, :cond_1

    .line 53
    iget-object v3, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    iget-object v3, v3, Lcom/moji/weatherprovider/data/Detail;->mCondition:Lcom/moji/weatherprovider/data/Condition;

    iget v3, v3, Lcom/moji/weatherprovider/data/Condition;->mTemperature:I

    goto :goto_0

    :cond_1
    const/16 v3, -0x64

    :goto_0
    if-ne v3, v4, :cond_2

    const-string v3, ""

    goto :goto_1

    :cond_2
    int-to-double v3, v3

    .line 59
    invoke-static {v3, v4, v2}, Lcom/moji/preferences/units/UNIT_TEMP;->getValueStringByCurrentUnitTemp(DZ)Ljava/lang/String;

    move-result-object v3

    .line 63
    :goto_1
    iget-object v4, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    iget-object v4, v4, Lcom/moji/weatherprovider/data/Detail;->mCondition:Lcom/moji/weatherprovider/data/Condition;

    iget-object v4, v4, Lcom/moji/weatherprovider/data/Condition;->mCondition:Ljava/lang/String;

    .line 65
    invoke-virtual {v3}, Ljava/lang/String;->length()I

    move-result v5

    const/16 v6, 0x8

    rsub-int/lit8 v5, v5, 0x8

    const-string v7, " "

    invoke-virtual {v7}, Ljava/lang/String;->length()I

    move-result v7

    sub-int/2addr v5, v7

    .line 66
    invoke-virtual {v4}, Ljava/lang/String;->length()I

    move-result v7

    const/4 v8, 0x0

    if-le v7, v5, :cond_3

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

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

    const-string v9, "\u2026"

    invoke-virtual {v9}, Ljava/lang/String;->length()I

    move-result v9

    sub-int/2addr v5, v9

    add-int/2addr v5, v2

    invoke-virtual {v4, v8, v5}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v2

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

    const-string v2, "\u2026"

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

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

    move-result-object v4

    .line 70
    :cond_3
    invoke-virtual {v4}, Ljava/lang/String;->length()I

    move-result v2

    const-string v5, "\u2026"

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

    move-result v5

    if-ne v2, v5, :cond_4

    goto :goto_2

    .line 73
    :cond_4
    new-instance v2, Ljava/lang/StringBuilder;

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

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

    const-string v4, " "

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

    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 v3

    .line 75
    :goto_2
    iget-object v0, v0, Lcom/moji/weatherprovider/data/Weather;->mDetail:Lcom/moji/weatherprovider/data/Detail;

    iget-object v0, v0, Lcom/moji/weatherprovider/data/Detail;->mCityName:Ljava/lang/String;

    .line 76
    invoke-virtual {v0}, Ljava/lang/String;->length()I

    move-result v2

    if-le v2, v6, :cond_5

    .line 77
    new-instance v2, Ljava/lang/StringBuilder;

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

    const-string v4, "\u2026"

    invoke-virtual {v4}, Ljava/lang/String;->length()I

    move-result v4

    sub-int/2addr v6, v4

    invoke-virtual {v0, v8, v6}, Ljava/lang/String;->substring(II)Ljava/lang/String;

    move-result-object v0

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

    const-string v0, "\u2026"

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

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

    move-result-object v0

    .line 79
    :cond_5
    new-instance v2, Ljava/lang/StringBuilder;

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

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

    const-string v3, "\n"

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

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

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

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/service/quicksettings/Tile;->setLabel(Ljava/lang/CharSequence;)V

    const/4 v0, 0x2

    .line 80
    invoke-virtual {p1, v0}, Landroid/service/quicksettings/Tile;->setState(I)V

    .line 81
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/service/quicksettings/Tile;->setContentDescription(Ljava/lang/CharSequence;)V

    .line 83
    :try_start_0
    invoke-virtual {p1}, Landroid/service/quicksettings/Tile;->updateTile()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_3

    :catch_0
    move-exception p1

    const-string v0, "MJQSWeatherTileService"

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

    goto :goto_3

    :cond_6
    const v0, 0x7f0e0933

    .line 88
    invoke-virtual {p0, v0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getString(I)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/service/quicksettings/Tile;->setLabel(Ljava/lang/CharSequence;)V

    .line 89
    invoke-virtual {p1, v2}, Landroid/service/quicksettings/Tile;->setState(I)V

    const v0, 0x7f08056f

    .line 90
    invoke-static {p0, v0}, Landroid/graphics/drawable/Icon;->createWithResource(Landroid/content/Context;I)Landroid/graphics/drawable/Icon;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/service/quicksettings/Tile;->setIcon(Landroid/graphics/drawable/Icon;)V

    .line 91
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getResources()Landroid/content/res/Resources;

    move-result-object v0

    invoke-virtual {v0, v1}, Landroid/content/res/Resources;->getString(I)Ljava/lang/String;

    move-result-object v0

    invoke-virtual {p1, v0}, Landroid/service/quicksettings/Tile;->setContentDescription(Ljava/lang/CharSequence;)V

    .line 93
    :try_start_1
    invoke-virtual {p1}, Landroid/service/quicksettings/Tile;->updateTile()V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_1

    goto :goto_3

    :catch_1
    move-exception p1

    const-string v0, "MJQSWeatherTileService"

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

    :goto_3
    return-void
.end method


# virtual methods
.method public onClick()V
    .locals 5

    .line 141
    invoke-super {p0}, Landroid/service/quicksettings/TileService;->onClick()V

    const-string v0, "MJQSWeatherTileService"

    const-string v1, "onClick:  "

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

    const/4 v0, 0x0

    .line 145
    :try_start_0
    new-instance v1, Landroid/content/Intent;

    invoke-direct {v1}, Landroid/content/Intent;-><init>()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    .line 146
    :try_start_1
    new-instance v0, Landroid/content/ComponentName;

    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getPackageName()Ljava/lang/String;

    move-result-object v2

    const-string v3, "com.moji.mjweather.MainActivity"

    invoke-direct {v0, v2, v3}, Landroid/content/ComponentName;-><init>(Ljava/lang/String;Ljava/lang/String;)V

    .line 147
    invoke-virtual {v1, v0}, Landroid/content/Intent;->setComponent(Landroid/content/ComponentName;)Landroid/content/Intent;

    const-string v0, "android.intent.category.LAUNCHER"

    .line 148
    invoke-virtual {v1, v0}, Landroid/content/Intent;->addCategory(Ljava/lang/String;)Landroid/content/Intent;

    const/high16 v0, 0x10200000

    .line 149
    invoke-virtual {v1, v0}, Landroid/content/Intent;->setFlags(I)Landroid/content/Intent;

    const-string v0, "where"

    const-string v2, "icon"

    .line 150
    invoke-virtual {v1, v0, v2}, Landroid/content/Intent;->putExtra(Ljava/lang/String;Ljava/lang/String;)Landroid/content/Intent;

    .line 151
    invoke-virtual {p0, v1}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->startActivityAndCollapse(Landroid/content/Intent;)V
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    goto :goto_1

    :catch_0
    move-exception v0

    goto :goto_0

    :catch_1
    move-exception v1

    move-object v4, v1

    move-object v1, v0

    move-object v0, v4

    :goto_0
    const-string v2, "MJQSWeatherTileService"

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

    if-eqz v1, :cond_0

    .line 155
    :try_start_2
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getPackageManager()Landroid/content/pm/PackageManager;

    move-result-object v0

    invoke-virtual {v1, v0}, Landroid/content/Intent;->resolveActivity(Landroid/content/pm/PackageManager;)Landroid/content/ComponentName;

    move-result-object v0

    if-eqz v0, :cond_0

    .line 156
    invoke-virtual {p0, v1}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->startActivity(Landroid/content/Intent;)V
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_2

    goto :goto_1

    :catch_2
    move-exception v0

    const-string v1, "MJQSWeatherTileService"

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

    :cond_0
    :goto_1
    return-void
.end method

.method public onStartListening()V
    .locals 2

    .line 125
    invoke-super {p0}, Landroid/service/quicksettings/TileService;->onStartListening()V

    const-string v0, "MJQSWeatherTileService"

    const-string v1, "onStartListening: "

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

    .line 127
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getQsTile()Landroid/service/quicksettings/Tile;

    move-result-object v0

    .line 128
    invoke-direct {p0, v0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->a(Landroid/service/quicksettings/Tile;)V

    return-void
.end method

.method public onStopListening()V
    .locals 2

    .line 133
    invoke-super {p0}, Landroid/service/quicksettings/TileService;->onStopListening()V

    const-string v0, "MJQSWeatherTileService"

    const-string v1, "onStopListening: "

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

    .line 135
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getQsTile()Landroid/service/quicksettings/Tile;

    move-result-object v0

    .line 136
    invoke-direct {p0, v0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->a(Landroid/service/quicksettings/Tile;)V

    return-void
.end method

.method public onTileAdded()V
    .locals 3

    .line 33
    invoke-super {p0}, Landroid/service/quicksettings/TileService;->onTileAdded()V

    const-string v0, "MJQSWeatherTileService"

    const-string v1, "onTileAdded: "

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

    .line 36
    invoke-static {}, Lcom/moji/statistics/EventManager;->a()Lcom/moji/statistics/EventManager;

    move-result-object v0

    sget-object v1, Lcom/moji/statistics/EVENT_TAG;->SET_ICON_ADD:Lcom/moji/statistics/EVENT_TAG;

    const-string v2, "1"

    invoke-virtual {v0, v1, v2}, Lcom/moji/statistics/EventManager;->a(Lcom/moji/statistics/EVENT_TAG;Ljava/lang/String;)Lcom/moji/statistics/EventManager;

    .line 37
    new-instance v0, Lcom/moji/mjweather/quicksetting/QuickSettingCase;

    invoke-direct {v0, p0}, Lcom/moji/mjweather/quicksetting/QuickSettingCase;-><init>(Landroid/content/Context;)V

    invoke-virtual {v0}, Lcom/moji/mjweather/quicksetting/QuickSettingCase;->b()V

    .line 38
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getQsTile()Landroid/service/quicksettings/Tile;

    move-result-object v0

    .line 39
    invoke-direct {p0, v0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->a(Landroid/service/quicksettings/Tile;)V

    return-void
.end method

.method public onTileRemoved()V
    .locals 3

    .line 103
    invoke-super {p0}, Landroid/service/quicksettings/TileService;->onTileRemoved()V

    .line 104
    invoke-static {}, Lcom/moji/statistics/EventManager;->a()Lcom/moji/statistics/EventManager;

    move-result-object v0

    sget-object v1, Lcom/moji/statistics/EVENT_TAG;->SET_ICON_ADD:Lcom/moji/statistics/EVENT_TAG;

    const-string v2, "0"

    invoke-virtual {v0, v1, v2}, Lcom/moji/statistics/EventManager;->a(Lcom/moji/statistics/EVENT_TAG;Ljava/lang/String;)Lcom/moji/statistics/EventManager;

    const-string v0, "MJQSWeatherTileService"

    const-string v1, "onTileRemoved: "

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

    .line 106
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getQsTile()Landroid/service/quicksettings/Tile;

    move-result-object v0

    if-nez v0, :cond_0

    return-void

    :cond_0
    const-string v1, "\u67e5\u770b\u5b9e\u65f6\u5929\u6c14"

    .line 112
    invoke-virtual {v0, v1}, Landroid/service/quicksettings/Tile;->setLabel(Ljava/lang/CharSequence;)V

    .line 113
    invoke-virtual {p0}, Lcom/moji/mjweather/quicksetting/MJQSWeatherTileService;->getApplicationContext()Landroid/content/Context;

    move-result-object v1

    const v2, 0x7f08056f

    invoke-static {v1, v2}, Landroid/graphics/drawable/Icon;->createWithResource(Landroid/content/Context;I)Landroid/graphics/drawable/Icon;

    move-result-object v1

    invoke-virtual {v0, v1}, Landroid/service/quicksettings/Tile;->setIcon(Landroid/graphics/drawable/Icon;)V

    .line 115
    :try_start_0
    invoke-virtual {v0}, Landroid/service/quicksettings/Tile;->updateTile()V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    goto :goto_0

    :catch_0
    move-exception v0

    const-string v1, "MJQSWeatherTileService"

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

    .line 119
    :goto_0
    new-instance v0, Lcom/moji/mjweather/quicksetting/QuickSettingCase;

    invoke-direct {v0, p0}, Lcom/moji/mjweather/quicksetting/QuickSettingCase;-><init>(Landroid/content/Context;)V

    invoke-virtual {v0}, Lcom/moji/mjweather/quicksetting/QuickSettingCase;->c()V

    return-void
.end method
