230 lines
6.3 KiB
Smali
230 lines
6.3 KiB
Smali
.class public final Lcom/discord/utilities/rest/AttachmentRequestBody;
|
|
.super Lokhttp3/RequestBody;
|
|
.source "AttachmentRequestBody.kt"
|
|
|
|
|
|
# instance fields
|
|
.field private final attachment:Lcom/lytefast/flexinput/model/Attachment;
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"Lcom/lytefast/flexinput/model/Attachment<",
|
|
"*>;"
|
|
}
|
|
.end annotation
|
|
.end field
|
|
|
|
.field private final contentResolver:Landroid/content/ContentResolver;
|
|
|
|
.field private final size:J
|
|
|
|
|
|
# direct methods
|
|
.method public constructor <init>(Landroid/content/ContentResolver;Lcom/lytefast/flexinput/model/Attachment;)V
|
|
.locals 2
|
|
.annotation system Ldalvik/annotation/Signature;
|
|
value = {
|
|
"(",
|
|
"Landroid/content/ContentResolver;",
|
|
"Lcom/lytefast/flexinput/model/Attachment<",
|
|
"*>;)V"
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "contentResolver"
|
|
|
|
invoke-static {p1, v0}, Ly/m/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v0, "attachment"
|
|
|
|
invoke-static {p2, v0}, Ly/m/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
invoke-direct {p0}, Lokhttp3/RequestBody;-><init>()V
|
|
|
|
iput-object p1, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->contentResolver:Landroid/content/ContentResolver;
|
|
|
|
iput-object p2, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->attachment:Lcom/lytefast/flexinput/model/Attachment;
|
|
|
|
invoke-virtual {p2}, Lcom/lytefast/flexinput/model/Attachment;->getData()Ljava/lang/Object;
|
|
|
|
move-result-object v0
|
|
|
|
instance-of v1, v0, Ljava/io/File;
|
|
|
|
if-nez v1, :cond_0
|
|
|
|
const/4 v0, 0x0
|
|
|
|
:cond_0
|
|
check-cast v0, Ljava/io/File;
|
|
|
|
if-eqz v0, :cond_1
|
|
|
|
invoke-virtual {v0}, Ljava/io/File;->length()J
|
|
|
|
move-result-wide p1
|
|
|
|
goto :goto_0
|
|
|
|
:cond_1
|
|
invoke-virtual {p2}, Lcom/lytefast/flexinput/model/Attachment;->getUri()Landroid/net/Uri;
|
|
|
|
move-result-object p2
|
|
|
|
invoke-static {p2, p1}, Lcom/discord/utilities/rest/SendUtilsKt;->computeFileSizeBytes(Landroid/net/Uri;Landroid/content/ContentResolver;)J
|
|
|
|
move-result-wide p1
|
|
|
|
:goto_0
|
|
iput-wide p1, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->size:J
|
|
|
|
return-void
|
|
.end method
|
|
|
|
|
|
# virtual methods
|
|
.method public contentLength()J
|
|
.locals 2
|
|
|
|
iget-wide v0, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->size:J
|
|
|
|
return-wide v0
|
|
.end method
|
|
|
|
.method public contentType()Lokhttp3/MediaType;
|
|
.locals 2
|
|
|
|
sget-object v0, Lokhttp3/MediaType;->g:Lokhttp3/MediaType$a;
|
|
|
|
iget-object v0, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->attachment:Lcom/lytefast/flexinput/model/Attachment;
|
|
|
|
iget-object v1, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->contentResolver:Landroid/content/ContentResolver;
|
|
|
|
invoke-static {v0, v1}, Lcom/discord/utilities/attachments/AttachmentUtilsKt;->getMimeType(Lcom/lytefast/flexinput/model/Attachment;Landroid/content/ContentResolver;)Ljava/lang/String;
|
|
|
|
move-result-object v0
|
|
|
|
invoke-static {v0}, Lokhttp3/MediaType$a;->b(Ljava/lang/String;)Lokhttp3/MediaType;
|
|
|
|
move-result-object v0
|
|
|
|
return-object v0
|
|
.end method
|
|
|
|
.method public writeTo(Lokio/BufferedSink;)V
|
|
.locals 3
|
|
.annotation system Ldalvik/annotation/Throws;
|
|
value = {
|
|
Ljava/io/IOException;
|
|
}
|
|
.end annotation
|
|
|
|
const-string v0, "sink"
|
|
|
|
invoke-static {p1, v0}, Ly/m/c/j;->checkNotNullParameter(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
:try_start_0
|
|
iget-object v0, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->contentResolver:Landroid/content/ContentResolver;
|
|
|
|
iget-object v1, p0, Lcom/discord/utilities/rest/AttachmentRequestBody;->attachment:Lcom/lytefast/flexinput/model/Attachment;
|
|
|
|
invoke-virtual {v1}, Lcom/lytefast/flexinput/model/Attachment;->getUri()Landroid/net/Uri;
|
|
|
|
move-result-object v1
|
|
|
|
invoke-virtual {v0, v1}, Landroid/content/ContentResolver;->openInputStream(Landroid/net/Uri;)Ljava/io/InputStream;
|
|
|
|
move-result-object v0
|
|
:try_end_0
|
|
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
|
|
|
|
if-eqz v0, :cond_0
|
|
|
|
:try_start_1
|
|
const-string v1, "inputStream"
|
|
|
|
invoke-static {v0, v1}, Ly/m/c/j;->checkNotNullExpressionValue(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
const-string v1, "$this$source"
|
|
|
|
invoke-static {v0, v1}, Ly/m/c/j;->checkParameterIsNotNull(Ljava/lang/Object;Ljava/lang/String;)V
|
|
|
|
new-instance v1, Ld0/n;
|
|
|
|
new-instance v2, Ld0/y;
|
|
|
|
invoke-direct {v2}, Ld0/y;-><init>()V
|
|
|
|
invoke-direct {v1, v0, v2}, Ld0/n;-><init>(Ljava/io/InputStream;Ld0/y;)V
|
|
:try_end_1
|
|
.catchall {:try_start_1 .. :try_end_1} :catchall_2
|
|
|
|
:try_start_2
|
|
invoke-interface {p1, v1}, Lokio/BufferedSink;->a0(Ld0/x;)J
|
|
:try_end_2
|
|
.catchall {:try_start_2 .. :try_end_2} :catchall_0
|
|
|
|
const/4 p1, 0x0
|
|
|
|
:try_start_3
|
|
invoke-static {v1, p1}, Lf/h/a/f/f/n/f;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
:try_end_3
|
|
.catchall {:try_start_3 .. :try_end_3} :catchall_2
|
|
|
|
:try_start_4
|
|
invoke-static {v0, p1}, Lf/h/a/f/f/n/f;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
:try_end_4
|
|
.catch Ljava/io/IOException; {:try_start_4 .. :try_end_4} :catch_0
|
|
|
|
goto :goto_0
|
|
|
|
:catchall_0
|
|
move-exception p1
|
|
|
|
:try_start_5
|
|
throw p1
|
|
:try_end_5
|
|
.catchall {:try_start_5 .. :try_end_5} :catchall_1
|
|
|
|
:catchall_1
|
|
move-exception v2
|
|
|
|
:try_start_6
|
|
invoke-static {v1, p1}, Lf/h/a/f/f/n/f;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
|
|
throw v2
|
|
:try_end_6
|
|
.catchall {:try_start_6 .. :try_end_6} :catchall_2
|
|
|
|
:catchall_2
|
|
move-exception p1
|
|
|
|
:try_start_7
|
|
throw p1
|
|
:try_end_7
|
|
.catchall {:try_start_7 .. :try_end_7} :catchall_3
|
|
|
|
:catchall_3
|
|
move-exception v1
|
|
|
|
:try_start_8
|
|
invoke-static {v0, p1}, Lf/h/a/f/f/n/f;->closeFinally(Ljava/io/Closeable;Ljava/lang/Throwable;)V
|
|
|
|
throw v1
|
|
:try_end_8
|
|
.catch Ljava/io/IOException; {:try_start_8 .. :try_end_8} :catch_0
|
|
|
|
:cond_0
|
|
:goto_0
|
|
return-void
|
|
|
|
:catch_0
|
|
move-exception p1
|
|
|
|
sget-object v0, Lcom/discord/app/AppLog;->e:Lcom/discord/app/AppLog;
|
|
|
|
const-string v1, "Could not write to sink"
|
|
|
|
invoke-virtual {v0, v1, p1}, Lcom/discord/app/AppLog;->i(Ljava/lang/String;Ljava/lang/Throwable;)V
|
|
|
|
throw p1
|
|
.end method
|