mirror of
https://github.com/nextcloud/talk-android.git
synced 2024-11-21 20:45:29 +03:00
Simplify Glide
Signed-off-by: Mario Danic <mario@lovelyhq.com>
This commit is contained in:
parent
4f166c1dc6
commit
41a6201097
4 changed files with 10 additions and 31 deletions
|
@ -26,7 +26,6 @@ import android.view.View;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.load.model.LazyHeaders;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.api.helpers.api.ApiHelper;
|
||||
import com.nextcloud.talk.api.models.json.rooms.Room;
|
||||
|
@ -116,14 +115,8 @@ public class RoomItem extends AbstractFlexibleItem<RoomItem.RoomItemViewHolder>
|
|||
toUpperCase().charAt(0)), ColorUtils.colorSeed);
|
||||
|
||||
if (!TextUtils.isEmpty(room.getName())) {
|
||||
GlideUrl glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
room.getName()), new LazyHeaders.Builder()
|
||||
.addHeader("OCS-APIRequest", "true")
|
||||
.addHeader("User-Agent", ApiHelper.getUserAgent())
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("Authorization", () ->
|
||||
ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()))
|
||||
.build());
|
||||
String glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
room.getName())).toString();
|
||||
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.asBitmap()
|
||||
|
|
|
@ -24,7 +24,6 @@ import android.view.View;
|
|||
import android.widget.TextView;
|
||||
|
||||
import com.bumptech.glide.load.model.GlideUrl;
|
||||
import com.bumptech.glide.load.model.LazyHeaders;
|
||||
import com.nextcloud.talk.R;
|
||||
import com.nextcloud.talk.api.helpers.api.ApiHelper;
|
||||
import com.nextcloud.talk.api.models.User;
|
||||
|
@ -98,14 +97,9 @@ public class UserItem extends AbstractFlexibleItem<UserItem.UserItemViewHolder>
|
|||
holder.avatarImageViewInvisible.setTextAndColorSeed(String.valueOf(user.getName().
|
||||
toUpperCase().charAt(0)), ColorUtils.colorSeed);
|
||||
|
||||
GlideUrl glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
user.getUserId()), new LazyHeaders.Builder()
|
||||
.addHeader("OCS-APIRequest", "true")
|
||||
.addHeader("User-Agent", ApiHelper.getUserAgent())
|
||||
.addHeader("Accept", "*/*")
|
||||
.addHeader("Authorization", () ->
|
||||
ApiHelper.getCredentials(userEntity.getUsername(), userEntity.getToken()))
|
||||
.build());
|
||||
|
||||
String glideUrl = new GlideUrl(ApiHelper.getUrlForAvatarWithName(userEntity.getBaseUrl(),
|
||||
user.getUserId())).toString();
|
||||
|
||||
GlideApp.with(NextcloudTalkApplication.getSharedApplication().getApplicationContext())
|
||||
.asBitmap()
|
||||
|
|
|
@ -161,11 +161,6 @@ public interface NcApi {
|
|||
@GET
|
||||
Observable<Integer> pullSignalingMessages(@Header("Authorization") String authorization, @Url String url);
|
||||
|
||||
/*
|
||||
Server URL is: baseUrl + /index.php/avatar/userId/128
|
||||
Avatar OkHttp
|
||||
*/
|
||||
|
||||
/*
|
||||
QueryMap items are as follows:
|
||||
- "format" : "json"
|
||||
|
|
|
@ -31,26 +31,23 @@ 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 com.nextcloud.talk.application.NextcloudTalkApplication;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import okhttp3.Cache;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import okhttp3.OkHttpClient;
|
||||
|
||||
@GlideModule
|
||||
public class CachingGlideModule extends AppGlideModule {
|
||||
// 128 MB
|
||||
private static final int OK_HTTP_CLIENT_CACHE = 128 * 1024 * 1024;
|
||||
// 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) {
|
||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
httpClient.cache(new Cache(NextcloudTalkApplication.getSharedApplication().getCacheDir(),
|
||||
OK_HTTP_CLIENT_CACHE));
|
||||
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(httpClient.build()));
|
||||
registry.replace(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(okHttpClient));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue