1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2025-03-01 01:06:11 +00:00

Refactoring

This commit is contained in:
M66B 2024-08-04 15:22:23 +02:00
parent bf77f8cc91
commit 28a70479c5
2 changed files with 15 additions and 1 deletions

View file

@ -1387,7 +1387,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (account_color == 2 &&
!Objects.equals(ivBadge.getTag(), colorBackground)) {
ivBadge.setTag(colorBackground);
((GradientDrawable) ivBadge.getDrawable().mutate()).setColor(colorBackground);
Helper.setColor(ivBadge.getDrawable(), colorBackground);
}
ivBadge.setVisibility(account_color == 2 ? View.VISIBLE : View.GONE);

View file

@ -56,6 +56,10 @@ import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.net.Uri;
import android.opengl.EGL14;
import android.opengl.EGLConfig;
@ -1958,6 +1962,16 @@ public class Helper {
return fragment.getClass().getName() + ":result:" + getWho(fragment);
}
static void setColor(Drawable drawable, int color) {
drawable = drawable.mutate();
if (drawable instanceof ShapeDrawable)
((ShapeDrawable) drawable).getPaint().setColor(color);
else if (drawable instanceof GradientDrawable)
((GradientDrawable) drawable).setColor(color);
else if (drawable instanceof ColorDrawable)
((ColorDrawable) drawable).setColor(color);
}
static void clearViews(Object instance) {
try {
String cname = instance.getClass().getSimpleName();