コード例 #1
0
  public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {

    int buttonID = buttonView.getId();

    if (buttonID == R.id.switchNotificationLO) {
      if (isChecked) {
        repeatSpinner.setEnabled(true);
        timepicker.setEnabled(true);
        datepicker.setEnabled(true);
      } else {
        repeatSpinner.setEnabled(false);
        timepicker.setEnabled(false);
        datepicker.setEnabled(false);
      }
    }
  }
コード例 #2
0
 public void initilizeForNewTask() {
   repeatAlarmInterval = -1;
   // disable the time picker on the oncreate
   // set the timepicker to view 24 hours format
   timepicker.setEnabled(false);
   datepicker.setEnabled(false);
   repeatSpinner.setEnabled(false);
   notifySwitch.setChecked(false);
   // button, add the task
 }
コード例 #3
0
  private void updateShareInfo(final Share share) {
    View dialogView = context.getLayoutInflater().inflate(R.layout.update_share, null);
    final EditText nameBox = (EditText) dialogView.findViewById(R.id.get_share_name);
    final DatePicker expireBox = (DatePicker) dialogView.findViewById(R.id.get_share_expire);
    final CheckBox noExpiresBox = (CheckBox) dialogView.findViewById(R.id.get_share_no_expire);

    nameBox.setText(share.getDescription());
    Date expires = share.getExpires();
    if (expires != null) {
      expireBox.updateDate(expires.getYear() + 1900, expires.getMonth(), expires.getDate());
    }

    boolean noExpires = share.getExpires() == null;
    if (noExpires) {
      expireBox.setEnabled(false);
      noExpiresBox.setChecked(true);
    }

    noExpiresBox.setOnCheckedChangeListener(
        new CompoundButton.OnCheckedChangeListener() {
          @Override
          public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            expireBox.setEnabled(!isChecked);
          }
        });

    new AlertDialog.Builder(context)
        .setIcon(android.R.drawable.ic_dialog_alert)
        .setTitle(R.string.playlist_update_info)
        .setView(dialogView)
        .setPositiveButton(
            R.string.common_ok,
            new DialogInterface.OnClickListener() {
              @Override
              public void onClick(DialogInterface dialog, int which) {
                new LoadingTask<Void>(context, false) {
                  @Override
                  protected Void doInBackground() throws Throwable {
                    Long expiresIn = 0L;
                    if (!noExpiresBox.isChecked()) {
                      Date expires =
                          new Date(
                              expireBox.getYear() - 1900,
                              expireBox.getMonth(),
                              expireBox.getDayOfMonth());
                      expiresIn = expires.getTime();
                    }

                    MusicService musicService = MusicServiceFactory.getMusicService(context);
                    musicService.updateShare(
                        share.getId(), nameBox.getText().toString(), expiresIn, context, null);
                    return null;
                  }

                  @Override
                  protected void done(Void result) {
                    refresh();
                    Util.toast(
                        context,
                        context
                            .getResources()
                            .getString(R.string.share_updated_info, share.getName()));
                  }

                  @Override
                  protected void error(Throwable error) {
                    String msg;
                    if (error instanceof OfflineException
                        || error instanceof ServerTooOldException) {
                      msg = getErrorMessage(error);
                    } else {
                      msg =
                          context
                                  .getResources()
                                  .getString(R.string.share_updated_info_error, share.getName())
                              + " "
                              + getErrorMessage(error);
                    }

                    Util.toast(context, msg, false);
                  }
                }.execute();
              }
            })
        .setNegativeButton(R.string.common_cancel, null)
        .show();
  }
コード例 #4
0
 private void setFieldsEnabled(boolean v) {
   _datePicker.setEnabled(v);
   _timePicker.setEnabled(v);
   _okButton.setEnabled(v);
   _cancelButton.setEnabled(v);
 }