Java Code Examples for com.bumptech.glide.Glide#get()

The following examples show how to use com.bumptech.glide.Glide#get() . 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: GlideFilmstripManager.java    From Camera2 with Apache License 2.0 6 votes vote down vote up
public GlideFilmstripManager(Context context)
{
    Glide glide = Glide.get(context);
    BitmapEncoder bitmapEncoder = new BitmapEncoder(Bitmap.CompressFormat.JPEG,
            JPEG_COMPRESS_QUALITY);
    GifBitmapWrapperResourceEncoder drawableEncoder = new GifBitmapWrapperResourceEncoder(
            bitmapEncoder,
            new GifResourceEncoder(glide.getBitmapPool()));
    RequestManager request = Glide.with(context);

    mTinyImageBuilder = request
            .fromMediaStore()
            .asBitmap() // This prevents gifs from animating at tiny sizes.
            .transcode(new BitmapToGlideDrawableTranscoder(context), GlideDrawable.class)
            .fitCenter()
            .placeholder(DEFAULT_PLACEHOLDER_RESOURCE)
            .dontAnimate();

    mLargeImageBuilder = request
            .fromMediaStore()
            .encoder(drawableEncoder)
            .fitCenter()
            .placeholder(DEFAULT_PLACEHOLDER_RESOURCE)
            .dontAnimate();
}
 
Example 2
Source File: ThumbnailUtils.java    From Cirrus_depricated with GNU General Public License v2.0 6 votes vote down vote up
/**
 *
 * @param mContext context
 * @param mAccount account
 * @param target   image view target
 * @param resource fallback resource
 */
public static void processAvatar(final Context mContext, final Account mAccount, final ImageView target, final int resource) {
    try {
        final OwnCloudAccount ocAccount = new OwnCloudAccount(mAccount, mContext);

        final Glide avatar = Glide.get(mContext);
        avatar.with(mContext)
                .load(getAvatarURL(ocAccount))
                .placeholder(resource)
                .fallback(resource)
                .error(resource)
                .diskCacheStrategy(DiskCacheStrategy.NONE)
                .centerCrop()
                .transform(new CircleTransform(mContext))
                .into(target);
    } catch (com.synox.android.lib.common.accounts.AccountUtils.AccountNotFoundException e) {
        Log_OC.e("ThumbnailUtils", e.getMessage());
    }
}
 
Example 3
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 4
Source File: GlideX.java    From NClientV2 with Apache License 2.0 5 votes vote down vote up
@Nullable
public static Glide get(Context context) {
    try {
        return Glide.get(context);
    } catch (VerifyError | IllegalStateException ignore) {
        return null;
    }
}
 
Example 5
Source File: ImageCache.java    From nativescript-image-cache-it with Apache License 2.0 5 votes vote down vote up
public static void init(Context context) {
    if (manager == null) {
        manager = Glide.with(context);
    }
    if (glide == null) {
        glide = Glide.get(context);
    }

    if (executorService == null) {
        executorService = Executors.newSingleThreadExecutor();
    }
}
 
Example 6
Source File: ImageCache.java    From nativescript-image-cache-it with Apache License 2.0 5 votes vote down vote up
public static void init(Context context) {
    if (manager == null) {
        manager = Glide.with(context);
    }
    if (glide == null) {
        glide = Glide.get(context);
    }

    if (executorService == null) {
        executorService = Executors.newSingleThreadExecutor();
    }
}
 
Example 7
Source File: ImageView.java    From nativescript-image-cache-it with Apache License 2.0 5 votes vote down vote up
public static void clear(final Context context, final boolean memoryOnly) {
    final Glide glide = Glide.get(context);
    glide.clearMemory();
    if (!memoryOnly) {
        executor.submit(new Runnable() {
            @Override
            public void run() {
                glide.clearDiskCache();
            }
        });
    }
}
 
Example 8
Source File: ImageViewOld.java    From nativescript-image-cache-it with Apache License 2.0 5 votes vote down vote up
public static void clear(final Context context, final boolean memoryOnly) {
    final Glide glide = Glide.get(context);
    glide.clearMemory();
    if (!memoryOnly) {
        executor.execute(new Runnable() {
            @Override
            public void run() {
                glide.clearDiskCache();
            }
        });
    }
}
 
Example 9
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 10
Source File: LocalRepositoryModule.java    From Android-App-Architecture-MVVM-Databinding with Apache License 2.0 4 votes vote down vote up
@Provides
@Singleton
/* default */ static Glide provideGlide(@ApplicationContext final Context context) {
    return Glide.get(context);
}
 
Example 11
Source File: ThumbnailUtils.java    From Cirrus_depricated with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Init
 */
private static void init()
{
    mContext = getContext();
    thumbnail = Glide.get( mContext);
}