Methods Summary |
---|
protected void | onCreate(android.os.Bundle savedInstanceState)
super.onCreate(savedInstanceState);
// Create and attach the view that is responsible for painting.
mView = new MyView(this);
setContentView(mView);
mView.requestFocus();
// Restore the fading option if we are being thawed from a
// previously saved state. Note that we are not currently remembering
// the contents of the bitmap.
mFading = savedInstanceState != null ? savedInstanceState.getBoolean("fading", true) : true;
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
menu.add(0, CLEAR_ID, 0, "Clear");
menu.add(0, FADE_ID, 0, "Fade").setCheckable(true);
return super.onCreateOptionsMenu(menu);
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
switch (item.getItemId()) {
case CLEAR_ID:
mView.clear();
return true;
case FADE_ID:
mFading = !mFading;
if (mFading) {
startFading();
} else {
stopFading();
}
return true;
default:
return super.onOptionsItemSelected(item);
}
|
protected void | onPause()
super.onPause();
// Make sure to never run the fading pulse while we are paused or
// stopped.
stopFading();
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
menu.findItem(FADE_ID).setChecked(mFading);
return super.onPrepareOptionsMenu(menu);
|
protected void | onResume()
super.onResume();
// If fading mode is enabled, then as long as we are resumed we want
// to run pulse to fade the contents.
if (mFading) {
startFading();
}
|
protected void | onSaveInstanceState(android.os.Bundle outState)
super.onSaveInstanceState(outState);
// Save away the fading state to restore if needed later. Note that
// we do not currently save the contents of the display.
outState.putBoolean("fading", mFading);
|
void | startFading()Start up the pulse to fade the screen, clearing any existing pulse to
ensure that we don't have multiple pulses running at a time.
mHandler.removeMessages(FADE_MSG);
mHandler.sendMessageDelayed(
mHandler.obtainMessage(FADE_MSG), FADE_DELAY);
|
void | stopFading()Stop the pulse to fade the screen.
mHandler.removeMessages(FADE_MSG);
|