@Override
  public void onTaskFinished(Intent intent) {
    dismiss();

    DialogListener listener = mDialogListenerRef.get();
    if (listener != null) {
      listener.onUpdateFinished(intent);
    }
  }
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.color1:
        color = R.color.color1;

        break;

      case R.id.color2:
        color = R.color.color2;

        break;

      case R.id.color3:
        color = (R.color.color3);

        break;

      case R.id.color4:
        color = (R.color.color4);

        break;

      case R.id.color5:
        color = R.color.color5;

        break;

      case R.id.color6:
        color = R.color.color6;

        break;

      case R.id.color7:
        color = R.color.color7;

        break;

      case R.id.color8:
        color = R.color.color8;

        break;

      case R.id.color9:
        color = R.color.color9;

        break;

      default:
        Toast.makeText(getActivity(), "Error", Toast.LENGTH_SHORT).show();
    }

    dismiss(); // dismiss the color fragment
    dialogListener.colorPicker(color);
  }
  private void validateBox() {

    String name = tfName.getText();
    int index = -1;

    try {
      index = Integer.parseInt(tfIndex.getText());
    } catch (NumberFormatException e) {
      JOptionPane.showMessageDialog(
          null, "L'index doit etre un nombre entier !", "Erreur", JOptionPane.WARNING_MESSAGE);
      tfIndex.setText("0");
      return;
    }

    listener.onValidate(name, index);
    this.setVisible(false);
  }
 @Override
 public boolean processCmd(String key, DialogCmd cmd, Object obj) {
   // TODO Auto-generated method stub
   TvToastFocusData toastFocusData = (TvToastFocusData) obj;
   switch (cmd) {
     case DIALOG_SHOW:
     case DIALOG_UPDATE:
       super.showUI();
       toastFocusView.updateView(toastFocusData);
       break;
     case DIALOG_HIDE:
       break;
     case DIALOG_DISMISS:
       super.dismissUI();
       Object[] objects = null;
       if (null != dialogListener) dialogListener.onDismissDialogDone(objects);
       break;
   }
   return false;
 }
  /**
   * IMPORTANT: This method must be invoked at the top of the calling activity's onActivityResult()
   * function or Facebook authentication will not function properly!
   *
   * <p>If your calling activity does not currently implement onActivityResult(), you must implement
   * it and include a call to this method if you intend to use the authorize() method in this SDK.
   *
   * <p>For more information, see http://developer.android.com/reference/android/app/
   * Activity.html#onActivityResult(int, int, android.content.Intent)
   */
  public void authorizeCallback(int requestCode, int resultCode, Intent data) {
    if (requestCode == mAuthActivityCode) {

      // Successfully redirected.
      if (resultCode == Activity.RESULT_OK) {

        // Check OAuth 2.0/2.10 error code.
        String error = data.getStringExtra("error");
        if (error == null) {
          error = data.getStringExtra("error_type");
        }

        // A Facebook error occurred.
        if (error != null) {
          if (error.equals(SINGLE_SIGN_ON_DISABLED)
              || error.equals("AndroidAuthKillSwitchException")) {
            Log.d(
                "Facebook-authorize",
                "Hosted auth currently " + "disabled. Retrying dialog auth...");
            startDialogAuth(mAuthActivity, mAuthPermissions);
          } else if (error.equals("access_denied") || error.equals("OAuthAccessDeniedException")) {
            Log.d("Facebook-authorize", "Login canceled by user.");
            mAuthDialogListener.onCancel();
          } else {
            String description = data.getStringExtra("error_description");
            if (description != null) {
              error = error + ":" + description;
            }
            Log.d("Facebook-authorize", "Login failed: " + error);
            mAuthDialogListener.onFacebookError(new FacebookError(error));
          }

          // No errors.
        } else {
          setAccessToken(data.getStringExtra(TOKEN));
          setAccessExpiresIn(data.getStringExtra(EXPIRES));
          if (isSessionValid()) {
            Log.d(
                "Facebook-authorize",
                "Login Success! access_token="
                    + getAccessToken()
                    + " expires="
                    + getAccessExpires());
            mAuthDialogListener.onComplete(data.getExtras());
          } else {
            mAuthDialogListener.onFacebookError(
                new FacebookError("Failed to receive access token."));
          }
        }

        // An error occurred before we could be redirected.
      } else if (resultCode == Activity.RESULT_CANCELED) {

        // An Android error occured.
        if (data != null) {
          Log.d("Facebook-authorize", "Login failed: " + data.getStringExtra("error"));
          mAuthDialogListener.onError(
              new DialogError(
                  data.getStringExtra("error"),
                  data.getIntExtra("error_code", -1),
                  data.getStringExtra("failing_url")));

          // User pressed the 'back' button.
        } else {
          Log.d("Facebook-authorize", "Login canceled by user.");
          mAuthDialogListener.onCancel();
        }
      }
    }
  }
 void makeChoice(int choiceIndex) {
   choiceHasBeenMade = true;
   listener.choiceWasMade(choiceIndex);
 }
 protected void onCancel() {
   // close this dialog
   dismiss();
   listener.onUserAction(NO);
 }
 protected void onConfirm() {
   // close this dialog
   dismiss();
   listener.onUserAction(YES);
 }
 private void cancelBox() {
   listener.onCancel();
   this.setVisible(false);
 }