Close TypedArray

This commit is contained in:
MrLetsplay 2023-09-21 21:43:52 +02:00
parent 7be7e0e11e
commit 9d822b2725
Signed by: mr
SSH Key Fingerprint: SHA256:92jBH80vpXyaZHjaIl47pjRq+Yt7XGTArqQg1V7hSqg
2 changed files with 14 additions and 6 deletions

View File

@ -42,9 +42,13 @@ public class GroupListItem extends RecyclerView.ViewHolder {
if(selected) { if(selected) {
TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 }); TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 });
try {
int color = array.getColor(0, 0xFFFF00FF); int color = array.getColor(0, 0xFFFF00FF);
color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color)); color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color));
binding.menuItemBackground.setBackground(new ColorDrawable(color)); binding.menuItemBackground.setBackground(new ColorDrawable(color));
} finally {
array.close();
}
}else { }else {
binding.menuItemBackground.setBackground(null); binding.menuItemBackground.setBackground(null);
} }

View File

@ -55,9 +55,13 @@ public class OTPListItem extends RecyclerView.ViewHolder {
if(selected) { if(selected) {
TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 }); TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 });
try {
int color = array.getColor(0, 0xFFFF00FF); int color = array.getColor(0, 0xFFFF00FF);
color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color)); color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color));
binding.otpCodeBackground.setBackground(new ColorDrawable(color)); binding.otpCodeBackground.setBackground(new ColorDrawable(color));
} finally {
array.close();
}
}else { }else {
binding.otpCodeBackground.setBackground(null); binding.otpCodeBackground.setBackground(null);
} }