package com.ironsource; import android.graphics.drawable.Drawable; import android.webkit.URLUtil; import java.io.File; import java.io.InputStream; import kotlin.Result; import kotlin.ResultKt; import kotlin.io.CloseableKt; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Intrinsics; /* loaded from: classes2.dex */ public final class rg implements sg { private final o8 a; /* JADX WARN: Multi-variable type inference failed */ public rg() { this(null, 1, 0 == true ? 1 : 0); } public rg(o8 connectionFactory) { Intrinsics.checkNotNullParameter(connectionFactory, "connectionFactory"); this.a = connectionFactory; } public /* synthetic */ rg(o8 o8Var, int i, DefaultConstructorMarker defaultConstructorMarker) { this((i & 1) != 0 ? v9.a : o8Var); } private final Object b(String str) { Exception exc; File file = new File(str); if (file.exists()) { Drawable createFromPath = Drawable.createFromPath(file.getPath()); if (createFromPath != null) { return Result.m4060constructorimpl(createFromPath); } Result.Companion companion = Result.Companion; exc = new Exception("failed to create a drawable"); } else { Result.Companion companion2 = Result.Companion; exc = new Exception("file does not exists"); } return Result.m4060constructorimpl(ResultKt.createFailure(exc)); } private final Object c(String str) { InputStream a = this.a.a(str); try { Object createFromStream = Drawable.createFromStream(a, new File(str).getName()); CloseableKt.closeFinally(a, null); if (createFromStream == null) { Result.Companion companion = Result.Companion; createFromStream = ResultKt.createFailure(new Exception("failed to create a drawable")); } return Result.m4060constructorimpl(createFromStream); } finally { } } private final boolean d(String str) { return URLUtil.isHttpsUrl(str); } @Override // com.ironsource.sg public Object a(String url) { Intrinsics.checkNotNullParameter(url, "url"); try { return d(url) ? c(url) : b(url); } catch (Exception e) { i9.d().a(e); Result.Companion companion = Result.Companion; return Result.m4060constructorimpl(ResultKt.createFailure(e)); } } }