93 lines
3.2 KiB
Java
93 lines
3.2 KiB
Java
package com.discord.utilities.file;
|
|
|
|
import android.content.Context;
|
|
import androidx.annotation.RequiresPermission;
|
|
import com.discord.utilities.auth.GoogleSmartLockManager;
|
|
import d0.z.d.m;
|
|
import java.io.File;
|
|
import kotlin.jvm.internal.DefaultConstructorMarker;
|
|
import rx.Emitter;
|
|
import rx.Observable;
|
|
/* compiled from: DownloadUtils.kt */
|
|
public final class DownloadUtils {
|
|
public static final DownloadUtils INSTANCE = new DownloadUtils();
|
|
|
|
/* compiled from: DownloadUtils.kt */
|
|
public static abstract class DownloadState {
|
|
|
|
/* compiled from: DownloadUtils.kt */
|
|
public static final class Completed extends DownloadState {
|
|
private final File file;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Completed(File file) {
|
|
super(null);
|
|
m.checkNotNullParameter(file, "file");
|
|
this.file = file;
|
|
}
|
|
|
|
public final File getFile() {
|
|
return this.file;
|
|
}
|
|
}
|
|
|
|
/* compiled from: DownloadUtils.kt */
|
|
public static final class Failure extends DownloadState {
|
|
private final Exception exception;
|
|
|
|
/* JADX INFO: super call moved to the top of the method (can break code semantics) */
|
|
public Failure(Exception exc) {
|
|
super(null);
|
|
m.checkNotNullParameter(exc, "exception");
|
|
this.exception = exc;
|
|
}
|
|
|
|
public final Exception getException() {
|
|
return this.exception;
|
|
}
|
|
}
|
|
|
|
/* compiled from: DownloadUtils.kt */
|
|
public static final class InProgress extends DownloadState {
|
|
private final float progress;
|
|
|
|
public InProgress(float f) {
|
|
super(null);
|
|
this.progress = f;
|
|
}
|
|
|
|
public final float getProgress() {
|
|
return this.progress;
|
|
}
|
|
}
|
|
|
|
private DownloadState() {
|
|
}
|
|
|
|
public /* synthetic */ DownloadState(DefaultConstructorMarker defaultConstructorMarker) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
private DownloadUtils() {
|
|
}
|
|
|
|
@RequiresPermission(conditional = GoogleSmartLockManager.SET_DISCORD_ACCOUNT_DETAILS, value = "android.permission.WRITE_EXTERNAL_STORAGE")
|
|
public static final Observable<DownloadState> downloadFile(Context context, String str, String str2, File file) {
|
|
m.checkNotNullParameter(context, "context");
|
|
m.checkNotNullParameter(str, "fileUrl");
|
|
m.checkNotNullParameter(str2, "fileName");
|
|
m.checkNotNullParameter(file, "downloadDirectory");
|
|
Observable<DownloadState> n = Observable.n(new DownloadUtils$downloadFile$1(str, file, str2), Emitter.BackpressureMode.BUFFER);
|
|
m.checkNotNullExpressionValue(n, "Observable.create({ emit….BackpressureMode.BUFFER)");
|
|
return n;
|
|
}
|
|
|
|
public static /* synthetic */ Observable downloadFile$default(Context context, String str, String str2, File file, int i, Object obj) {
|
|
if ((i & 8) != 0) {
|
|
file = context.getCacheDir();
|
|
m.checkNotNullExpressionValue(file, "context.cacheDir");
|
|
}
|
|
return downloadFile(context, str, str2, file);
|
|
}
|
|
}
|