package com.applovin.impl.sdk.nativeAd; import android.net.Uri; import com.applovin.impl.sdk.j; import com.applovin.impl.sdk.n; import com.applovin.impl.sdk.utils.StringUtils; import com.applovin.impl.u2; import com.applovin.impl.yl; import java.io.File; import java.util.Collections; /* loaded from: classes2.dex */ public class a extends yl { private final u2 h; private final AppLovinNativeAdImpl i; private final InterfaceC0039a j; /* renamed from: com.applovin.impl.sdk.nativeAd.a$a, reason: collision with other inner class name */ public interface InterfaceC0039a { void a(AppLovinNativeAdImpl appLovinNativeAdImpl); } public a(AppLovinNativeAdImpl appLovinNativeAdImpl, j jVar, InterfaceC0039a interfaceC0039a) { super("TaskCacheNativeAd", jVar); this.h = new u2(); this.i = appLovinNativeAdImpl; this.j = interfaceC0039a; } private Uri a(Uri uri) { if (uri == null) { return null; } if (n.a()) { this.c.a(this.b, "Attempting to cache resource: " + uri); } String a = this.a.B().a(a(), uri.toString(), this.i.getCachePrefix(), Collections.emptyList(), false, false, this.h, 1); if (StringUtils.isValidString(a)) { File a2 = this.a.B().a(a, a()); if (a2 != null) { Uri fromFile = Uri.fromFile(a2); if (fromFile != null) { return fromFile; } if (n.a()) { this.c.b(this.b, "Unable to extract Uri from image file"); } } else if (n.a()) { this.c.b(this.b, "Unable to retrieve File from cached image filename = " + a); } } return null; } @Override // java.lang.Runnable public void run() { if (n.a()) { this.c.a(this.b, "Begin caching ad #" + this.i.getAdIdNumber() + "..."); } Uri a = a(this.i.getIconUri()); if (a != null) { this.i.setIconUri(a); } Uri a2 = a(this.i.getMainImageUri()); if (a2 != null) { this.i.setMainImageUri(a2); } Uri a3 = a(this.i.getPrivacyIconUri()); if (a3 != null) { this.i.setPrivacyIconUri(a3); } if (n.a()) { this.c.a(this.b, "Finished caching ad #" + this.i.getAdIdNumber()); } this.j.a(this.i); } }