mirror of
https://github.com/beemdevelopment/Aegis.git
synced 2025-04-20 13:59:14 +00:00
Merge pull request #1323 from alexbakker/glide-no-res
Don't use Glide to load drawable resources
This commit is contained in:
commit
49a2b5d34d
3 changed files with 5 additions and 19 deletions
|
@ -4,10 +4,8 @@ import android.graphics.drawable.Drawable;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.DrawableRes;
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.annotation.RawRes;
|
|
||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
|
import com.beemdevelopment.aegis.helpers.TextDrawableHelper;
|
||||||
|
@ -38,21 +36,6 @@ public class GlideHelper {
|
||||||
loadIconFile(rm, icon.getFile(), icon.getIconType(), targetView);
|
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) {
|
public static void loadEntryIcon(RequestManager rm, VaultEntry entry, ImageView targetView) {
|
||||||
if (entry.hasIcon()) {
|
if (entry.hasIcon()) {
|
||||||
setCommonOptions(rm.load(entry.getIcon()), entry.getIcon().getType()).into(targetView);
|
setCommonOptions(rm.load(entry.getIcon()), entry.getIcon().getType()).into(targetView);
|
||||||
|
|
|
@ -47,7 +47,8 @@ public class AssignIconHolder extends RecyclerView.ViewHolder implements AssignI
|
||||||
if (_entry.getNewIcon() != null) {
|
if (_entry.getNewIcon() != null) {
|
||||||
GlideHelper.loadIcon(Glide.with(_view.getContext()), _entry.getNewIcon(), _newIcon);
|
GlideHelper.loadIcon(Glide.with(_view.getContext()), _entry.getNewIcon(), _newIcon);
|
||||||
} else {
|
} 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);
|
_btnReset.setVisibility(_entry.getNewIcon() != null ? View.VISIBLE : View.INVISIBLE);
|
||||||
|
|
|
@ -39,8 +39,10 @@ public class IconHolder extends RecyclerView.ViewHolder {
|
||||||
|
|
||||||
public void loadIcon(Context context) {
|
public void loadIcon(Context context) {
|
||||||
if (_isCustom) {
|
if (_isCustom) {
|
||||||
|
Glide.with(context).clear(_imageView);
|
||||||
int tint = MaterialColors.getColor(itemView, com.google.android.material.R.attr.colorOnSurfaceVariant);
|
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 {
|
} else {
|
||||||
GlideHelper.loadIconFile(Glide.with(context), _iconFile, _iconType, _imageView);
|
GlideHelper.loadIconFile(Glide.with(context), _iconFile, _iconType, _imageView);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue