From 915b8d371a7df3c885d1e4b44edafd85d5e3007f Mon Sep 17 00:00:00 2001 From: oSumAtrIX Date: Sat, 7 Jan 2023 11:24:07 +0100 Subject: [PATCH] refactor: early return in `saveValue` Signed-off-by: oSumAtrIX --- .../revanced/tiktok/settings/SettingsEnum.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java index f732494f..a114b429 100644 --- a/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java +++ b/app/src/main/java/app/revanced/tiktok/settings/SettingsEnum.java @@ -103,16 +103,17 @@ public enum SettingsEnum { public void saveValue(Object newValue) { Context context = ReVancedUtils.getAppContext(); - if (context != null) { - if (returnType == ReturnType.BOOLEAN) { - SharedPrefHelper.saveBoolean(context, sharedPref, path, (Boolean) newValue); - } else { - SharedPrefHelper.saveString(context, sharedPref, path, newValue + ""); - } - value = newValue; - } else { + if (context == null) { LogHelper.printException(SettingsEnum.class, "Context on SaveValue is null!"); + return; } + + if (returnType == ReturnType.BOOLEAN) { + SharedPrefHelper.saveBoolean(context, sharedPref, path, (Boolean) newValue); + } else { + SharedPrefHelper.saveString(context, sharedPref, path, newValue + ""); + } + value = newValue; } public int getInt() {