EditSlideDurationActivitypublic class EditSlideDurationActivity extends android.app.Activity This activity provides the function to edit the duration of given slide. |
Fields Summary |
---|
public static final String | SLIDE_INDEX | public static final String | SLIDE_TOTAL | public static final String | SLIDE_DUR | private android.widget.TextView | mLabel | private android.widget.Button | mDone | private android.widget.EditText | mDur | private int | mCurSlide | private int | mTotal | private android.os.Bundle | mState | private static final String | STATE | private static final String | TAG | private static final boolean | DEBUG | private static final boolean | LOCAL_LOGV | private final android.view.View.OnKeyListener | mOnKeyListener | private final android.view.View.OnClickListener | mOnDoneClickListener |
Methods Summary |
---|
protected void | editDone()
// Set result to parent, and close window.
// Check the duration.
String dur = mDur.getText().toString();
try {
Integer.valueOf(dur);
} catch (NumberFormatException e) {
notifyUser("Invalid duration! Please input again.");
mDur.requestFocus();
mDur.selectAll();
return;
}
// Set result.
setResult(RESULT_OK, new Intent(mDur.getText().toString()));
finish();
| private void | notifyUser(java.lang.String message)
if (LOCAL_LOGV) {
Log.v(TAG, "notifyUser: message=" + message);
}
| protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.edit_slide_duration);
int dur;
if (icicle == null) {
// Get extra from intent.
Intent intent = getIntent();
mCurSlide = intent.getIntExtra(SLIDE_INDEX, 1);
mTotal = intent.getIntExtra(SLIDE_TOTAL, 1);
dur = intent.getIntExtra(SLIDE_DUR, 8);
} else {
mState = icicle.getBundle(STATE);
mCurSlide = mState.getInt(SLIDE_INDEX, 1);
mTotal = mState.getInt(SLIDE_TOTAL, 1);
dur = mState.getInt(SLIDE_DUR, 8);
}
// Label.
mLabel = (TextView) findViewById(R.id.label);
mLabel.setText(getString(R.string.duration_selector_title) + " " + (mCurSlide + 1) + "/" + mTotal);
// Input text field.
mDur = (EditText) findViewById(R.id.text);
mDur.setText(String.valueOf(dur));
mDur.setOnKeyListener(mOnKeyListener);
// Done button.
mDone = (Button) findViewById(R.id.done);
mDone.setOnClickListener(mOnDoneClickListener);
| protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
mState = new Bundle();
mState.putInt(SLIDE_INDEX, mCurSlide);
mState.putInt(SLIDE_TOTAL, mTotal);
mState.putInt(SLIDE_DUR, Integer.parseInt(mDur.getText().toString()));
outState.putBundle(STATE, mState);
|
|