improve code scores

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-11-05 18:27:17 +01:00
parent ed7a762b4c
commit 61e0c88188
No known key found for this signature in database
GPG Key ID: 6CADC7E3523C308B
2 changed files with 7 additions and 5 deletions

View File

@ -101,6 +101,7 @@ import androidx.annotation.XmlRes;
import androidx.appcompat.widget.AppCompatDrawableManager; import androidx.appcompat.widget.AppCompatDrawableManager;
import androidx.appcompat.widget.SearchView; import androidx.appcompat.widget.SearchView;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import androidx.emoji.text.EmojiCompat; import androidx.emoji.text.EmojiCompat;
@ -160,7 +161,7 @@ public class DisplayUtils {
} }
public static Bitmap getRoundedBitmapFromVectorDrawableResource(Resources resources, int resource) { public static Bitmap getRoundedBitmapFromVectorDrawableResource(Resources resources, int resource) {
VectorDrawable vectorDrawable = (VectorDrawable) resources.getDrawable(resource); VectorDrawable vectorDrawable = (VectorDrawable) ResourcesCompat.getDrawable(resources, resource,null);
Bitmap bitmap = getBitmap(vectorDrawable); Bitmap bitmap = getBitmap(vectorDrawable);
new RoundPostprocessor(true).process(bitmap); new RoundPostprocessor(true).process(bitmap);
return bitmap; return bitmap;
@ -260,13 +261,14 @@ public class DisplayUtils {
} }
public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) { public static Drawable getTintedDrawable(Resources res, @DrawableRes int drawableResId, @ColorRes int colorResId) {
Drawable drawable = res.getDrawable(drawableResId); Drawable drawable = ResourcesCompat.getDrawable(res, drawableResId,null);;
int color = res.getColor(colorResId); int color = res.getColor(colorResId);
drawable.setTint(color); if (drawable != null) {
drawable.setTint(color);
}
return drawable; return drawable;
} }
public static Drawable getDrawableForMentionChipSpan(Context context, String id, CharSequence label, public static Drawable getDrawableForMentionChipSpan(Context context, String id, CharSequence label,
UserEntity conversationUser, String type, UserEntity conversationUser, String type,
@XmlRes int chipResource, @XmlRes int chipResource,