From c87641a9212a0852fe571b65c529140a77ab7a13 Mon Sep 17 00:00:00 2001 From: kauron Date: Sun, 19 Jul 2015 23:49:37 +0200 Subject: [PATCH] PowerDisplay: impact not showing and blank fields not hiding fixed --- .../kauron/dungeonmanager/PowerEditor.java | 4 +-- .../com/kauron/dungeonmanager/ShowPlayer.java | 25 ++++++++++++++----- app/src/main/res/layout/attack_display.xml | 2 +- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java b/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java index dad7161..0ca6642 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java +++ b/app/src/main/java/com/kauron/dungeonmanager/PowerEditor.java @@ -19,9 +19,9 @@ import com.nispok.snackbar.SnackbarManager; public class PowerEditor extends ActionBarActivity { private EditText [] edits = new EditText[6]; - private Spinner [] spinners = new Spinner[6]; + private Spinner [] spinners = new Spinner[5]; - private String[] strings = new String[5]; + private String[] strings = new String[6]; private int[] ints = new int[5]; private String originalName; diff --git a/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java b/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java index 0a51c09..bca5399 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java +++ b/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java @@ -590,8 +590,13 @@ public class ShowPlayer extends ActionBarActivity { ((TextView) dialog.findViewById(R.id.freqText)).setText(power.getFrequencyString()); else dialog.findViewById(R.id.freqText).setVisibility(View.GONE); - ((TextView) dialog.findViewById(R.id.keywordsText)).setText(power.getKeywords()); - ((TextView) dialog.findViewById(R.id.distanceText)).setText(String.valueOf(power.getDistance())); + if (!power.getKeywords().isEmpty()) + ((TextView) dialog.findViewById(R.id.keywordsText)).setText(power.getKeywords()); + else dialog.findViewById(R.id.keywordsText).setVisibility(View.GONE); + + if (!power.getDistance().isEmpty()) + ((TextView) dialog.findViewById(R.id.distanceText)).setText(power.getDistance()); + else dialog.findViewById(R.id.distanceText).setVisibility(View.GONE); if (!power.getObjective().isEmpty()) ((TextView) dialog.findViewById(R.id.objectiveText)).setText(power.getObjective()); @@ -603,10 +608,18 @@ public class ShowPlayer extends ActionBarActivity { ((TextView) dialog.findViewById(R.id.otherText)).setText(power.getOther()); - String[] attack = getResources().getStringArray(R.array.attack); - String[] defense = getResources().getStringArray(R.array.defense); - ((TextView) dialog.findViewById(R.id.impactText)).setText(attack[power.getAtk()] - + " " + getResources().getString(R.string.vs) + " " + defense[power.getDef()]); + if (power.getAtk() != 0) { + String[] attack = getResources().getStringArray(R.array.attack); + String[] defense; + String text = attack[power.getAtk()]; + if (power.getDef() != 0) { + defense = getResources().getStringArray(R.array.defense); + text += " " + getString(R.string.vs) + " " + defense[power.getDef()]; + } + ((TextView) dialog.findViewById(R.id.attackText)).setText(text); + } else { + dialog.findViewById(R.id.attackLayout).setVisibility(View.GONE); + } final Button useButton = (Button) dialog.findViewById(R.id.useButton); diff --git a/app/src/main/res/layout/attack_display.xml b/app/src/main/res/layout/attack_display.xml index 64d52fc..f2e3803 100644 --- a/app/src/main/res/layout/attack_display.xml +++ b/app/src/main/res/layout/attack_display.xml @@ -129,7 +129,7 @@ android:layout_height="wrap_content" android:textAppearance="?android:attr/textAppearanceSmall" tools:text="ConstituciĆ³n contra Reflejos" - android:id="@+id/impactText"/> + android:id="@+id/attackText"/>