From 84a50b82f022ed53663069e62ab9d25ed4e95907 Mon Sep 17 00:00:00 2001 From: serso Date: Thu, 12 Feb 2015 12:32:24 +0100 Subject: [PATCH] Lint warnings fixed --- .../android/calculator/CalculatorButton.java | 13 +++++++------ .../android/calculator/CalculatorReceiver.java | 2 +- .../calculator/onscreen/CalculatorOnscreenView.java | 4 ++-- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButton.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButton.java index 247a88d7..d9c0b3b5 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButton.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorButton.java @@ -23,6 +23,7 @@ package org.solovyev.android.calculator; import android.content.Context; +import android.util.SparseArray; import javax.annotation.Nonnull; import javax.annotation.Nullable; @@ -92,7 +93,7 @@ public enum CalculatorButton { private final String onLongClickText; @Nonnull - private static Map buttonsByIds = new HashMap(); + private static SparseArray buttonsByIds = new SparseArray<>(); CalculatorButton(int buttonId, @Nonnull CalculatorSpecialButton onClickButton, @Nullable CalculatorSpecialButton onLongClickButton) { this(buttonId, onClickButton.getActionCode(), onLongClickButton == null ? null : onLongClickButton.getActionCode()); @@ -113,14 +114,14 @@ public enum CalculatorButton { this(buttonId, onClickText, null); } - public void onLongClick(@Nonnull Context context) { + public void onLongClick() { Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onLongClickText); if (onLongClickText != null) { Locator.getInstance().getKeyboard().buttonPressed(onLongClickText); } } - public void onClick(@Nonnull Context context) { + public void onClick() { Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onClickText); Locator.getInstance().getKeyboard().buttonPressed(onClickText); } @@ -133,14 +134,14 @@ public enum CalculatorButton { } private static void initButtonsByIdsMap() { - if (buttonsByIds.isEmpty()) { + if (buttonsByIds.size() == 0) { // if not initialized final CalculatorButton[] calculatorButtons = values(); - final Map localButtonsByIds = new HashMap(calculatorButtons.length); + final SparseArray localButtonsByIds = new SparseArray<>(); for (CalculatorButton calculatorButton : calculatorButtons) { - localButtonsByIds.put(calculatorButton.getButtonId(), calculatorButton); + localButtonsByIds.append(calculatorButton.getButtonId(), calculatorButton); } buttonsByIds = localButtonsByIds; diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java index 17c019c8..4d3ba721 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorReceiver.java @@ -20,7 +20,7 @@ public final class CalculatorReceiver extends BroadcastReceiver { final CalculatorButton button = CalculatorButton.getById(buttonId); if (button != null) { - button.onClick(context); + button.onClick(); } } } diff --git a/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java b/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java index 00d40d77..c6e4940a 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/onscreen/CalculatorOnscreenView.java @@ -192,7 +192,7 @@ public class CalculatorOnscreenView { button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { - widgetButton.onClick(context); + widgetButton.onClick(); if (widgetButton == CalculatorButton.app) { minimize(); } @@ -201,7 +201,7 @@ public class CalculatorOnscreenView { button.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { - widgetButton.onLongClick(context); + widgetButton.onLongClick(); return true; } });