Search in sources :

Example 1 with MultiModelLoaderFactory

use of com.bumptech.glide.load.model.MultiModelLoaderFactory in project glide by bumptech.

the class MockModelLoader method mock.

@SuppressWarnings("unchecked")
public static <ModelT, DataT> void mock(final ModelT model, final DataT data) {
    Context context = InstrumentationRegistry.getTargetContext();
    Glide.get(context).getRegistry().replace((Class<ModelT>) model.getClass(), (Class<DataT>) data.getClass(), new ModelLoaderFactory<ModelT, DataT>() {

        @NonNull
        @Override
        public ModelLoader<ModelT, DataT> build(@NonNull MultiModelLoaderFactory multiFactory) {
            return new MockModelLoader<>(model, data);
        }

        @Override
        public void teardown() {
        // Do nothing.
        }
    });
}
Also used : Context(android.content.Context) ModelLoader(com.bumptech.glide.load.model.ModelLoader) NonNull(android.support.annotation.NonNull) MultiModelLoaderFactory(com.bumptech.glide.load.model.MultiModelLoaderFactory)

Aggregations

Context (android.content.Context)1 NonNull (android.support.annotation.NonNull)1 ModelLoader (com.bumptech.glide.load.model.ModelLoader)1 MultiModelLoaderFactory (com.bumptech.glide.load.model.MultiModelLoaderFactory)1