package p138.p145.p146.p151.p160.p163;

import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import java.util.List;
import p138.p139.p143.p144.C2803;
import p138.p145.p146.p151.C2848;
import p138.p145.p146.p151.InterfaceC2850;
import p138.p145.p146.p151.p154.InterfaceC2932;

/* JADX INFO: renamed from: ދ.ؠ.֏.ތ.ތ.ނ.ށ, reason: contains not printable characters */
/* JADX INFO: loaded from: classes.dex */
public class C3134 implements InterfaceC2850<Uri, Drawable> {

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public final Context f9366;

    public C3134(Context context) {
        this.f9366 = context.getApplicationContext();
    }

    /* JADX INFO: renamed from: ֏, reason: contains not printable characters */
    public InterfaceC2932 m5207(Uri uri) {
        Context contextCreatePackageContext;
        int identifier;
        String authority = uri.getAuthority();
        if (authority.equals(this.f9366.getPackageName())) {
            contextCreatePackageContext = this.f9366;
        } else {
            try {
                contextCreatePackageContext = this.f9366.createPackageContext(authority, 0);
            } catch (PackageManager.NameNotFoundException e) {
                if (!authority.contains(this.f9366.getPackageName())) {
                    throw new IllegalArgumentException(C2803.m4876("Failed to obtain context or unrecognized Uri format for: ", uri), e);
                }
                contextCreatePackageContext = this.f9366;
            }
        }
        List<String> pathSegments = uri.getPathSegments();
        if (pathSegments.size() == 2) {
            List<String> pathSegments2 = uri.getPathSegments();
            String authority2 = uri.getAuthority();
            String str = pathSegments2.get(0);
            String str2 = pathSegments2.get(1);
            identifier = contextCreatePackageContext.getResources().getIdentifier(str2, str, authority2);
            if (identifier == 0) {
                identifier = Resources.getSystem().getIdentifier(str2, str, "android");
            }
            if (identifier == 0) {
                throw new IllegalArgumentException(C2803.m4876("Failed to find resource id for: ", uri));
            }
        } else {
            if (pathSegments.size() != 1) {
                throw new IllegalArgumentException(C2803.m4876("Unrecognized Uri format: ", uri));
            }
            try {
                identifier = Integer.parseInt(uri.getPathSegments().get(0));
            } catch (NumberFormatException e2) {
                throw new IllegalArgumentException(C2803.m4876("Unrecognized Uri format: ", uri), e2);
            }
        }
        Drawable drawableM5206 = C3131.m5206(this.f9366, contextCreatePackageContext, identifier, null);
        if (drawableM5206 != null) {
            return new C3133(drawableM5206);
        }
        return null;
    }

    @Override // p138.p145.p146.p151.InterfaceC2850
    /* JADX INFO: renamed from: ֏ */
    public /* bridge */ /* synthetic */ InterfaceC2932<Drawable> mo4981(Uri uri, int i, int i2, C2848 c2848) {
        return m5207(uri);
    }

    @Override // p138.p145.p146.p151.InterfaceC2850
    /* JADX INFO: renamed from: ֏ */
    public boolean mo4982(Uri uri, C2848 c2848) {
        return uri.getScheme().equals("android.resource");
    }
}
