com.bumptech.glide.module.GlideModule Java Examples

The following examples show how to use com.bumptech.glide.module.GlideModule. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GlideReset.java    From glide-support with The Unlicense 6 votes vote down vote up
/** Mimics Glide.get with a specific set of modules */
public void replace(Iterable<Class<? extends GlideModule>> moduleClasses) {
	Glide originalGlide = null;
	if (Glide.isSetup()) {
		originalGlide = Glide.get(applicationContext);
		tearDown();
	}
	Log.d(TAG, "Setting up new Glide...");
	GlideBuilder builder = new GlideBuilder(applicationContext);
	List<GlideModule> modules = createModules(moduleClasses);
	Log.v(TAG, "using modules: " + modules);
	applyOptions(modules, builder);
	Glide.setup(builder);
	Glide newGlide = Glide.get(applicationContext);
	registerComponents(modules, newGlide);
	Log.i(TAG, "Glide has been replaced, original=" + originalGlide + ", new=" + newGlide);
}
 
Example #2
Source File: GlideReset.java    From glide-support with The Unlicense 5 votes vote down vote up
/** new ManifestParser(applicationContext).parse(); */
private List<GlideModule> createModules(Iterable<Class<? extends GlideModule>> moduleClasses) {
	List<GlideModule> modules = new ArrayList<>();
	for (Class<? extends GlideModule> moduleClass : moduleClasses) {
		try {
			modules.add(moduleClass.newInstance());
		} catch (Exception ex) {
			throw new IllegalArgumentException("Cannot create GlideModule: " + moduleClass, ex);
		}
	}
	return modules;
}
 
Example #3
Source File: IssueEntryClassScanner.java    From glide-support with The Unlicense 5 votes vote down vote up
@Override
protected boolean isTargetClass(Class<?> clazz) {
    return super.isTargetClass(clazz) || (isAccessible(clazz) && (
            GlideModule.class.isAssignableFrom(clazz)
            || AppGlideModule.class.isAssignableFrom(clazz)
            || LibraryGlideModule.class.isAssignableFrom(clazz)
    ));
}
 
Example #4
Source File: GlideReset.java    From glide-support with The Unlicense 5 votes vote down vote up
/** Mimics Glide.get with a specific set of modules */
public void replace(Iterable<Class<? extends GlideModule>> moduleClasses) {
	Glide originalGlide = null;
	if (isSetup()) {
		originalGlide = Glide.get(applicationContext);
		tearDown();
		AppGlideModule.modules = Collections.emptyList();
	}
	setup(moduleClasses);
	Glide newGlide = Glide.get(applicationContext);
	Log.i(TAG, "Glide has been replaced, original=" + originalGlide + ", new=" + newGlide);
}
 
Example #5
Source File: GlideReset.java    From glide-support with The Unlicense 5 votes vote down vote up
private void setup(Iterable<Class<? extends GlideModule>> moduleClasses) {
	Log.d(TAG, "Setting up new Glide...");
	GlideBuilder builder = new GlideBuilder();
	Collection<GlideModule> modules = createModules(moduleClasses);
	Log.v(TAG, "using modules: " + modules);
	AppGlideModule.modules = modules;
	Glide.init(applicationContext, builder);
}
 
Example #6
Source File: GlideReset.java    From glide-support with The Unlicense 5 votes vote down vote up
/** new ManifestParser(applicationContext).parse(); */
private Collection<GlideModule> createModules(Iterable<Class<? extends GlideModule>> moduleClasses) {
	Collection<GlideModule> modules = new ArrayList<>();
	for (Class<? extends GlideModule> moduleClass : moduleClasses) {
		try {
			modules.add(moduleClass.newInstance());
		} catch (Exception ex) {
			throw new IllegalArgumentException("Cannot create GlideModule: " + moduleClass, ex);
		}
	}
	return modules;
}
 
Example #7
Source File: IssueInfo.java    From glide-support with The Unlicense 4 votes vote down vote up
public IssueInfo(ClassNameSplitter clazz, List< Class<? extends GlideModule>> modules) {
	this.clazz = clazz;
	this.source = clazz.getHostPackageName();
	this.name = clazz.getPackageName();
	this.modules = modules;
}
 
Example #8
Source File: IssueInfo.java    From glide-support with The Unlicense 4 votes vote down vote up
public List<Class<? extends GlideModule>> getModules() {
	return modules;
}
 
Example #9
Source File: IssueEntryClassScanner.java    From glide-support with The Unlicense 4 votes vote down vote up
@Override
protected boolean isTargetClass(Class<?> clazz) {
	return super.isTargetClass(clazz)
			|| (isAccessible(clazz) && GlideModule.class.isAssignableFrom(clazz));
}
 
Example #10
Source File: GlideReset.java    From glide-support with The Unlicense 4 votes vote down vote up
private void registerComponents(Iterable<GlideModule> modules, Glide glide) {
	for (GlideModule module : modules) {
		module.registerComponents(applicationContext, glide);
	}
}
 
Example #11
Source File: GlideReset.java    From glide-support with The Unlicense 4 votes vote down vote up
private void applyOptions(Iterable<GlideModule> modules, GlideBuilder builder) {
	for (GlideModule module : modules) {
		module.applyOptions(applicationContext, builder);
	}
}