session-android/src/org/thoughtcrime/securesms/mms/TextSecureGlideModule.java

40 lines
1.5 KiB
Java
Raw Normal View History

package org.thoughtcrime.securesms.mms;
import android.content.Context;
import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.cache.DiskCache;
import com.bumptech.glide.load.engine.cache.DiskCacheAdapter;
2016-10-17 02:05:07 +00:00
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.GlideModule;
2016-10-17 02:05:07 +00:00
import org.thoughtcrime.securesms.glide.OkHttpUrlLoader;
import org.thoughtcrime.securesms.mms.AttachmentStreamUriLoader.AttachmentModel;
import org.thoughtcrime.securesms.mms.ContactPhotoUriLoader.ContactPhotoUri;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import java.io.InputStream;
public class TextSecureGlideModule implements GlideModule {
@Override
public void applyOptions(Context context, GlideBuilder builder) {
2016-10-17 02:05:07 +00:00
// builder.setDiskCache(new NoopDiskCacheFactory());
}
@Override
public void registerComponents(Context context, Glide glide) {
glide.register(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory());
glide.register(ContactPhotoUri.class, InputStream.class, new ContactPhotoUriLoader.Factory());
glide.register(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
2016-10-17 02:05:07 +00:00
glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
}
public static class NoopDiskCacheFactory implements DiskCache.Factory {
@Override
public DiskCache build() {
return new DiskCacheAdapter();
}
}
}