diff --git a/app/src/main/java/com/kauron/dungeonmanager/PowerAdapter.java b/app/src/main/java/com/kauron/dungeonmanager/PowerAdapter.java index bf19ab7..ea17d66 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/PowerAdapter.java +++ b/app/src/main/java/com/kauron/dungeonmanager/PowerAdapter.java @@ -37,14 +37,10 @@ class PowerAdapter extends ArrayAdapter { mView.getBackground().setAlpha(0); int black = getContext().getResources().getColor(R.color.black); - name .setTextColor(black); - keywords .setTextColor(black); - frequency .setTextColor(black); - range .setTextColor(black); - - //name.setPaintFlags(name.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG); - } else { - mView.getBackground().setAlpha((position % 2) * 50 + 205); + name .setTextColor ( black ) ; + keywords .setTextColor ( black ) ; + frequency .setTextColor ( black ) ; + range .setTextColor ( black ) ; } } return mView; diff --git a/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java b/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java index 4c81510..2536a35 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java +++ b/app/src/main/java/com/kauron/dungeonmanager/ShowPlayer.java @@ -23,6 +23,7 @@ import android.widget.AdapterView; import android.widget.Button; import android.widget.EditText; import android.widget.ListView; +import android.widget.NumberPicker; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast; @@ -370,9 +371,11 @@ public class ShowPlayer extends ActionBarActivity { alert.setTitle(R.string.suffer_damage); // Set an EditText view to get user input - final EditText input = new EditText(this); - input.setInputType(InputType.TYPE_CLASS_NUMBER); - input.setHint(R.string.suffer_damage_hint); + final NumberPicker input = new NumberPicker (this); + input.setMinValue(0); + input.setMaxValue(player.getMaxHp() * 3); + input.setValue(0); + input.setWrapSelectorWheel(false); alert.setView(input); @@ -381,37 +384,32 @@ public class ShowPlayer extends ActionBarActivity { alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { - try { - final int undoPreviousValue = player.getHp(); - int damage = Integer.parseInt(input.getText().toString()); - player.losePg(damage); - SnackbarManager.show( - Snackbar.with(context).text(String.format(getString(R.string.lost_hp), damage)) - .actionLabel(R.string.action_undo) // action button label - .actionListener(new ActionClickListener() { - @Override - public void onActionClicked(Snackbar snackbar) { - SnackbarManager.show( - Snackbar - .with(activity) - .text(R.string.restored) - .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) - ); - player.setHp(undoPreviousValue); - p.edit().putInt("pg", player.getHp()).apply(); - hpUpdate(); - invalidateOptionsMenu(); - } - }) - .actionColor(getResources().getColor(R.color.yellow)) - .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) - ,activity); // action button's - p.edit().putInt("pg", player.getHp()).apply(); - hpUpdate(); - invalidateOptionsMenu(); - } catch (Exception e) { - Toast.makeText(getApplicationContext(), "There was an error", Toast.LENGTH_LONG).show(); - } + final int undoPreviousValue = player.getHp(); + player.losePg(input.getValue()); + SnackbarManager.show( + Snackbar.with(context).text(String.format(getString(R.string.lost_hp), input.getValue())) + .actionLabel(R.string.action_undo) // action button label + .actionListener(new ActionClickListener() { + @Override + public void onActionClicked(Snackbar snackbar) { + SnackbarManager.show( + Snackbar + .with(activity) + .text(R.string.restored) + .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) + ); + player.setHp(undoPreviousValue); + p.edit().putInt("pg", player.getHp()).apply(); + hpUpdate(); + invalidateOptionsMenu(); + } + }) + .actionColor(getResources().getColor(R.color.yellow)) + .duration(Snackbar.SnackbarDuration.LENGTH_INDEFINITE) + ,activity); // action button's + p.edit().putInt("pg", player.getHp()).apply(); + hpUpdate(); + invalidateOptionsMenu(); } }); diff --git a/app/src/main/java/com/kauron/dungeonmanager/Welcome.java b/app/src/main/java/com/kauron/dungeonmanager/Welcome.java index 96cd328..af9914c 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Welcome.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Welcome.java @@ -4,8 +4,8 @@ import android.app.AlertDialog; import android.content.DialogInterface; import android.content.Intent; import android.content.SharedPreferences; -import android.support.v7.app.ActionBarActivity; import android.os.Bundle; +import android.support.v7.app.ActionBarActivity; import android.support.v7.widget.Toolbar; import android.util.Log; import android.view.Menu; @@ -156,20 +156,23 @@ public class Welcome extends ActionBarActivity { }), activity ); - } else if(which==1) { - //TODO: edit the player - /**TEMP*/ - Toast.makeText( - activity, "Editor not implemented yet", Toast.LENGTH_LONG) - .show(); - } else { - //TODO: export as files - /**TEMP*/ - Toast.makeText( - activity, "Exporting feature not implemented yet", Toast.LENGTH_LONG) - .show(); + } else if(which==1) { + //TODO: edit the player + /**TEMP*/ + Toast.makeText( + activity, "Editor not implemented yet", Toast.LENGTH_LONG) + .show(); + } else { + //TODO: export as files + /**TEMP*/ + startActivity(new Intent( + getApplicationContext(), TabsViewPagerFragmentActivity.class + ).putExtra("player", position)); + Toast.makeText( + activity, "Exporting feature not implemented yet", Toast.LENGTH_LONG) + .show(); + } } - } } ); diff --git a/app/src/main/res/layout/activity_show_player.xml b/app/src/main/res/layout/activity_show_player.xml index 430318e..7637e60 100644 --- a/app/src/main/res/layout/activity_show_player.xml +++ b/app/src/main/res/layout/activity_show_player.xml @@ -220,8 +220,6 @@ android:layout_height="wrap_content" android:id="@+id/powerList" android:layout_gravity="center_horizontal" - android:divider="@android:color/transparent" - android:dividerHeight="0dp" android:choiceMode="none" />