Cherish: applock: early return in setChecked if backing field has the same value

Signed-off-by: jhonboy121 <alfredmathew05@gmail.com>
Signed-off-by: Hưng Phan <phandinhhungvp2001@gmail.com>
This commit is contained in:
jhonboy121
2022-10-04 18:14:44 +05:30
committed by Hưng Phan
parent a410b4c687
commit 7e9ea36502
4 changed files with 5 additions and 2 deletions

View File

@@ -14,7 +14,7 @@
* limitations under the License. * limitations under the License.
*/ */
package com.cherish.settings.fragment package com.cherish.settings.fragments
import androidx.preference.Preference import androidx.preference.Preference

View File

@@ -63,6 +63,7 @@ class AppLockBiometricPreferenceController(
override fun isChecked() = isBiometricsAllowed override fun isChecked() = isBiometricsAllowed
override fun setChecked(checked: Boolean): Boolean { override fun setChecked(checked: Boolean): Boolean {
if (isBiometricsAllowed == checked) return false
isBiometricsAllowed = checked isBiometricsAllowed = checked
coroutineScope.launch(Dispatchers.Default) { coroutineScope.launch(Dispatchers.Default) {
appLockManager.setBiometricsAllowed(isBiometricsAllowed) appLockManager.setBiometricsAllowed(isBiometricsAllowed)

View File

@@ -59,6 +59,7 @@ class AppLockNotificationRedactionPC(
override fun isChecked() = shouldRedactNotification override fun isChecked() = shouldRedactNotification
override fun setChecked(checked: Boolean): Boolean { override fun setChecked(checked: Boolean): Boolean {
if (shouldRedactNotification == checked) return false
shouldRedactNotification = checked shouldRedactNotification = checked
coroutineScope.launch(Dispatchers.Default) { coroutineScope.launch(Dispatchers.Default) {
appLockManager.setShouldRedactNotification(packageName, checked) appLockManager.setShouldRedactNotification(packageName, checked)

View File

@@ -60,6 +60,7 @@ class AppLockPackageProtectionPC(
override fun isChecked() = isProtected override fun isChecked() = isProtected
override fun setChecked(checked: Boolean): Boolean { override fun setChecked(checked: Boolean): Boolean {
if (isProtected == checked) return false
isProtected = checked isProtected = checked
coroutineScope.launch(Dispatchers.Default) { coroutineScope.launch(Dispatchers.Default) {
if (isProtected) { if (isProtected) {