Slice.smali

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


# instance fields
.field private bounds:Landroid/graphics/RectF;

.field private file:Ljava/io/File;


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

    return-void
.end method

.method public constructor <init>(Ljava/nio/ByteBuffer;Landroid/graphics/RectF;Lim/tpelyyftgw/messenger/DispatchQueue;)V
    .registers 7
    .param p1, "data"    # Ljava/nio/ByteBuffer;
    .param p2, "rect"    # Landroid/graphics/RectF;
    .param p3, "queue"    # Lim/tpelyyftgw/messenger/DispatchQueue;

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

    .line 22
    iput-object p2, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->bounds:Landroid/graphics/RectF;

    .line 25
    :try_start_5
    sget-object v0, Lim/tpelyyftgw/messenger/ApplicationLoader;->applicationContext:Landroid/content/Context;

    invoke-virtual {v0}, Landroid/content/Context;->getCacheDir()Ljava/io/File;

    move-result-object v0

    .line 26
    .local v0, "outputDir":Ljava/io/File;
    const-string v1, "paint"

    const-string v2, ".bin"

    invoke-static {v1, v2, v0}, Ljava/io/File;->createTempFile(Ljava/lang/String;Ljava/lang/String;Ljava/io/File;)Ljava/io/File;

    move-result-object v1

    iput-object v1, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->file:Ljava/io/File;
    :try_end_15
    .catch Ljava/lang/Exception; {:try_start_5 .. :try_end_15} :catch_16

    .line 29
    .end local v0    # "outputDir":Ljava/io/File;
    goto :goto_1a

    .line 27
    :catch_16
    move-exception v0

    .line 28
    .local v0, "e":Ljava/lang/Exception;
    invoke-static {v0}, Lim/tpelyyftgw/messenger/FileLog;->e(Ljava/lang/Throwable;)V

    .line 31
    .end local v0    # "e":Ljava/lang/Exception;
    :goto_1a
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->file:Ljava/io/File;

    if-nez v0, :cond_1f

    .line 32
    return-void

    .line 34
    :cond_1f
    invoke-direct {p0, p1}, Lim/tpelyyftgw/ui/components/paint/Slice;->storeData(Ljava/nio/ByteBuffer;)V

    .line 35
    return-void
.end method

.method private storeData(Ljava/nio/ByteBuffer;)V
    .registers 8
    .param p1, "data"    # Ljava/nio/ByteBuffer;

    .line 46
    :try_start_0
    invoke-virtual {p1}, Ljava/nio/ByteBuffer;->array()[B

    move-result-object v0

    .line 47
    .local v0, "input":[B
    new-instance v1, Ljava/io/FileOutputStream;

    iget-object v2, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->file:Ljava/io/File;

    invoke-direct {v1, v2}, Ljava/io/FileOutputStream;-><init>(Ljava/io/File;)V

    .line 49
    .local v1, "fos":Ljava/io/FileOutputStream;
    new-instance v2, Ljava/util/zip/Deflater;

    const/4 v3, 0x1

    invoke-direct {v2, v3, v3}, Ljava/util/zip/Deflater;-><init>(IZ)V

    .line 50
    .local v2, "deflater":Ljava/util/zip/Deflater;
    invoke-virtual {p1}, Ljava/nio/ByteBuffer;->arrayOffset()I

    move-result v3

    invoke-virtual {p1}, Ljava/nio/ByteBuffer;->remaining()I

    move-result v4

    invoke-virtual {v2, v0, v3, v4}, Ljava/util/zip/Deflater;->setInput([BII)V

    .line 51
    invoke-virtual {v2}, Ljava/util/zip/Deflater;->finish()V

    .line 53
    const/16 v3, 0x400

    new-array v3, v3, [B

    .line 54
    .local v3, "buf":[B
    :goto_23
    invoke-virtual {v2}, Ljava/util/zip/Deflater;->finished()Z

    move-result v4

    if-nez v4, :cond_32

    .line 55
    invoke-virtual {v2, v3}, Ljava/util/zip/Deflater;->deflate([B)I

    move-result v4

    .line 56
    .local v4, "byteCount":I
    const/4 v5, 0x0

    invoke-virtual {v1, v3, v5, v4}, Ljava/io/FileOutputStream;->write([BII)V

    .line 57
    .end local v4    # "byteCount":I
    goto :goto_23

    .line 58
    :cond_32
    invoke-virtual {v2}, Ljava/util/zip/Deflater;->end()V

    .line 60
    invoke-virtual {v1}, Ljava/io/FileOutputStream;->close()V
    :try_end_38
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_38} :catch_39

    .line 63
    .end local v0    # "input":[B
    .end local v1    # "fos":Ljava/io/FileOutputStream;
    .end local v2    # "deflater":Ljava/util/zip/Deflater;
    .end local v3    # "buf":[B
    goto :goto_3d

    .line 61
    :catch_39
    move-exception v0

    .line 62
    .local v0, "e":Ljava/lang/Exception;
    invoke-static {v0}, Lim/tpelyyftgw/messenger/FileLog;->e(Ljava/lang/Throwable;)V

    .line 64
    .end local v0    # "e":Ljava/lang/Exception;
    :goto_3d
    return-void
.end method


# virtual methods
.method public cleanResources()V
    .registers 2

    .line 38
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->file:Ljava/io/File;

    if-eqz v0, :cond_a

    .line 39
    invoke-virtual {v0}, Ljava/io/File;->delete()Z

    .line 40
    const/4 v0, 0x0

    iput-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->file:Ljava/io/File;

    .line 42
    :cond_a
    return-void
.end method

.method public getBounds()Landroid/graphics/RectF;
    .registers 3

    .line 124
    new-instance v0, Landroid/graphics/RectF;

    iget-object v1, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->bounds:Landroid/graphics/RectF;

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

    return-object v0
.end method

.method public getData()Ljava/nio/ByteBuffer;
    .registers 10

    .line 68
    const/16 v0, 0x400

    :try_start_2
    new-array v1, v0, [B

    .line 69
    .local v1, "input":[B
    new-array v0, v0, [B

    .line 70
    .local v0, "output":[B
    new-instance v2, Ljava/io/FileInputStream;

    iget-object v3, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->file:Ljava/io/File;

    invoke-direct {v2, v3}, Ljava/io/FileInputStream;-><init>(Ljava/io/File;)V

    .line 71
    .local v2, "fin":Ljava/io/FileInputStream;
    new-instance v3, Ljava/io/ByteArrayOutputStream;

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

    .line 72
    .local v3, "bos":Ljava/io/ByteArrayOutputStream;
    new-instance v4, Ljava/util/zip/Inflater;

    const/4 v5, 0x1

    invoke-direct {v4, v5}, Ljava/util/zip/Inflater;-><init>(Z)V

    .line 75
    .local v4, "inflater":Ljava/util/zip/Inflater;
    :goto_18
    invoke-virtual {v2, v1}, Ljava/io/FileInputStream;->read([B)I

    move-result v5

    .line 76
    .local v5, "numRead":I
    const/4 v6, -0x1

    const/4 v7, 0x0

    if-eq v5, v6, :cond_23

    .line 77
    invoke-virtual {v4, v1, v7, v5}, Ljava/util/zip/Inflater;->setInput([BII)V

    .line 81
    :cond_23
    :goto_23
    array-length v6, v0

    invoke-virtual {v4, v0, v7, v6}, Ljava/util/zip/Inflater;->inflate([BII)I

    move-result v6

    move v8, v6

    .local v8, "numDecompressed":I
    if-eqz v6, :cond_2f

    .line 82
    invoke-virtual {v3, v0, v7, v8}, Ljava/io/ByteArrayOutputStream;->write([BII)V

    goto :goto_23

    .line 85
    :cond_2f
    invoke-virtual {v4}, Ljava/util/zip/Inflater;->finished()Z

    move-result v6

    if-eqz v6, :cond_4c

    .line 86
    nop

    .line 93
    .end local v5    # "numRead":I
    .end local v8    # "numDecompressed":I
    invoke-virtual {v4}, Ljava/util/zip/Inflater;->end()V

    .line 94
    invoke-virtual {v3}, Ljava/io/ByteArrayOutputStream;->toByteArray()[B

    move-result-object v5

    invoke-virtual {v3}, Ljava/io/ByteArrayOutputStream;->size()I

    move-result v6

    invoke-static {v5, v7, v6}, Ljava/nio/ByteBuffer;->wrap([BII)Ljava/nio/ByteBuffer;

    move-result-object v5

    .line 96
    .local v5, "result":Ljava/nio/ByteBuffer;
    invoke-virtual {v3}, Ljava/io/ByteArrayOutputStream;->close()V

    .line 97
    invoke-virtual {v2}, Ljava/io/FileInputStream;->close()V

    .line 99
    return-object v5

    .line 88
    .local v5, "numRead":I
    .restart local v8    # "numDecompressed":I
    :cond_4c
    invoke-virtual {v4}, Ljava/util/zip/Inflater;->needsInput()Z

    move-result v6
    :try_end_50
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_50} :catch_54

    if-eqz v6, :cond_53

    .line 89
    goto :goto_18

    .line 91
    .end local v5    # "numRead":I
    .end local v8    # "numDecompressed":I
    :cond_53
    goto :goto_18

    .line 100
    .end local v0    # "output":[B
    .end local v1    # "input":[B
    .end local v2    # "fin":Ljava/io/FileInputStream;
    .end local v3    # "bos":Ljava/io/ByteArrayOutputStream;
    .end local v4    # "inflater":Ljava/util/zip/Inflater;
    :catch_54
    move-exception v0

    .line 101
    .local v0, "e":Ljava/lang/Exception;
    invoke-static {v0}, Lim/tpelyyftgw/messenger/FileLog;->e(Ljava/lang/Throwable;)V

    .line 104
    .end local v0    # "e":Ljava/lang/Exception;
    const/4 v0, 0x0

    return-object v0
.end method

.method public getHeight()I
    .registers 2

    .line 120
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->bounds:Landroid/graphics/RectF;

    invoke-virtual {v0}, Landroid/graphics/RectF;->height()F

    move-result v0

    float-to-int v0, v0

    return v0
.end method

.method public getWidth()I
    .registers 2

    .line 116
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->bounds:Landroid/graphics/RectF;

    invoke-virtual {v0}, Landroid/graphics/RectF;->width()F

    move-result v0

    float-to-int v0, v0

    return v0
.end method

.method public getX()I
    .registers 2

    .line 108
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->bounds:Landroid/graphics/RectF;

    iget v0, v0, Landroid/graphics/RectF;->left:F

    float-to-int v0, v0

    return v0
.end method

.method public getY()I
    .registers 2

    .line 112
    iget-object v0, p0, Lim/tpelyyftgw/ui/components/paint/Slice;->bounds:Landroid/graphics/RectF;

    iget v0, v0, Landroid/graphics/RectF;->top:F

    float-to-int v0, v0

    return v0
.end method