Load roll presets from previous game.
updated ExaltedDice to load the roll presets from the previous roll when loading an existing game. updated ExaltedDice to load the mod preset to 0 for new games Change-Id: I8e5d82d99f7d90bbe2e42697966fa0d06e6424de Signed-off-by: Ricky Barrette <rickbarrette@gmail.com>
This commit is contained in:
@@ -51,6 +51,22 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
private String[] mModValues;
|
private String[] mModValues;
|
||||||
private NumberPicker mModPicker;
|
private NumberPicker mModPicker;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Applies the presets from the provided roll
|
||||||
|
* @param id of the roll
|
||||||
|
* @author ricky barrette
|
||||||
|
*/
|
||||||
|
private void applyRollPresets(long id) {
|
||||||
|
ContentValues roll = mDb.getGameHistoryInfo(mGameName, (int) (id));
|
||||||
|
try{
|
||||||
|
mNumberPicker.setValue(roll.getAsInteger(Database.KEY_NUMBER));
|
||||||
|
mDPicker.setValue(parseD(roll.getAsString(Database.KEY_D_TYPE)));
|
||||||
|
mModPicker.setValue(parseMod(roll.getAsString(Database.KEY_MOD).replace("'", "")));
|
||||||
|
} catch(NullPointerException e){
|
||||||
|
mModPicker.setValue(parseMod("0"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* clears the rollHistory List array and refreshes the listview
|
* clears the rollHistory List array and refreshes the listview
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
@@ -145,7 +161,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
mModPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
mModPicker.setDescendantFocusability(NumberPicker.FOCUS_BLOCK_DESCENDANTS);
|
||||||
|
|
||||||
findViewById(R.id.roll_button).setOnClickListener(this);
|
findViewById(R.id.roll_button).setOnClickListener(this);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -176,10 +191,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
|
public void onItemClick(AdapterView<?> arg0, View v, int position, long id) {
|
||||||
ContentValues roll = mDb.getGameHistoryInfo(mGameName, (int) (id + 1));
|
applyRollPresets(id + 1);
|
||||||
mNumberPicker.setValue(roll.getAsInteger(Database.KEY_NUMBER));
|
|
||||||
mDPicker.setValue(parseD(roll.getAsString(Database.KEY_D_TYPE)));
|
|
||||||
mModPicker.setValue(parseMod(roll.getAsString(Database.KEY_MOD).replace("'", "")));
|
|
||||||
|
|
||||||
if(mSettings.getBoolean(Settings.KEY_ROLL_AGAIN, true))
|
if(mSettings.getBoolean(Settings.KEY_ROLL_AGAIN, true))
|
||||||
rollDice();
|
rollDice();
|
||||||
@@ -239,6 +251,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnItemClic
|
|||||||
@Override
|
@Override
|
||||||
protected void onResume() {
|
protected void onResume() {
|
||||||
refresh();
|
refresh();
|
||||||
|
applyRollPresets(mDb.getGameRollCount(mGameId));
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user