Refactoring

pull/215/head
M66B 3 months ago
parent bf77f8cc91
commit 28a70479c5

@ -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);

@ -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();

Loading…
Cancel
Save