Replace drawer feeds icons by their favicon

This commit is contained in:
Shinokuni 2019-05-23 22:32:50 +02:00
parent 3efb023d56
commit c4d00fe2e1
2 changed files with 25 additions and 4 deletions

View File

@ -40,10 +40,10 @@ dependencies {
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation "com.github.bumptech.glide:okhttp3-integration:4.8.0"
implementation("com.github.bumptech.glide:recyclerview-integration:4.8.0") {
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
implementation "com.github.bumptech.glide:okhttp3-integration:4.9.0"
implementation("com.github.bumptech.glide:recyclerview-integration:4.9.0") {
// Excludes the support library because it's already included by Glide.
transitive = false
}

View File

@ -1,10 +1,16 @@
package com.readrops.app.utils;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.widget.Toolbar;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.mikepenz.materialdrawer.AccountHeader;
import com.mikepenz.materialdrawer.AccountHeaderBuilder;
import com.mikepenz.materialdrawer.Drawer;
@ -94,6 +100,21 @@ public class DrawerManager {
.withIcon(color != 0 ? drawableWithColor(color) : drawableWithColor(activity.getResources().getColor(R.color.colorPrimary)))
.withIdentifier(feed.getId());
Glide.with(activity)
.load(feed.getIconUrl())
.into(new CustomTarget<Drawable>() {
@Override
public void onResourceReady(@NonNull Drawable resource, @Nullable Transition<? super Drawable> transition) {
secondaryDrawerItem.withIcon(resource);
}
@Override
public void onLoadCleared(@Nullable Drawable placeholder) {
}
});
secondaryDrawerItems.add(secondaryDrawerItem);
}