From 5cdb4b293253ce70504005d0066de64f5b09692c Mon Sep 17 00:00:00 2001 From: Carlos Galindo Date: Wed, 25 Mar 2015 14:02:03 +0100 Subject: [PATCH] Fixed Snackbars and changed to Light --- .../kauron/dungeonmanager/MainActivity.java | 44 +++++++------------ .../com/kauron/dungeonmanager/Welcome.java | 10 ++--- app/src/main/res/values/styles.xml | 2 +- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java b/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java index 8321c0d..7c5c0ea 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java +++ b/app/src/main/java/com/kauron/dungeonmanager/MainActivity.java @@ -98,7 +98,7 @@ public class MainActivity extends ActionBarActivity{ if(player.getMaxPg() <= player.getPg()){ SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.maxed_curative) ); } else { @@ -144,13 +144,7 @@ public class MainActivity extends ActionBarActivity{ // Player.LEVEL_PX[player.getLevel() - 1], // true, player.getPx() - Player.LEVEL_PX[player.getLevel() - 1] // ); - } catch(Exception e) { - SnackbarManager.show( - Snackbar - .with(getApplicationContext()) - .text(R.string.message_no_px) - ); - } + } catch(Exception e) {} } }); alert.show(); @@ -160,7 +154,7 @@ public class MainActivity extends ActionBarActivity{ player.rest(true); SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.long_rest_done) ); p.edit() @@ -173,7 +167,7 @@ public class MainActivity extends ActionBarActivity{ player.rest(false); SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.rest_done) ); pgUpdate(); @@ -197,14 +191,14 @@ public class MainActivity extends ActionBarActivity{ if (hasCured == Player.NOT_CURED) { SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.no_curative_efforts_error) ); } else { if(hasCured == Player.MAXED){ SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.maxed_curative) ); } @@ -327,11 +321,12 @@ public class MainActivity extends ActionBarActivity{ alert.setNegativeButton(R.string.die, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { - SnackbarManager.show( - Snackbar - .with(getApplicationContext()) - .text(R.string.message_death) - ); + //TODO: fix +// SnackbarManager.show( +// Snackbar +// .with(this) +// .text(R.string.message_death) +// ); p.edit().clear().apply(); restoreData(); } @@ -346,7 +341,7 @@ public class MainActivity extends ActionBarActivity{ if(lastState != Player.SAME) { SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.state_changed_debilitado) ); } @@ -358,7 +353,7 @@ public class MainActivity extends ActionBarActivity{ if(lastState != Player.SAME) { SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(R.string.state_changed_malherido) ); } @@ -507,7 +502,7 @@ public class MainActivity extends ActionBarActivity{ if (!message.isEmpty()) { SnackbarManager.show( Snackbar - .with(getApplicationContext()) + .with(this) .text(message) ); } @@ -530,14 +525,7 @@ public class MainActivity extends ActionBarActivity{ .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { - if (input.getText().toString().isEmpty()) { - SnackbarManager.show( - Snackbar - .with(getApplicationContext()) - .text(R.string.empty_field) - ); - pgDialog(); - } else { + if (!input.getText().toString().isEmpty()) { player.setMaxPg(Integer.parseInt(input.getText().toString())); } } diff --git a/app/src/main/java/com/kauron/dungeonmanager/Welcome.java b/app/src/main/java/com/kauron/dungeonmanager/Welcome.java index 0372b11..cf80498 100644 --- a/app/src/main/java/com/kauron/dungeonmanager/Welcome.java +++ b/app/src/main/java/com/kauron/dungeonmanager/Welcome.java @@ -8,14 +8,15 @@ import android.view.Menu; import android.view.MenuItem; import android.view.View; import android.widget.Button; -import android.widget.TextView; + +import com.nispok.snackbar.Snackbar; +import com.nispok.snackbar.SnackbarManager; public class Welcome extends ActionBarActivity { private Button load; private SharedPreferences p; - private TextView newText; @Override protected void onCreate(Bundle savedInstanceState) { @@ -23,15 +24,12 @@ public class Welcome extends ActionBarActivity { setContentView(R.layout.activity_welcome); p = getSharedPreferences("basics", MODE_PRIVATE); load = (Button) findViewById(R.id.loadCharacter); - newText = (TextView) findViewById(R.id.newText); if (p.getBoolean("saved", false)) { load.setEnabled(true); load.setText(String.format(getString(R.string.load_text), p.getString("playerName", ""))); - newText.setVisibility(View.VISIBLE); } else { load.setEnabled(false); load.setText(R.string.load_character); - newText.setVisibility(View.GONE); } } @@ -71,11 +69,9 @@ public class Welcome extends ActionBarActivity { if (p.getBoolean("saved", false)) { load.setEnabled(true); load.setText(String.format(getString(R.string.load_text), p.getString("playerName", ""))); - newText.setVisibility(View.VISIBLE); } else { load.setEnabled(false); load.setText(R.string.load_character); - newText.setVisibility(View.GONE); } } } diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index d54b919..5d05ec0 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -1,7 +1,7 @@ -