From 9d822b2725ce24dfcc20c870f09e3ee938f3247e Mon Sep 17 00:00:00 2001 From: MrLetsplay Date: Thu, 21 Sep 2023 21:43:52 +0200 Subject: [PATCH] Close TypedArray --- .../cringe_authenticator/grouplist/GroupListItem.java | 10 +++++++--- .../cringe_authenticator/otplist/OTPListItem.java | 10 +++++++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/grouplist/GroupListItem.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/grouplist/GroupListItem.java index a13ae7c..777e2dc 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/grouplist/GroupListItem.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/grouplist/GroupListItem.java @@ -42,9 +42,13 @@ public class GroupListItem extends RecyclerView.ViewHolder { if(selected) { TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 }); - int color = array.getColor(0, 0xFFFF00FF); - color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color)); - binding.menuItemBackground.setBackground(new ColorDrawable(color)); + try { + int color = array.getColor(0, 0xFFFF00FF); + color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color)); + binding.menuItemBackground.setBackground(new ColorDrawable(color)); + } finally { + array.close(); + } }else { binding.menuItemBackground.setBackground(null); } diff --git a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java index fc40ed6..5062641 100644 --- a/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java +++ b/app/src/main/java/com/cringe_studios/cringe_authenticator/otplist/OTPListItem.java @@ -55,9 +55,13 @@ public class OTPListItem extends RecyclerView.ViewHolder { if(selected) { TypedArray array = binding.getRoot().getContext().getTheme().obtainStyledAttributes(new int[] { R.attr.colorTheme1 }); - int color = array.getColor(0, 0xFFFF00FF); - color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color)); - binding.otpCodeBackground.setBackground(new ColorDrawable(color)); + try { + int color = array.getColor(0, 0xFFFF00FF); + color = Color.argb(0x55, Color.red(color), Color.green(color), Color.blue(color)); + binding.otpCodeBackground.setBackground(new ColorDrawable(color)); + } finally { + array.close(); + } }else { binding.otpCodeBackground.setBackground(null); }