From 4957e9a84eab79434df7c191cdeb7801d18524e9 Mon Sep 17 00:00:00 2001 From: Naveen Date: Fri, 14 Oct 2022 22:29:59 +0530 Subject: [PATCH] Simplify code iterating through the views was really unnecessary --- .../draw/pro/activities/MainActivity.kt | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/MainActivity.kt index 30bd5c0..06c8521 100644 --- a/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/draw/pro/activities/MainActivity.kt @@ -12,6 +12,7 @@ import android.os.Bundle import android.provider.MediaStore import android.view.WindowManager import android.webkit.MimeTypeMap +import android.widget.ImageView import android.widget.SeekBar import android.widget.Toast import androidx.print.PrintHelper @@ -409,18 +410,16 @@ class MainActivity : SimpleActivity(), CanvasListener { private fun updateButtonStates() { hideBrushSettings(isEyeDropperOn || isBucketFillOn) - arrayOf( - eraser to isEraserOn, - eye_dropper to isEyeDropperOn, - bucket_fill to isBucketFillOn - ).forEach { - val view = it.first - val enabled = it.second - if (enabled) { - view.applyColorFilter(getProperPrimaryColor()) - } else { - view.applyColorFilter(config.canvasBackgroundColor.getContrastColor()) - } + updateButtonColor(eraser, isEraserOn) + updateButtonColor(eye_dropper, isEyeDropperOn) + updateButtonColor(bucket_fill, isBucketFillOn) + } + + private fun updateButtonColor(view: ImageView, enabled: Boolean) { + if (enabled) { + view.applyColorFilter(getProperPrimaryColor()) + } else { + view.applyColorFilter(config.canvasBackgroundColor.getContrastColor()) } }