diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/RoomItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/RoomItem.java index cf4f77330..d9992108d 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/RoomItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/RoomItem.java @@ -31,8 +31,7 @@ import com.nextcloud.talk.api.helpers.api.ApiHelper; import com.nextcloud.talk.api.models.json.rooms.Room; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.persistence.entities.UserEntity; -import com.nextcloud.talk.utils.ColorUtils; -import com.nextcloud.talk.utils.GlideApp; +import com.nextcloud.talk.utils.glide.GlideApp; import java.util.List; @@ -111,9 +110,6 @@ public class RoomItem extends AbstractFlexibleItem case ROOM_TYPE_ONE_TO_ONE_CALL: holder.avatarImageView.setVisibility(View.VISIBLE); - holder.avatarImageViewInvisible.setTextAndColorSeed(String.valueOf(room.getDisplayName(). - toUpperCase().charAt(0)), ColorUtils.colorSeed); - if (!TextUtils.isEmpty(room.getName())) { String glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(), room.getName())).toString(); @@ -122,7 +118,6 @@ public class RoomItem extends AbstractFlexibleItem .asBitmap() .skipMemoryCache(true) .load(glideUrl) - .placeholder(holder.avatarImageViewInvisible.getDrawable()) .circleCrop() .centerInside() .into(holder.avatarImageView); diff --git a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java index 688369ee3..085cd3a86 100644 --- a/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java +++ b/app/src/main/java/com/nextcloud/talk/adapters/items/UserItem.java @@ -30,7 +30,7 @@ import com.nextcloud.talk.api.models.User; import com.nextcloud.talk.application.NextcloudTalkApplication; import com.nextcloud.talk.persistence.entities.UserEntity; import com.nextcloud.talk.utils.ColorUtils; -import com.nextcloud.talk.utils.GlideApp; +import com.nextcloud.talk.utils.glide.GlideApp; import java.util.List; @@ -94,7 +94,7 @@ public class UserItem extends AbstractFlexibleItem } // Awful hack - holder.avatarImageViewInvisible.setTextAndColorSeed(String.valueOf(user.getName(). + holder.avatarImageView.setTextAndColorSeed(String.valueOf(user.getName(). toUpperCase().charAt(0)), ColorUtils.colorSeed); @@ -104,7 +104,6 @@ public class UserItem extends AbstractFlexibleItem GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext()) .asBitmap() .skipMemoryCache(true) - .placeholder(holder.avatarImageViewInvisible.getDrawable()) .load(glideUrl) .circleCrop() .centerInside() diff --git a/app/src/main/java/com/nextcloud/talk/utils/CachingGlideModule.java b/app/src/main/java/com/nextcloud/talk/utils/CachingGlideModule.java deleted file mode 100644 index 22ac09d6d..000000000 --- a/app/src/main/java/com/nextcloud/talk/utils/CachingGlideModule.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Nextcloud Talk application - * - * @author Mario Danic - * Copyright (C) 2017 Mario Danic (mario@lovelyhq.com) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.nextcloud.talk.utils; - - -import android.content.Context; - -import com.bumptech.glide.Glide; -import com.bumptech.glide.GlideBuilder; -import com.bumptech.glide.Registry; -import com.bumptech.glide.annotation.GlideModule; -import com.bumptech.glide.integration.okhttp3.OkHttpUrlLoader; -import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory; -import com.bumptech.glide.load.model.GlideUrl; -import com.bumptech.glide.module.AppGlideModule; - -import java.io.InputStream; - -import javax.inject.Inject; - -import okhttp3.OkHttpClient; - -@GlideModule -public class CachingGlideModule extends AppGlideModule { - // 256 MB - private static final int IMAGE_CACHE_SIZE = 256 * 1024 * 1024; - - @Inject - OkHttpClient okHttpClient; - - @Override - public void registerComponents(Context context, Glide glide, Registry registry) { - registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient)); - } - - @Override - public void applyOptions(Context context, GlideBuilder builder) { - builder.setDiskCache(new InternalCacheDiskCacheFactory(context, IMAGE_CACHE_SIZE)); - } -} diff --git a/app/src/main/java/com/nextcloud/talk/utils/glide/CachingGlideModule.java b/app/src/main/java/com/nextcloud/talk/utils/glide/CachingGlideModule.java index ec5eed077..9784ed8e8 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/glide/CachingGlideModule.java +++ b/app/src/main/java/com/nextcloud/talk/utils/glide/CachingGlideModule.java @@ -32,11 +32,13 @@ import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory; import com.bumptech.glide.load.model.GlideUrl; import com.bumptech.glide.module.AppGlideModule; import com.nextcloud.talk.application.NextcloudTalkApplication; -import com.nextcloud.talk.utils.HttpClientUtils; import java.io.InputStream; +import javax.inject.Inject; + import autodagger.AutoInjector; +import okhttp3.OkHttpClient; @AutoInjector(NextcloudTalkApplication.class) @GlideModule @@ -44,10 +46,14 @@ public class CachingGlideModule extends AppGlideModule { // 256 MB private static final int IMAGE_CACHE_SIZE = 256 * 1024 * 1024; + @Inject + OkHttpClient okHttpClient; + @Override public void registerComponents(Context context, Glide glide, Registry registry) { + NextcloudTalkApplication.getSharedApplication().getComponentApplication().inject(this); registry.replace(GlideUrl.class, InputStream.class, - new OkHttpUrlLoader.Factory(HttpClientUtils.getOkHttpClient())); + new OkHttpUrlLoader.Factory(okHttpClient)); } @Override