Lint warnings fixed
This commit is contained in:
parent
9d99863752
commit
84a50b82f0
@ -23,6 +23,7 @@
|
|||||||
package org.solovyev.android.calculator;
|
package org.solovyev.android.calculator;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.util.SparseArray;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -92,7 +93,7 @@ public enum CalculatorButton {
|
|||||||
private final String onLongClickText;
|
private final String onLongClickText;
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
private static Map<Integer, CalculatorButton> buttonsByIds = new HashMap<Integer, CalculatorButton>();
|
private static SparseArray<CalculatorButton> buttonsByIds = new SparseArray<>();
|
||||||
|
|
||||||
CalculatorButton(int buttonId, @Nonnull CalculatorSpecialButton onClickButton, @Nullable CalculatorSpecialButton onLongClickButton) {
|
CalculatorButton(int buttonId, @Nonnull CalculatorSpecialButton onClickButton, @Nullable CalculatorSpecialButton onLongClickButton) {
|
||||||
this(buttonId, onClickButton.getActionCode(), onLongClickButton == null ? null : onLongClickButton.getActionCode());
|
this(buttonId, onClickButton.getActionCode(), onLongClickButton == null ? null : onLongClickButton.getActionCode());
|
||||||
@ -113,14 +114,14 @@ public enum CalculatorButton {
|
|||||||
this(buttonId, onClickText, null);
|
this(buttonId, onClickText, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onLongClick(@Nonnull Context context) {
|
public void onLongClick() {
|
||||||
Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onLongClickText);
|
Locator.getInstance().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onLongClickText);
|
||||||
if (onLongClickText != null) {
|
if (onLongClickText != null) {
|
||||||
Locator.getInstance().getKeyboard().buttonPressed(onLongClickText);
|
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().getNotifier().showDebugMessage("Calculator++ Widget", "Button pressed: " + onClickText);
|
||||||
Locator.getInstance().getKeyboard().buttonPressed(onClickText);
|
Locator.getInstance().getKeyboard().buttonPressed(onClickText);
|
||||||
}
|
}
|
||||||
@ -133,14 +134,14 @@ public enum CalculatorButton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void initButtonsByIdsMap() {
|
private static void initButtonsByIdsMap() {
|
||||||
if (buttonsByIds.isEmpty()) {
|
if (buttonsByIds.size() == 0) {
|
||||||
// if not initialized
|
// if not initialized
|
||||||
|
|
||||||
final CalculatorButton[] calculatorButtons = values();
|
final CalculatorButton[] calculatorButtons = values();
|
||||||
|
|
||||||
final Map<Integer, CalculatorButton> localButtonsByIds = new HashMap<Integer, CalculatorButton>(calculatorButtons.length);
|
final SparseArray<CalculatorButton> localButtonsByIds = new SparseArray<>();
|
||||||
for (CalculatorButton calculatorButton : calculatorButtons) {
|
for (CalculatorButton calculatorButton : calculatorButtons) {
|
||||||
localButtonsByIds.put(calculatorButton.getButtonId(), calculatorButton);
|
localButtonsByIds.append(calculatorButton.getButtonId(), calculatorButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
buttonsByIds = localButtonsByIds;
|
buttonsByIds = localButtonsByIds;
|
||||||
|
@ -20,7 +20,7 @@ public final class CalculatorReceiver extends BroadcastReceiver {
|
|||||||
|
|
||||||
final CalculatorButton button = CalculatorButton.getById(buttonId);
|
final CalculatorButton button = CalculatorButton.getById(buttonId);
|
||||||
if (button != null) {
|
if (button != null) {
|
||||||
button.onClick(context);
|
button.onClick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ public class CalculatorOnscreenView {
|
|||||||
button.setOnClickListener(new View.OnClickListener() {
|
button.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
widgetButton.onClick(context);
|
widgetButton.onClick();
|
||||||
if (widgetButton == CalculatorButton.app) {
|
if (widgetButton == CalculatorButton.app) {
|
||||||
minimize();
|
minimize();
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ public class CalculatorOnscreenView {
|
|||||||
button.setOnLongClickListener(new View.OnLongClickListener() {
|
button.setOnLongClickListener(new View.OnLongClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public boolean onLongClick(View v) {
|
public boolean onLongClick(View v) {
|
||||||
widgetButton.onLongClick(context);
|
widgetButton.onLongClick();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user