.class public Lcom/scaleasw/powercalc/ConstantActivity;
.super Landroid/app/Activity;
.source "ConstantActivity.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/scaleasw/powercalc/ConstantActivity$ParserState;
    }
.end annotation


# static fields
.field static final KEY_SYMBOL:Ljava/lang/String; = "symbol"

.field static final KEY_TITLE:Ljava/lang/String; = "title"

.field static final KEY_VALUE:Ljava/lang/String; = "value"


# instance fields
.field private adapter:Lcom/scaleasw/powercalc/ConstantAdapter;

.field private list:Landroid/widget/ListView;


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

    .prologue
    .line 21
    invoke-direct {p0}, Landroid/app/Activity;-><init>()V

    .line 23
    return-void
.end method

.method static synthetic access$000(Lcom/scaleasw/powercalc/ConstantActivity;Lcom/scaleasw/powercalc/ConstantItem;)V
    .locals 0
    .param p0, "x0"    # Lcom/scaleasw/powercalc/ConstantActivity;
    .param p1, "x1"    # Lcom/scaleasw/powercalc/ConstantItem;

    .prologue
    .line 21
    invoke-direct {p0, p1}, Lcom/scaleasw/powercalc/ConstantActivity;->sendResult(Lcom/scaleasw/powercalc/ConstantItem;)V

    return-void
.end method

.method private applyScreenOrientation()V
    .locals 7

    .prologue
    const/4 v6, 0x6

    const/4 v5, 0x4

    const/4 v4, 0x1

    .line 41
    invoke-static {p0}, Landroid/preference/PreferenceManager;->getDefaultSharedPreferences(Landroid/content/Context;)Landroid/content/SharedPreferences;

    move-result-object v1

    .line 42
    .local v1, "prefs":Landroid/content/SharedPreferences;
    const-string v2, "prefScreenRotation"

    const-string v3, "1"

    invoke-interface {v1, v2, v3}, Landroid/content/SharedPreferences;->getString(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    invoke-static {v2}, Ljava/lang/Integer;->parseInt(Ljava/lang/String;)I

    move-result v0

    .line 45
    .local v0, "orientation":I
    const/4 v0, 0x1

    .line 47
    if-nez v0, :cond_1

    .line 48
    invoke-virtual {p0, v5}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    .line 61
    :cond_0
    :goto_0
    return-void

    .line 49
    :cond_1
    if-ne v0, v4, :cond_2

    .line 50
    invoke-virtual {p0, v4}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    goto :goto_0

    .line 51
    :cond_2
    const/4 v2, 0x2

    if-ne v0, v2, :cond_3

    .line 52
    const/16 v2, 0x9

    invoke-virtual {p0, v2}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    goto :goto_0

    .line 53
    :cond_3
    const/4 v2, 0x3

    if-ne v0, v2, :cond_4

    .line 54
    const/4 v2, 0x7

    invoke-virtual {p0, v2}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    goto :goto_0

    .line 55
    :cond_4
    if-ne v0, v5, :cond_5

    .line 56
    const/4 v2, 0x0

    invoke-virtual {p0, v2}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    goto :goto_0

    .line 57
    :cond_5
    const/4 v2, 0x5

    if-ne v0, v2, :cond_6

    .line 58
    const/16 v2, 0x8

    invoke-virtual {p0, v2}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    goto :goto_0

    .line 59
    :cond_6
    if-ne v0, v6, :cond_0

    .line 60
    invoke-virtual {p0, v6}, Lcom/scaleasw/powercalc/ConstantActivity;->setRequestedOrientation(I)V

    goto :goto_0
.end method

.method private sendResult(Lcom/scaleasw/powercalc/ConstantItem;)V
    .locals 3
    .param p1, "item"    # Lcom/scaleasw/powercalc/ConstantItem;

    .prologue
    .line 65
    new-instance v0, Landroid/content/Intent;

    invoke-direct {v0}, Landroid/content/Intent;-><init>()V

    .line 66
    .local v0, "returnIntent":Landroid/content/Intent;
    const-string v1, "element"

    iget-object v2, p1, Lcom/scaleasw/powercalc/ConstantItem;->element:Ljava/lang/String;

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

    .line 67
    const-string v1, "value"

    iget-object v2, p1, Lcom/scaleasw/powercalc/ConstantItem;->value:Ljava/lang/String;

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

    .line 68
    const/4 v1, -0x1

    invoke-virtual {p0, v1, v0}, Lcom/scaleasw/powercalc/ConstantActivity;->setResult(ILandroid/content/Intent;)V

    .line 69
    invoke-virtual {p0}, Lcom/scaleasw/powercalc/ConstantActivity;->finish()V

    .line 70
    return-void
.end method


# virtual methods
.method public loadConstantPage(Ljava/lang/String;)V
    .locals 4
    .param p1, "pageName"    # Ljava/lang/String;

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

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

    .line 76
    .local v0, "constantList":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Lcom/scaleasw/powercalc/ConstantItem;>;"
    const/high16 v2, 0x7f030000

    invoke-virtual {p0, v2}, Lcom/scaleasw/powercalc/ConstantActivity;->setContentView(I)V

    .line 78
    :try_start_0
    invoke-virtual {p0, p1, v0}, Lcom/scaleasw/powercalc/ConstantActivity;->readXmlPage(Ljava/lang/String;Ljava/util/ArrayList;)V
    :try_end_0
    .catch Lorg/xmlpull/v1/XmlPullParserException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_1

    .line 85
    :goto_0
    const/high16 v2, 0x7f0b0000

    invoke-virtual {p0, v2}, Lcom/scaleasw/powercalc/ConstantActivity;->findViewById(I)Landroid/view/View;

    move-result-object v2

    check-cast v2, Landroid/widget/ListView;

    iput-object v2, p0, Lcom/scaleasw/powercalc/ConstantActivity;->list:Landroid/widget/ListView;

    .line 88
    new-instance v2, Lcom/scaleasw/powercalc/ConstantAdapter;

    invoke-direct {v2, p0, v0}, Lcom/scaleasw/powercalc/ConstantAdapter;-><init>(Landroid/app/Activity;Ljava/util/ArrayList;)V

    iput-object v2, p0, Lcom/scaleasw/powercalc/ConstantActivity;->adapter:Lcom/scaleasw/powercalc/ConstantAdapter;

    .line 89
    iget-object v2, p0, Lcom/scaleasw/powercalc/ConstantActivity;->list:Landroid/widget/ListView;

    iget-object v3, p0, Lcom/scaleasw/powercalc/ConstantActivity;->adapter:Lcom/scaleasw/powercalc/ConstantAdapter;

    invoke-virtual {v2, v3}, Landroid/widget/ListView;->setAdapter(Landroid/widget/ListAdapter;)V

    .line 90
    iget-object v2, p0, Lcom/scaleasw/powercalc/ConstantActivity;->list:Landroid/widget/ListView;

    new-instance v3, Lcom/scaleasw/powercalc/ConstantActivity$1;

    invoke-direct {v3, p0}, Lcom/scaleasw/powercalc/ConstantActivity$1;-><init>(Lcom/scaleasw/powercalc/ConstantActivity;)V

    invoke-virtual {v2, v3}, Landroid/widget/ListView;->setOnItemClickListener(Landroid/widget/AdapterView$OnItemClickListener;)V

    .line 104
    return-void

    .line 79
    :catch_0
    move-exception v1

    .line 80
    .local v1, "e":Lorg/xmlpull/v1/XmlPullParserException;
    invoke-virtual {v1}, Lorg/xmlpull/v1/XmlPullParserException;->printStackTrace()V

    goto :goto_0

    .line 81
    .end local v1    # "e":Lorg/xmlpull/v1/XmlPullParserException;
    :catch_1
    move-exception v1

    .line 82
    .local v1, "e":Ljava/io/IOException;
    invoke-virtual {v1}, Ljava/io/IOException;->printStackTrace()V

    goto :goto_0
.end method

.method protected onCreate(Landroid/os/Bundle;)V
    .locals 1
    .param p1, "savedInstanceState"    # Landroid/os/Bundle;

    .prologue
    .line 34
    invoke-super {p0, p1}, Landroid/app/Activity;->onCreate(Landroid/os/Bundle;)V

    .line 35
    const-string v0, "0"

    invoke-virtual {p0, v0}, Lcom/scaleasw/powercalc/ConstantActivity;->loadConstantPage(Ljava/lang/String;)V

    .line 36
    invoke-direct {p0}, Lcom/scaleasw/powercalc/ConstantActivity;->applyScreenOrientation()V

    .line 37
    return-void
.end method

.method public readXmlPage(Ljava/lang/String;Ljava/util/ArrayList;)V
    .locals 10
    .param p1, "pageName"    # Ljava/lang/String;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "(",
            "Ljava/lang/String;",
            "Ljava/util/ArrayList",
            "<",
            "Lcom/scaleasw/powercalc/ConstantItem;",
            ">;)V"
        }
    .end annotation

    .annotation system Ldalvik/annotation/Throws;
        value = {
            Lorg/xmlpull/v1/XmlPullParserException;,
            Ljava/io/IOException;
        }
    .end annotation

    .prologue
    .local p2, "constantList":Ljava/util/ArrayList;, "Ljava/util/ArrayList<Lcom/scaleasw/powercalc/ConstantItem;>;"
    const/4 v9, 0x0

    .line 109
    sget-object v3, Lcom/scaleasw/powercalc/ConstantActivity$ParserState;->IDDLE:Lcom/scaleasw/powercalc/ConstantActivity$ParserState;

    .line 110
    .local v3, "parserState":Lcom/scaleasw/powercalc/ConstantActivity$ParserState;
    invoke-virtual {p0}, Lcom/scaleasw/powercalc/ConstantActivity;->getResources()Landroid/content/res/Resources;

    move-result-object v4

    .line 111
    .local v4, "res":Landroid/content/res/Resources;
    const/high16 v7, 0x7f040000

    invoke-virtual {v4, v7}, Landroid/content/res/Resources;->getXml(I)Landroid/content/res/XmlResourceParser;

    move-result-object v6

    .line 113
    .local v6, "xpp":Landroid/content/res/XmlResourceParser;
    invoke-interface {v6}, Landroid/content/res/XmlResourceParser;->next()I

    .line 114
    invoke-interface {v6}, Landroid/content/res/XmlResourceParser;->getEventType()I

    move-result v0

    .line 115
    .local v0, "eventType":I
    :goto_0
    const/4 v7, 0x1

    if-eq v0, v7, :cond_c

    .line 117
    const/4 v7, 0x2

    if-ne v0, v7, :cond_b

    .line 119
    invoke-interface {v6}, Landroid/content/res/XmlResourceParser;->getName()Ljava/lang/String;

    move-result-object v5

    .line 120
    .local v5, "tag":Ljava/lang/String;
    sget-object v7, Lcom/scaleasw/powercalc/ConstantActivity$2;->$SwitchMap$com$scaleasw$powercalc$ConstantActivity$ParserState:[I

    invoke-virtual {v3}, Lcom/scaleasw/powercalc/ConstantActivity$ParserState;->ordinal()I

    move-result v8

    aget v7, v7, v8

    packed-switch v7, :pswitch_data_0

    .line 162
    .end local v5    # "tag":Ljava/lang/String;
    :cond_0
    :goto_1
    invoke-interface {v6}, Landroid/content/res/XmlResourceParser;->next()I

    move-result v0

    goto :goto_0

    .line 123
    .restart local v5    # "tag":Ljava/lang/String;
    :pswitch_0
    const-string v7, "page"

    invoke-virtual {v5, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_0

    .line 124
    const-string v7, "name"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    invoke-virtual {v7, p1}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_1

    sget-object v3, Lcom/scaleasw/powercalc/ConstantActivity$ParserState;->PAGE:Lcom/scaleasw/powercalc/ConstantActivity$ParserState;

    goto :goto_1

    .line 125
    :cond_1
    sget-object v3, Lcom/scaleasw/powercalc/ConstantActivity$ParserState;->IDDLE:Lcom/scaleasw/powercalc/ConstantActivity$ParserState;

    goto :goto_1

    .line 129
    :pswitch_1
    const-string v7, "item"

    invoke-virtual {v5, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_0

    .line 130
    new-instance v1, Lcom/scaleasw/powercalc/ConstantItem;

    invoke-direct {v1}, Lcom/scaleasw/powercalc/ConstantItem;-><init>()V

    .line 131
    .local v1, "item":Lcom/scaleasw/powercalc/ConstantItem;
    const-string v7, "page"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v2

    .line 132
    .local v2, "page":Ljava/lang/String;
    if-eqz v2, :cond_2

    const-string v7, ""

    invoke-virtual {v2, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_a

    :cond_2
    sget-object v7, Lcom/scaleasw/powercalc/ConstantItem$ConstantType;->CONSTANT:Lcom/scaleasw/powercalc/ConstantItem$ConstantType;

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->type:Lcom/scaleasw/powercalc/ConstantItem$ConstantType;

    .line 135
    :goto_2
    const-string v7, "symbol"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->symbol:Ljava/lang/String;

    .line 136
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->symbol:Ljava/lang/String;

    if-nez v7, :cond_3

    const-string v7, ""

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->symbol:Ljava/lang/String;

    .line 137
    :cond_3
    const-string v7, "title"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->title:Ljava/lang/String;

    .line 138
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->title:Ljava/lang/String;

    if-nez v7, :cond_4

    const-string v7, ""

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->title:Ljava/lang/String;

    .line 139
    :cond_4
    const-string v7, "valueDisplay"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->displayValue:Ljava/lang/String;

    .line 140
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->displayValue:Ljava/lang/String;

    if-nez v7, :cond_5

    const-string v7, ""

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->displayValue:Ljava/lang/String;

    .line 141
    :cond_5
    const-string v7, "page"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->page:Ljava/lang/String;

    .line 142
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->page:Ljava/lang/String;

    if-nez v7, :cond_6

    const-string v7, ""

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->page:Ljava/lang/String;

    .line 143
    :cond_6
    const-string v7, "value"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->value:Ljava/lang/String;

    .line 144
    const-string v7, "unit"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->unit:Ljava/lang/String;

    .line 145
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->unit:Ljava/lang/String;

    if-nez v7, :cond_7

    const-string v7, ""

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->unit:Ljava/lang/String;

    .line 146
    :cond_7
    const-string v7, "element"

    invoke-interface {v6, v9, v7}, Landroid/content/res/XmlResourceParser;->getAttributeValue(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->element:Ljava/lang/String;

    .line 147
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->element:Ljava/lang/String;

    if-nez v7, :cond_8

    const-string v7, ""

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->element:Ljava/lang/String;

    .line 148
    :cond_8
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->symbol:Ljava/lang/String;

    const-string v8, ""

    invoke-virtual {v7, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_9

    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->element:Ljava/lang/String;

    const-string v8, ""

    invoke-virtual {v7, v8}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-nez v7, :cond_9

    .line 150
    iget-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->element:Ljava/lang/String;

    invoke-static {v7}, Lcom/scaleasw/powercalc/Element;->valueOf(Ljava/lang/String;)Lcom/scaleasw/powercalc/Element;

    move-result-object v7

    invoke-virtual {v7}, Lcom/scaleasw/powercalc/Element;->translationSimple()Ljava/lang/String;

    move-result-object v7

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->symbol:Ljava/lang/String;

    .line 152
    :cond_9
    invoke-virtual {p2, v1}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    goto/16 :goto_1

    .line 133
    :cond_a
    sget-object v7, Lcom/scaleasw/powercalc/ConstantItem$ConstantType;->ITEM:Lcom/scaleasw/powercalc/ConstantItem$ConstantType;

    iput-object v7, v1, Lcom/scaleasw/powercalc/ConstantItem;->type:Lcom/scaleasw/powercalc/ConstantItem$ConstantType;

    goto/16 :goto_2

    .line 158
    .end local v1    # "item":Lcom/scaleasw/powercalc/ConstantItem;
    .end local v2    # "page":Ljava/lang/String;
    .end local v5    # "tag":Ljava/lang/String;
    :cond_b
    const/4 v7, 0x3

    if-ne v0, v7, :cond_0

    .line 159
    invoke-interface {v6}, Landroid/content/res/XmlResourceParser;->getName()Ljava/lang/String;

    move-result-object v5

    .line 160
    .restart local v5    # "tag":Ljava/lang/String;
    sget-object v7, Lcom/scaleasw/powercalc/ConstantActivity$ParserState;->PAGE:Lcom/scaleasw/powercalc/ConstantActivity$ParserState;

    if-ne v3, v7, :cond_0

    const-string v7, "page"

    invoke-virtual {v5, v7}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v7

    if-eqz v7, :cond_0

    .line 164
    .end local v5    # "tag":Ljava/lang/String;
    :cond_c
    return-void

    .line 120
    :pswitch_data_0
    .packed-switch 0x1
        :pswitch_0
        :pswitch_1
    .end packed-switch
.end method
