package com.zj.bumptech.glide.module; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import java.util.ArrayList; import java.util.List; public final class ManifestParser { private static final String GLIDE_MODULE_VALUE = "ZJGlideModule"; private final Context context; public ManifestParser(Context context2) { this.context = context2; } private static GlideModule parseModule(String str) { Object obj; Object obj2; try { try { Object newInstance = Class.forName(str).newInstance(); if (newInstance instanceof GlideModule) { return (GlideModule) newInstance; } throw new RuntimeException("Expected instanceof GlideModule, but found: " + newInstance); } catch (InstantiationException e) { throw new RuntimeException("Unable to instantiate GlideModule implementation for " + obj, e); } catch (IllegalAccessException e2) { throw new RuntimeException("Unable to instantiate GlideModule implementation for " + obj2, e2); } } catch (ClassNotFoundException e3) { throw new IllegalArgumentException("Unable to find GlideModule implementation", e3); } } public List<GlideModule> parse() { ArrayList arrayList = new ArrayList(); try { ApplicationInfo applicationInfo = this.context.getPackageManager().getApplicationInfo(this.context.getPackageName(), 128); if (applicationInfo.metaData != null) { for (String str : applicationInfo.metaData.keySet()) { if (GLIDE_MODULE_VALUE.equals(applicationInfo.metaData.get(str))) { arrayList.add(parseModule(str)); } } } return arrayList; } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException("Unable to find metadata to parse GlideModules", e); } } }