From f203ae033af04fddc57a4f081fb9eb58fefbbd2c Mon Sep 17 00:00:00 2001 From: Julie Raymond Date: Sat, 18 Jul 2026 19:01:32 +0200 Subject: [PATCH] refactor: clean code improvement (Magic Numbers, Yoda Conditions) --- .../git/amarradi/leafpad/adapter/CategoryAdapter.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/com/git/amarradi/leafpad/adapter/CategoryAdapter.java b/app/src/main/java/com/git/amarradi/leafpad/adapter/CategoryAdapter.java index e4d216cd..f3f1db87 100644 --- a/app/src/main/java/com/git/amarradi/leafpad/adapter/CategoryAdapter.java +++ b/app/src/main/java/com/git/amarradi/leafpad/adapter/CategoryAdapter.java @@ -1,4 +1,4 @@ -package com.git.amarradi.leafpad.adapter; +private static final int STROKE_WIDTH = ColorUtilsHelper.dpToPx(card.getContext(), 2);package com.git.amarradi.leafpad.adapter; import android.view.LayoutInflater; import android.view.View; @@ -54,7 +54,7 @@ public void setCategories(List categories) { public void setSelectedCategoryIds(List ids) { selectedCategoryIds.clear(); - if (ids != null) { + if (null != ids) { selectedCategoryIds.addAll(ids); } notifyDataSetChanged(); @@ -110,7 +110,7 @@ public void onBindViewHolder(@NonNull CategoryViewHolder holder, int position) { holder.editButton.setOnClickListener(v -> { - if (listener != null) { + if (null != listener) { listener.onEditCategory(category); } }); @@ -129,13 +129,13 @@ private void applyCategoryColors( ImageButton btnDelete, CategoryEntity category ) { - if (category == null) return; + if (null == category) return; int baseColor = ColorUtilsHelper.parseCategoryColor(category.colorHex); int bgColor = ColorUtilsHelper.getCategoryBackgroundColor(baseColor); - card.setStrokeWidth(ColorUtilsHelper.dpToPx(card.getContext(), 2)); + card.setStrokeWidth(STROKE_WIDTH); card.setStrokeColor(baseColor); card.setCardBackgroundColor(bgColor);