Methods Summary |
---|
static void | log(java.lang.String message)
if (LOG_ENABLED) {
Log.v(LOG_TAG, message);
}
|
public void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.main);
mPersist = new Persist(this);
mHistory = mPersist.history;
mDisplay = (CalculatorDisplay) findViewById(R.id.display);
mLogic = new Logic(this, mHistory, mDisplay, (Button) findViewById(R.id.equal));
HistoryAdapter historyAdapter = new HistoryAdapter(this, mHistory, mLogic);
mHistory.setObserver(historyAdapter);
View view;
mPanelSwitcher = (PanelSwitcher) findViewById(R.id.panelswitch);
mListener.setHandler(mLogic, mPanelSwitcher);
mDisplay.setOnKeyListener(mListener);
if ((view = findViewById(R.id.del)) != null) {
view.setOnClickListener(mListener);
view.setOnLongClickListener(mListener);
}
/*
if ((view = findViewById(R.id.clear)) != null) {
view.setOnClickListener(mListener);
}
*/
/*
ListView historyPad = (ListView) findViewById(R.id.historyPad);
if (historyPad != null) {
historyPad.setAdapter(historyAdapter);
}
*/
|
public boolean | onCreateOptionsMenu(android.view.Menu menu)
super.onCreateOptionsMenu(menu);
MenuItem item;
item = menu.add(0, CMD_CLEAR_HISTORY, 0, R.string.clear_history);
item.setIcon(R.drawable.clear_history);
item = menu.add(0, CMD_ADVANCED_PANEL, 0, R.string.advanced);
item.setIcon(R.drawable.advanced);
item = menu.add(0, CMD_BASIC_PANEL, 0, R.string.basic);
item.setIcon(R.drawable.simple);
return true;
|
public boolean | onOptionsItemSelected(android.view.MenuItem item)
switch (item.getItemId()) {
case CMD_CLEAR_HISTORY:
mHistory.clear();
break;
case CMD_BASIC_PANEL:
if (mPanelSwitcher != null &&
mPanelSwitcher.getCurrentIndex() == ADVANCED_PANEL) {
mPanelSwitcher.moveRight();
}
break;
case CMD_ADVANCED_PANEL:
if (mPanelSwitcher != null &&
mPanelSwitcher.getCurrentIndex() == BASIC_PANEL) {
mPanelSwitcher.moveLeft();
}
break;
}
return super.onOptionsItemSelected(item);
|
public void | onPause()
super.onPause();
mLogic.updateHistory();
mPersist.save();
|
public boolean | onPrepareOptionsMenu(android.view.Menu menu)
super.onPrepareOptionsMenu(menu);
menu.findItem(CMD_BASIC_PANEL).setVisible(mPanelSwitcher != null &&
mPanelSwitcher.getCurrentIndex() == ADVANCED_PANEL);
menu.findItem(CMD_ADVANCED_PANEL).setVisible(mPanelSwitcher != null &&
mPanelSwitcher.getCurrentIndex() == BASIC_PANEL);
return true;
|
protected void | onSaveInstanceState(android.os.Bundle icicle)
// as work-around for ClassCastException in TextView on restart
// avoid calling superclass, to keep icicle empty
|