ExaltedDice.java
i remove the field mFormater, interface Formatter, formatNumber() as they are not needed by exalted dice. i removed getCurrent(), setCurrent() also because they were not used by exalted dice. i modified onClick() and onLongClick() to use switch blocks rather than nested if else blocks i incremented the version / build from b12 to b13
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="com.TwentyCode.android.ExaltedDice"
|
package="com.TwentyCode.android.ExaltedDice"
|
||||||
android:versionCode="12" android:versionName="1.0.1">
|
android:versionName="1.0.1" android:versionCode="13">
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
||||||
<activity android:name=".ExaltedDice"
|
<activity android:name=".ExaltedDice"
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -41,7 +41,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
private static boolean mDecrement;
|
private static boolean mDecrement;
|
||||||
private InputFilter mNumberInputFilter;
|
private InputFilter mNumberInputFilter;
|
||||||
private String[] mDisplayedValues;
|
private String[] mDisplayedValues;
|
||||||
private Formatter mFormatter;
|
|
||||||
//the speed in milliseconds for dice increment or decrement
|
//the speed in milliseconds for dice increment or decrement
|
||||||
private long mSpeed = 300;
|
private long mSpeed = 300;
|
||||||
//the least and most dice allowed
|
//the least and most dice allowed
|
||||||
@@ -51,7 +50,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
private static final int MENU_CLEAR = Menu.FIRST + 1;
|
private static final int MENU_CLEAR = Menu.FIRST + 1;
|
||||||
protected PostMortemReportExceptionHandler mDamageReport = new PostMortemReportExceptionHandler(this);
|
protected PostMortemReportExceptionHandler mDamageReport = new PostMortemReportExceptionHandler(this);
|
||||||
private static final String TAG = "ExaltedDice";
|
private static final String TAG = "ExaltedDice";
|
||||||
|
|
||||||
private Handler mHandler;
|
private Handler mHandler;
|
||||||
//this runnable will be used to increment or decrement the amount of dice being rolled
|
//this runnable will be used to increment or decrement the amount of dice being rolled
|
||||||
private final Runnable mRunnable = new Runnable() {
|
private final Runnable mRunnable = new Runnable() {
|
||||||
@@ -70,9 +68,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'
|
||||||
};
|
};
|
||||||
|
|
||||||
public interface Formatter {
|
|
||||||
String toString(int value);
|
|
||||||
}
|
|
||||||
private class NumberPickerInputFilter implements InputFilter {
|
private class NumberPickerInputFilter implements InputFilter {
|
||||||
public CharSequence filter(CharSequence source, int start, int end,
|
public CharSequence filter(CharSequence source, int start, int end,
|
||||||
Spanned dest, int dstart, int dend) {
|
Spanned dest, int dstart, int dend) {
|
||||||
@@ -103,9 +98,7 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
filtered = source.subSequence(start, end);
|
filtered = source.subSequence(start, end);
|
||||||
}
|
}
|
||||||
|
|
||||||
String result = String.valueOf(dest.subSequence(0, dstart))
|
String result = String.valueOf(dest.subSequence(0, dstart)) + filtered + dest.subSequence(dend, dest.length());
|
||||||
+ filtered
|
|
||||||
+ dest.subSequence(dend, dest.length());
|
|
||||||
|
|
||||||
if ("".equals(result)) {
|
if ("".equals(result)) {
|
||||||
return result;
|
return result;
|
||||||
@@ -153,7 +146,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void changeCurrent(int current) {
|
protected void changeCurrent(int current) {
|
||||||
|
|
||||||
// Wrap around the values if we go past the start or end
|
// Wrap around the values if we go past the start or end
|
||||||
if (current > mEnd) {
|
if (current > mEnd) {
|
||||||
current = mStart;
|
current = mStart;
|
||||||
@@ -175,19 +167,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
listview.setAdapter(new ArrayAdapter<String>(this, R.layout.list_row, rollHistory));
|
listview.setAdapter(new ArrayAdapter<String>(this, R.layout.list_row, rollHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
private String formatNumber(int value) {
|
|
||||||
return (mFormatter != null)
|
|
||||||
? mFormatter.toString(value)
|
|
||||||
: String.valueOf(value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return the current value.
|
|
||||||
*/
|
|
||||||
public int getCurrent() {
|
|
||||||
return mCurrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
private int getSelectedPos(String str) {
|
private int getSelectedPos(String str) {
|
||||||
if (mDisplayedValues == null) {
|
if (mDisplayedValues == null) {
|
||||||
return Integer.parseInt(str);
|
return Integer.parseInt(str);
|
||||||
@@ -230,14 +209,17 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.getId() == R.id.up)
|
switch (v.getId()){
|
||||||
|
case R.id.up:
|
||||||
changeCurrent(mCurrent + 1);
|
changeCurrent(mCurrent + 1);
|
||||||
|
break;
|
||||||
if (v.getId() == R.id.down)
|
case R.id.down:
|
||||||
changeCurrent(mCurrent - 1);
|
changeCurrent(mCurrent - 1);
|
||||||
|
break;
|
||||||
if (v.getId() == R.id.roll)
|
case R.id.roll:
|
||||||
rollDice();
|
rollDice();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -337,18 +319,19 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.getId() == R.id.up) {
|
switch (v.getId()){
|
||||||
|
case R.id.up:
|
||||||
mIncrement = true;
|
mIncrement = true;
|
||||||
mHandler.post(mRunnable);
|
mHandler.post(mRunnable);
|
||||||
|
return true;
|
||||||
|
|
||||||
} else if (v.getId() == R.id.down) {
|
case R.id.down:
|
||||||
mDecrement = true;
|
mDecrement = true;
|
||||||
mHandler.post(mRunnable);
|
mHandler.post(mRunnable);
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handles menu selection
|
* handles menu selection
|
||||||
@@ -385,8 +368,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
listview.setAdapter(new ArrayAdapter<String>(this, R.layout.list_row, rollHistory));
|
listview.setAdapter(new ArrayAdapter<String>(this, R.layout.list_row, rollHistory));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* saves application state before rotatoin
|
* saves application state before rotatoin
|
||||||
* @author ricky barrette
|
* @author ricky barrette
|
||||||
@@ -497,11 +478,6 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
return roll;
|
return roll;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrent(int current) {
|
|
||||||
mCurrent = current;
|
|
||||||
updateView();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* counts each dice roll that is greater than or equal to 7 as a success. 10
|
* counts each dice roll that is greater than or equal to 7 as a success. 10
|
||||||
* gets another success (for a total of 2)
|
* gets another success (for a total of 2)
|
||||||
@@ -534,18 +510,13 @@ public class ExaltedDice extends Activity implements OnClickListener, OnLongClic
|
|||||||
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateView() {
|
/**
|
||||||
|
* a convince method that will update the edit text dice to what the current amount of dice is
|
||||||
/* If we don't have displayed values then use the
|
*
|
||||||
* current number else find the correct value in the
|
* @author ricky barrette
|
||||||
* displayed values for the current number.
|
|
||||||
*/
|
*/
|
||||||
if (mDisplayedValues == null) {
|
protected void updateView() {
|
||||||
dice.setText(formatNumber(mCurrent));
|
dice.setText(mCurrent+"");
|
||||||
} else {
|
|
||||||
dice.setText(mDisplayedValues[mCurrent - mStart]);
|
|
||||||
}
|
|
||||||
dice.setSelection(dice.getText().length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user