Skip to content

Commit

Permalink
Don't use Glide to load drawable resources
Browse files Browse the repository at this point in the history
Loading drawables using Glide while the size of the ImageView
is not known yet appears to result in a blurry mess.
  • Loading branch information
alexbakker committed Mar 24, 2024
1 parent f9f37d3 commit 9815e51
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
import android.os.Build;
import android.widget.ImageView;

import androidx.annotation.DrawableRes;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RawRes;

import com.amulyakhare.textdrawable.TextDrawable;
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
Expand Down Expand Up @@ -38,21 +36,6 @@ public static void loadIcon(RequestManager rm, IconPack.Icon icon, ImageView tar
loadIconFile(rm, icon.getFile(), icon.getIconType(), targetView);
}

public static void loadResource(RequestManager rm, @RawRes @DrawableRes @Nullable Integer resourceId, ImageView targetView) {
loadResource(rm, resourceId, null, targetView);
}

public static void loadResource(RequestManager rm, @RawRes @DrawableRes @Nullable Integer resourceId, @Nullable Integer tint, ImageView targetView) {
setCommonOptions(rm.load(resourceId), null)
.listener(new ViewReadyListener<>(view -> {
if (tint != null) {
view.setColorFilter(tint);
}
setLayerType(targetView, IconType.INVALID);
}))
.into(targetView);
}

public static void loadEntryIcon(RequestManager rm, VaultEntry entry, ImageView targetView) {
if (entry.hasIcon()) {
setCommonOptions(rm.load(entry.getIcon()), entry.getIcon().getType()).into(targetView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ private void setNewIcon() {
if (_entry.getNewIcon() != null) {
GlideHelper.loadIcon(Glide.with(_view.getContext()), _entry.getNewIcon(), _newIcon);
} else {
GlideHelper.loadResource(Glide.with(_view.getContext()), R.drawable.ic_unselected, _newIcon);
Glide.with(_view.getContext()).clear(_newIcon);
_newIcon.setImageResource(R.drawable.ic_unselected);
}

_btnReset.setVisibility(_entry.getNewIcon() != null ? View.VISIBLE : View.INVISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public void setData(IconPack.Icon icon) {

public void loadIcon(Context context) {
if (_isCustom) {
Glide.with(context).clear(_imageView);
int tint = MaterialColors.getColor(itemView, com.google.android.material.R.attr.colorOnSurfaceVariant);
GlideHelper.loadResource(Glide.with(context), R.drawable.ic_outline_add_24, tint, _imageView);
_imageView.setColorFilter(tint);
_imageView.setImageResource(R.drawable.ic_outline_add_24);
} else {
GlideHelper.loadIconFile(Glide.with(context), _iconFile, _iconType, _imageView);
}
Expand Down

0 comments on commit 9815e51

Please sign in to comment.