mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-24 14:05:40 +03:00
Fix glide
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
032a3cb930
commit
55d78401ad
4 changed files with 11 additions and 69 deletions
|
@ -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<RoomItem.RoomItemViewHolder>
|
|||
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<RoomItem.RoomItemViewHolder>
|
|||
.asBitmap()
|
||||
.skipMemoryCache(true)
|
||||
.load(glideUrl)
|
||||
.placeholder(holder.avatarImageViewInvisible.getDrawable())
|
||||
.circleCrop()
|
||||
.centerInside()
|
||||
.into(holder.avatarImageView);
|
||||
|
|
|
@ -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<UserItem.UserItemViewHolder>
|
|||
}
|
||||
|
||||
// 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<UserItem.UserItemViewHolder>
|
|||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.asBitmap()
|
||||
.skipMemoryCache(true)
|
||||
.placeholder(holder.avatarImageViewInvisible.getDrawable())
|
||||
.load(glideUrl)
|
||||
.circleCrop()
|
||||
.centerInside()
|
||||
|
|
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue