FireworksEffect.smali

.class public Lim/tpelyyftgw/ui/components/FireworksEffect;
.super Ljava/lang/Object;
.source "FireworksEffect.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    }
.end annotation


# instance fields
.field final angleDiff:F

.field private freeParticles:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList<",
            "Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;",
            ">;"
        }
    .end annotation
.end field

.field private lastAnimationTime:J

.field private particlePaint:Landroid/graphics/Paint;

.field private particles:Ljava/util/ArrayList;
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "Ljava/util/ArrayList<",
            "Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;",
            ">;"
        }
    .end annotation
.end field


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

    return-void
.end method

.method public constructor <init>()V
    .registers 5

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

    .line 22
    const v0, 0x3f860a92

    iput v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->angleDiff:F

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

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

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

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

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

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    .line 56
    new-instance v0, Landroid/graphics/Paint;

    const/4 v1, 0x1

    invoke-direct {v0, v1}, Landroid/graphics/Paint;-><init>(I)V

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particlePaint:Landroid/graphics/Paint;

    .line 57
    const/high16 v1, 0x3fc00000    # 1.5f

    invoke-static {v1}, Lim/tpelyyftgw/messenger/AndroidUtilities;->dp(F)I

    move-result v1

    int-to-float v1, v1

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeWidth(F)V

    .line 58
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particlePaint:Landroid/graphics/Paint;

    const-string v1, "actionBarDefaultTitle"

    invoke-static {v1}, Lim/tpelyyftgw/ui/actionbar/Theme;->getColor(Ljava/lang/String;)I

    move-result v1

    const v2, -0x19191a

    and-int/2addr v1, v2

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setColor(I)V

    .line 59
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particlePaint:Landroid/graphics/Paint;

    sget-object v1, Landroid/graphics/Paint$Cap;->ROUND:Landroid/graphics/Paint$Cap;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStrokeCap(Landroid/graphics/Paint$Cap;)V

    .line 60
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particlePaint:Landroid/graphics/Paint;

    sget-object v1, Landroid/graphics/Paint$Style;->STROKE:Landroid/graphics/Paint$Style;

    invoke-virtual {v0, v1}, Landroid/graphics/Paint;->setStyle(Landroid/graphics/Paint$Style;)V

    .line 62
    const/4 v0, 0x0

    .local v0, "a":I
    :goto_46
    const/16 v1, 0x14

    if-ge v0, v1, :cond_58

    .line 63
    iget-object v1, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    new-instance v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;

    const/4 v3, 0x0

    invoke-direct {v2, p0, v3}, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;-><init>(Lim/tpelyyftgw/ui/components/FireworksEffect;Lim/tpelyyftgw/ui/components/FireworksEffect$1;)V

    invoke-virtual {v1, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 62
    add-int/lit8 v0, v0, 0x1

    goto :goto_46

    .line 65
    .end local v0    # "a":I
    :cond_58
    return-void
.end method

.method static synthetic access$000(Lim/tpelyyftgw/ui/components/FireworksEffect;)Landroid/graphics/Paint;
    .registers 2
    .param p0, "x0"    # Lim/tpelyyftgw/ui/components/FireworksEffect;

    .line 16
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particlePaint:Landroid/graphics/Paint;

    return-object v0
.end method

.method private updateParticles(J)V
    .registers 10
    .param p1, "dt"    # J

    .line 68
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v0}, Ljava/util/ArrayList;->size()I

    move-result v0

    .line 69
    .local v0, "count":I
    const/4 v1, 0x0

    .local v1, "a":I
    :goto_7
    if-ge v1, v0, :cond_74

    .line 70
    iget-object v2, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v2, v1}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v2

    check-cast v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;

    .line 71
    .local v2, "particle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    iget v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->currentTime:F

    iget v4, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->lifeTime:F

    cmpl-float v3, v3, v4

    if-ltz v3, :cond_32

    .line 72
    iget-object v3, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v3

    const/16 v4, 0x28

    if-ge v3, v4, :cond_28

    .line 73
    iget-object v3, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    invoke-virtual {v3, v2}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 75
    :cond_28
    iget-object v3, p0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v3, v1}, Ljava/util/ArrayList;->remove(I)Ljava/lang/Object;

    .line 76
    add-int/lit8 v1, v1, -0x1

    .line 77
    add-int/lit8 v0, v0, -0x1

    .line 78
    goto :goto_71

    .line 80
    :cond_32
    const/high16 v3, 0x3f800000    # 1.0f

    sget-object v4, Lim/tpelyyftgw/messenger/AndroidUtilities;->decelerateInterpolator:Landroid/view/animation/DecelerateInterpolator;

    iget v5, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->currentTime:F

    iget v6, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->lifeTime:F

    div-float/2addr v5, v6

    invoke-virtual {v4, v5}, Landroid/view/animation/DecelerateInterpolator;->getInterpolation(F)F

    move-result v4

    sub-float/2addr v3, v4

    iput v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->alpha:F

    .line 81
    iget v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->x:F

    iget v4, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->vx:F

    iget v5, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->velocity:F

    mul-float v4, v4, v5

    long-to-float v5, p1

    mul-float v4, v4, v5

    const/high16 v5, 0x43fa0000    # 500.0f

    div-float/2addr v4, v5

    add-float/2addr v3, v4

    iput v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->x:F

    .line 82
    iget v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->y:F

    iget v4, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->vy:F

    iget v6, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->velocity:F

    mul-float v4, v4, v6

    long-to-float v6, p1

    mul-float v4, v4, v6

    div-float/2addr v4, v5

    add-float/2addr v3, v4

    iput v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->y:F

    .line 83
    iget v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->vy:F

    long-to-float v4, p1

    const/high16 v5, 0x42c80000    # 100.0f

    div-float/2addr v4, v5

    add-float/2addr v3, v4

    iput v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->vy:F

    .line 84
    iget v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->currentTime:F

    long-to-float v4, p1

    add-float/2addr v3, v4

    iput v3, v2, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->currentTime:F

    .line 69
    .end local v2    # "particle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    :goto_71
    add-int/lit8 v1, v1, 0x1

    goto :goto_7

    .line 86
    .end local v1    # "a":I
    :cond_74
    return-void
.end method


# virtual methods
.method public onDraw(Landroid/view/View;Landroid/graphics/Canvas;)V
    .registers 20
    .param p1, "parent"    # Landroid/view/View;
    .param p2, "canvas"    # Landroid/graphics/Canvas;

    .line 89
    move-object/from16 v0, p0

    move-object/from16 v1, p2

    if-eqz p1, :cond_138

    if-nez v1, :cond_a

    goto/16 :goto_138

    .line 93
    :cond_a
    iget-object v2, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v2}, Ljava/util/ArrayList;->size()I

    move-result v2

    .line 94
    .local v2, "count":I
    const/4 v3, 0x0

    .local v3, "a":I
    :goto_11
    if-ge v3, v2, :cond_21

    .line 95
    iget-object v4, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v4, v3}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v4

    check-cast v4, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;

    .line 96
    .local v4, "particle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    invoke-virtual {v4, v1}, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->draw(Landroid/graphics/Canvas;)V

    .line 94
    .end local v4    # "particle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    add-int/lit8 v3, v3, 0x1

    goto :goto_11

    .line 99
    .end local v3    # "a":I
    :cond_21
    sget-object v3, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    invoke-virtual {v3}, Ljava/security/SecureRandom;->nextBoolean()Z

    move-result v3

    if-eqz v3, :cond_121

    iget-object v3, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v3}, Ljava/util/ArrayList;->size()I

    move-result v3

    const/16 v4, 0x8

    add-int/2addr v3, v4

    const/16 v5, 0x96

    if-ge v3, v5, :cond_121

    .line 100
    sget v3, Landroid/os/Build$VERSION;->SDK_INT:I

    const/16 v5, 0x15

    const/4 v6, 0x0

    if-lt v3, v5, :cond_40

    sget v3, Lim/tpelyyftgw/messenger/AndroidUtilities;->statusBarHeight:I

    goto :goto_41

    :cond_40
    const/4 v3, 0x0

    .line 101
    .local v3, "statusBarHeight":I
    :goto_41
    sget-object v5, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    invoke-virtual {v5}, Ljava/security/SecureRandom;->nextFloat()F

    move-result v5

    invoke-virtual/range {p1 .. p1}, Landroid/view/View;->getMeasuredWidth()I

    move-result v7

    int-to-float v7, v7

    mul-float v5, v5, v7

    .line 102
    .local v5, "cx":F
    int-to-float v7, v3

    sget-object v8, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    invoke-virtual {v8}, Ljava/security/SecureRandom;->nextFloat()F

    move-result v8

    invoke-virtual/range {p1 .. p1}, Landroid/view/View;->getMeasuredHeight()I

    move-result v9

    const/high16 v10, 0x41a00000    # 20.0f

    invoke-static {v10}, Lim/tpelyyftgw/messenger/AndroidUtilities;->dp(F)I

    move-result v11

    sub-int/2addr v9, v11

    sub-int/2addr v9, v3

    int-to-float v9, v9

    mul-float v8, v8, v9

    add-float/2addr v7, v8

    .line 105
    .local v7, "cy":F
    sget-object v8, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    const/4 v9, 0x4

    invoke-virtual {v8, v9}, Ljava/security/SecureRandom;->nextInt(I)I

    move-result v8

    if-eqz v8, :cond_86

    const/4 v9, 0x1

    if-eq v8, v9, :cond_82

    const/4 v9, 0x2

    if-eq v8, v9, :cond_7e

    const/4 v9, 0x3

    if-eq v8, v9, :cond_7a

    .line 124
    const/16 v8, -0x1678

    .local v8, "color":I
    goto :goto_8a

    .line 119
    .end local v8    # "color":I
    :cond_7a
    const v8, -0xe63bc6

    .line 120
    .restart local v8    # "color":I
    goto :goto_8a

    .line 115
    .end local v8    # "color":I
    :cond_7e
    const v8, -0x328ad

    .line 116
    .restart local v8    # "color":I
    goto :goto_8a

    .line 111
    .end local v8    # "color":I
    :cond_82
    const v8, -0xcdfeb

    .line 112
    .restart local v8    # "color":I
    goto :goto_8a

    .line 107
    .end local v8    # "color":I
    :cond_86
    const v8, -0xcbd126

    .line 108
    .restart local v8    # "color":I
    nop

    .line 128
    :goto_8a
    const/4 v9, 0x0

    .local v9, "a":I
    :goto_8b
    if-ge v9, v4, :cond_120

    .line 129
    sget-object v11, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    const/16 v12, 0x10e

    invoke-virtual {v11, v12}, Ljava/security/SecureRandom;->nextInt(I)I

    move-result v11

    add-int/lit16 v11, v11, -0xe1

    .line 130
    .local v11, "angle":I
    int-to-double v12, v11

    const-wide v14, 0x3f91df46a2529d39L    # 0.017453292519943295

    invoke-static {v12, v13}, Ljava/lang/Double;->isNaN(D)Z

    mul-double v12, v12, v14

    invoke-static {v12, v13}, Ljava/lang/Math;->cos(D)D

    move-result-wide v12

    double-to-float v12, v12

    .line 131
    .local v12, "vx":F
    move/from16 v16, v5

    .end local v5    # "cx":F
    .local v16, "cx":F
    int-to-double v4, v11

    invoke-static {v4, v5}, Ljava/lang/Double;->isNaN(D)Z

    mul-double v4, v4, v14

    invoke-static {v4, v5}, Ljava/lang/Math;->sin(D)D

    move-result-wide v4

    double-to-float v4, v4

    .line 134
    .local v4, "vy":F
    iget-object v5, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    invoke-virtual {v5}, Ljava/util/ArrayList;->isEmpty()Z

    move-result v5

    if-nez v5, :cond_ca

    .line 135
    iget-object v5, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    invoke-virtual {v5, v6}, Ljava/util/ArrayList;->get(I)Ljava/lang/Object;

    move-result-object v5

    check-cast v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;

    .line 136
    .local v5, "newParticle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    iget-object v14, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->freeParticles:Ljava/util/ArrayList;

    invoke-virtual {v14, v6}, Ljava/util/ArrayList;->remove(I)Ljava/lang/Object;

    goto :goto_d0

    .line 138
    .end local v5    # "newParticle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    :cond_ca
    new-instance v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;

    const/4 v14, 0x0

    invoke-direct {v5, v0, v14}, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;-><init>(Lim/tpelyyftgw/ui/components/FireworksEffect;Lim/tpelyyftgw/ui/components/FireworksEffect$1;)V

    .line 140
    .restart local v5    # "newParticle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    :goto_d0
    move/from16 v14, v16

    .end local v16    # "cx":F
    .local v14, "cx":F
    iput v14, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->x:F

    .line 141
    iput v7, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->y:F

    .line 143
    const/high16 v15, 0x3fc00000    # 1.5f

    mul-float v13, v12, v15

    iput v13, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->vx:F

    .line 144
    iput v4, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->vy:F

    .line 146
    iput v8, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->color:I

    .line 147
    const/high16 v13, 0x3f800000    # 1.0f

    iput v13, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->alpha:F

    .line 148
    const/4 v10, 0x0

    iput v10, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->currentTime:F

    .line 150
    sget-object v10, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    invoke-virtual {v10}, Ljava/security/SecureRandom;->nextFloat()F

    move-result v10

    mul-float v10, v10, v15

    invoke-static {v13, v10}, Ljava/lang/Math;->max(FF)F

    move-result v10

    iput v10, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->scale:F

    .line 151
    iput v6, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->type:I

    .line 153
    sget-object v10, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    const/16 v13, 0x3e8

    invoke-virtual {v10, v13}, Ljava/security/SecureRandom;->nextInt(I)I

    move-result v10

    add-int/2addr v10, v13

    int-to-float v10, v10

    iput v10, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->lifeTime:F

    .line 154
    sget-object v10, Lim/tpelyyftgw/messenger/Utilities;->random:Ljava/security/SecureRandom;

    invoke-virtual {v10}, Ljava/security/SecureRandom;->nextFloat()F

    move-result v10

    const/high16 v13, 0x40800000    # 4.0f

    mul-float v10, v10, v13

    const/high16 v13, 0x41a00000    # 20.0f

    add-float/2addr v10, v13

    iput v10, v5, Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;->velocity:F

    .line 155
    iget-object v10, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->particles:Ljava/util/ArrayList;

    invoke-virtual {v10, v5}, Ljava/util/ArrayList;->add(Ljava/lang/Object;)Z

    .line 128
    .end local v4    # "vy":F
    .end local v5    # "newParticle":Lim/tpelyyftgw/ui/components/FireworksEffect$Particle;
    .end local v11    # "angle":I
    .end local v12    # "vx":F
    add-int/lit8 v9, v9, 0x1

    move v5, v14

    const/16 v4, 0x8

    const/high16 v10, 0x41a00000    # 20.0f

    goto/16 :goto_8b

    .end local v14    # "cx":F
    .local v5, "cx":F
    :cond_120
    move v14, v5

    .line 159
    .end local v3    # "statusBarHeight":I
    .end local v5    # "cx":F
    .end local v7    # "cy":F
    .end local v8    # "color":I
    .end local v9    # "a":I
    :cond_121
    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v3

    .line 160
    .local v3, "newTime":J
    const-wide/16 v5, 0x11

    iget-wide v7, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->lastAnimationTime:J

    sub-long v7, v3, v7

    invoke-static {v5, v6, v7, v8}, Ljava/lang/Math;->min(JJ)J

    move-result-wide v5

    .line 161
    .local v5, "dt":J
    invoke-direct {v0, v5, v6}, Lim/tpelyyftgw/ui/components/FireworksEffect;->updateParticles(J)V

    .line 162
    iput-wide v3, v0, Lim/tpelyyftgw/ui/components/FireworksEffect;->lastAnimationTime:J

    .line 163
    invoke-virtual/range {p1 .. p1}, Landroid/view/View;->invalidate()V

    .line 164
    return-void

    .line 90
    .end local v2    # "count":I
    .end local v3    # "newTime":J
    .end local v5    # "dt":J
    :cond_138
    :goto_138
    return-void
.end method