From d622dc773f9fc9c04bf6f84e9b53ee5df7744384 Mon Sep 17 00:00:00 2001 From: Anthony Calosa Date: Mon, 1 Mar 2021 17:50:44 +0800 Subject: [PATCH] [Android] enclosed check for FScrollPane drawOverlay --- .../src/forge/toolbox/FScrollPane.java | 56 ++++++++++--------- 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/forge-gui-mobile/src/forge/toolbox/FScrollPane.java b/forge-gui-mobile/src/forge/toolbox/FScrollPane.java index f590f67cecf..d05a88be084 100644 --- a/forge-gui-mobile/src/forge/toolbox/FScrollPane.java +++ b/forge-gui-mobile/src/forge/toolbox/FScrollPane.java @@ -155,32 +155,36 @@ public abstract class FScrollPane extends FContainer { @Override protected void drawOverlay(Graphics g) { - boolean isFieldZoneView = toString().contains("VField")||toString().contains("VZoneDisplay"); - //TODO: Consider other ways to indicate scroll potential that fade in and out based on input - //draw triangles indicating scroll potential - if (!FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ENABLE_MATCH_SCROLL_INDICATOR)) - return; - if (!isFieldZoneView) - return; - if (scrollLeft > 0) { - float x = INDICATOR_MARGIN; - float y = getHeight() / 2; - g.fillTriangle(INDICATOR_COLOR, x, y, x + INDICATOR_SIZE, y - INDICATOR_SIZE, x + INDICATOR_SIZE, y + INDICATOR_SIZE); - } - if (scrollLeft < getMaxScrollLeft()) { - float x = getWidth() - INDICATOR_MARGIN; - float y = getHeight() / 2; - g.fillTriangle(INDICATOR_COLOR, x, y, x - INDICATOR_SIZE, y - INDICATOR_SIZE, x - INDICATOR_SIZE, y + INDICATOR_SIZE); - } - if (scrollTop > 0) { - float x = getWidth() / 2; - float y = INDICATOR_MARGIN; - g.fillTriangle(INDICATOR_COLOR, x, y, x - INDICATOR_SIZE, y + INDICATOR_SIZE, x + INDICATOR_SIZE, y + INDICATOR_SIZE); - } - if (scrollTop < getMaxScrollTop()) { - float x = getWidth() / 2; - float y = getHeight() - INDICATOR_MARGIN; - g.fillTriangle(INDICATOR_COLOR, x, y, x - INDICATOR_SIZE, y - INDICATOR_SIZE, x + INDICATOR_SIZE, y - INDICATOR_SIZE); + try { + boolean isFieldZoneView = toString().contains("VField")||toString().contains("VZoneDisplay"); + //TODO: Consider other ways to indicate scroll potential that fade in and out based on input + //draw triangles indicating scroll potential + if (!FModel.getPreferences().getPrefBoolean(ForgePreferences.FPref.UI_ENABLE_MATCH_SCROLL_INDICATOR)) + return; + if (!isFieldZoneView) + return; + if (scrollLeft > 0) { + float x = INDICATOR_MARGIN; + float y = getHeight() / 2; + g.fillTriangle(INDICATOR_COLOR, x, y, x + INDICATOR_SIZE, y - INDICATOR_SIZE, x + INDICATOR_SIZE, y + INDICATOR_SIZE); + } + if (scrollLeft < getMaxScrollLeft()) { + float x = getWidth() - INDICATOR_MARGIN; + float y = getHeight() / 2; + g.fillTriangle(INDICATOR_COLOR, x, y, x - INDICATOR_SIZE, y - INDICATOR_SIZE, x - INDICATOR_SIZE, y + INDICATOR_SIZE); + } + if (scrollTop > 0) { + float x = getWidth() / 2; + float y = INDICATOR_MARGIN; + g.fillTriangle(INDICATOR_COLOR, x, y, x - INDICATOR_SIZE, y + INDICATOR_SIZE, x + INDICATOR_SIZE, y + INDICATOR_SIZE); + } + if (scrollTop < getMaxScrollTop()) { + float x = getWidth() / 2; + float y = getHeight() - INDICATOR_MARGIN; + g.fillTriangle(INDICATOR_COLOR, x, y, x - INDICATOR_SIZE, y - INDICATOR_SIZE, x + INDICATOR_SIZE, y - INDICATOR_SIZE); + } + } catch (Exception e) { + e.printStackTrace(); } }