2015-03-31 22:44:41 +00:00
|
|
|
package org.thoughtcrime.securesms.mms;
|
|
|
|
|
|
|
|
import android.content.Context;
|
2017-10-12 00:12:46 +00:00
|
|
|
import android.util.Log;
|
2015-03-31 22:44:41 +00:00
|
|
|
|
|
|
|
import com.bumptech.glide.Glide;
|
|
|
|
import com.bumptech.glide.GlideBuilder;
|
2017-10-12 00:12:46 +00:00
|
|
|
import com.bumptech.glide.Registry;
|
|
|
|
import com.bumptech.glide.annotation.GlideModule;
|
2015-03-31 22:44:41 +00:00
|
|
|
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;
|
2017-10-12 00:12:46 +00:00
|
|
|
import com.bumptech.glide.module.AppGlideModule;
|
2015-03-31 22:44:41 +00:00
|
|
|
|
2017-10-16 20:11:42 +00:00
|
|
|
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
|
2017-10-12 00:47:12 +00:00
|
|
|
import org.thoughtcrime.securesms.giph.model.GiphyPaddedUrl;
|
2017-10-16 20:11:42 +00:00
|
|
|
import org.thoughtcrime.securesms.glide.ContactPhotoLoader;
|
2017-10-12 00:47:12 +00:00
|
|
|
import org.thoughtcrime.securesms.glide.GiphyPaddedUrlLoader;
|
2016-10-17 02:05:07 +00:00
|
|
|
import org.thoughtcrime.securesms.glide.OkHttpUrlLoader;
|
2015-07-25 00:07:33 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.AttachmentStreamUriLoader.AttachmentModel;
|
2015-03-31 22:44:41 +00:00
|
|
|
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
|
|
|
|
|
|
|
|
import java.io.InputStream;
|
|
|
|
|
2017-10-12 00:12:46 +00:00
|
|
|
@GlideModule
|
|
|
|
public class SignalGlideModule extends AppGlideModule {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isManifestParsingEnabled() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-03-31 22:44:41 +00:00
|
|
|
@Override
|
|
|
|
public void applyOptions(Context context, GlideBuilder builder) {
|
2017-10-12 00:12:46 +00:00
|
|
|
builder.setLogLevel(Log.ERROR);
|
2016-10-17 02:05:07 +00:00
|
|
|
// builder.setDiskCache(new NoopDiskCacheFactory());
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2017-10-12 00:12:46 +00:00
|
|
|
public void registerComponents(Context context, Glide glide, Registry registry) {
|
2017-10-16 20:11:42 +00:00
|
|
|
registry.append(ContactPhoto.class, InputStream.class, new ContactPhotoLoader.Factory(context));
|
2017-10-12 00:12:46 +00:00
|
|
|
registry.append(DecryptableUri.class, InputStream.class, new DecryptableStreamUriLoader.Factory(context));
|
|
|
|
registry.append(AttachmentModel.class, InputStream.class, new AttachmentStreamUriLoader.Factory());
|
2017-10-12 00:47:12 +00:00
|
|
|
registry.append(GiphyPaddedUrl.class, InputStream.class, new GiphyPaddedUrlLoader.Factory());
|
2017-10-12 00:12:46 +00:00
|
|
|
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory());
|
2015-03-31 22:44:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public static class NoopDiskCacheFactory implements DiskCache.Factory {
|
|
|
|
@Override
|
|
|
|
public DiskCache build() {
|
|
|
|
return new DiskCacheAdapter();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|