public void onClick(View v) {
    switch (v.getId()) {
      case R.id.delete_group_button:
        if (!groupListAdapter.hasSelectedGroup()) {
          Toast.makeText(this, R.string.need_group_selection, Toast.LENGTH_SHORT).show();
          return;
        }

        new AlertDialog.Builder(this)
            .setIcon(android.R.drawable.ic_dialog_alert)
            .setTitle(R.string.delete)
            .setMessage(R.string.delete_warning_message)
            .setPositiveButton(
                R.string.okay,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    deleteSelectedGroups();
                  }
                })
            .setNeutralButton(
                R.string.cancel,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                  }
                })
            .show();
        break;
      case R.id.cancel_delete_group_button:
        finish();
        break;
    }
  }
Example #2
0
 public void onClick(View v) {
   if (v.getId() == R.id.group_list_btn_modify) {
     group.setName(((EditText) findViewById(R.id.group_list_item_name)).getText().toString());
     if (DB.inst.getGroupDao().getKey(group) != null) {
       DB.update(group);
     } else {
       DB.insert(group);
     }
   } else if (v.getId() == R.id.group_list_btn_remove) {
     groupList.remove(group);
     if (DB.inst.getGroupDao().getKey(group) != null) {
       DB.delete(group);
     }
   } else if (v.getId() == R.id.group_list_btn_new) {
     group = new Group();
     group.setName("***");
     ((EditText) findViewById(R.id.group_list_item_name)).setText(group.getName());
     DB.insert(group);
     groupList.add(group);
   }
   groupListAdapter.notifyDataSetChanged();
 }
 private void deleteSelectedGroups() {
   GroupDeleteJob groupDeleteJob = new GroupDeleteJob(this);
   groupDeleteJob.execute(groupListAdapter.getSelectedGroups());
 }
 @Override
 protected void onListItemClick(ListView l, View v, int position, long id) {
   super.onListItemClick(l, v, position, id);
   groupListAdapter.toggleSelection(position);
 }