コード例 #1
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   StatusMode statusMode = (StatusMode) statusModeView.getSelectedItem();
   outState.putString(SAVED_MODE, statusMode.name());
   outState.putString(SAVED_TEXT, statusTextView.getText().toString());
 }
コード例 #2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (isFinishing()) return;

    actionWithItem = null;

    setContentView(R.layout.status_editor);

    Intent intent = getIntent();
    account = StatusEditor.getAccount(intent);
    if (account == null) setTitle(getString(R.string.status_editor));
    else
      setTitle(
          getString(
              R.string.status_editor_for, AccountManager.getInstance().getVerboseName(account)));

    ListView listView = getListView();
    LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
    View header = inflater.inflate(R.layout.status_editor_header, listView, false);
    listView.addHeaderView(header, null, false);
    listView.setOnItemClickListener(this);
    registerForContextMenu(listView);
    setListAdapter(new StatusEditorAdapter(this));

    statusTextView = (EditText) header.findViewById(R.id.status_text);
    statusModeView = (Spinner) header.findViewById(R.id.status_mode);
    statusModeView.setAdapter(new StatusModeAdapter(this));
    ((Button) findViewById(R.id.ok)).setOnClickListener(this);

    StatusMode statusMode;
    String statusText;
    if (savedInstanceState == null) {
      if (account == null) {
        statusMode = SettingsManager.statusMode();
        statusText = SettingsManager.statusText();
      } else {
        AccountItem accountItem = AccountManager.getInstance().getAccount(account);
        if (accountItem == null) {
          Application.getInstance().onError(R.string.NO_SUCH_ACCOUNT);
          finish();
          return;
        }
        statusMode = accountItem.getFactualStatusMode();
        statusText = accountItem.getStatusText();
      }
    } else {
      statusMode = StatusMode.valueOf(savedInstanceState.getString(SAVED_MODE));
      statusText = savedInstanceState.getString(SAVED_TEXT);
    }
    showStatus(statusMode, statusText);
  }