示例#1
0
  @Override
  public void onClick(View v) {
    switch (v.getId()) {
      case R.id.addButton:
        final String name = nameEditText.getText().toString();
        final String server = serverEditText.getText().toString();
        final String url = urlEditText.getText().toString();
        Timber.d(
            "AddActivity.onClick, updating command id "
                + updateId
                + " with name: "
                + name
                + ", server: "
                + server
                + ", url: "
                + url);

        datasource.updateCommand(updateId, name, server, url);

        Intent main =
            new Intent(EditActivity.this, MainActivity.class)
                .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

        startActivity(main);
        break;
    }
  }
示例#2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Intent intent = getIntent();
    String updateIdString = intent.getStringExtra("updateId");
    Timber.v("EditActivity.onCreate, updateid: " + updateIdString);
    /*
    				Bundle bundle = intent.getExtras();
    				for (String key : bundle.keySet()) {
    				    Object value = bundle.get(key);
    				    Log.d("ZetaRemote", String.format("%s %s (%s)", key,
    				        value.toString(), value.getClass().getName()));
    				}
    */
    updateId = Long.valueOf(updateIdString).longValue();

    setTitle("Edit Record");

    setContentView(R.layout.addedit_activity);

    nameEditText = (EditText) findViewById(R.id.nameEditText);
    serverEditText = (EditText) findViewById(R.id.serverEditText);
    urlEditText = (EditText) findViewById(R.id.urlEditText);

    addButton = (Button) findViewById(R.id.addButton);

    datasource = new DataSource(this);
    datasource.open();

    Command currentCommand = datasource.getCommandById(updateId);

    nameEditText.setText(currentCommand.getName());
    serverEditText.setText(currentCommand.getServer());
    urlEditText.setText(currentCommand.getUrl());

    addButton.setText("Update");
    addButton.setOnClickListener(this);
  }