public void onClick(View v) {
    int id = v.getId();
    if (id == R.id.cht_alert_btn_yes) {
      dismiss();
      if (AlertType == 1) {
        try {
          // appSession.setData(ChatSession.CONNECTION_DATA, contactConn);
          // Contact conn = chatSession.getSelectedConnection();
          if (chatManager.getContactByLocalPublicKey(contactConn.getRemoteActorPublicKey())
              == null) {
            ContactImpl newContact = new ContactImpl();
            newContact.setAlias(contactConn.getAlias());
            newContact.setRemoteActorType(contactConn.getRemoteActorType());
            newContact.setRemoteActorPublicKey(contactConn.getRemoteActorPublicKey());
            newContact.setRemoteName(contactConn.getRemoteName());
            newContact.setContactId(UUID.randomUUID());
            newContact.setCreationDate(System.currentTimeMillis());
            newContact.setContactStatus(contactConn.getContactStatus());
            newContact.setProfileImage(contactConn.getProfileImage());
            chatManager.saveContact(newContact);
            addcontact = true;
            Toast.makeText(getActivity(), "Contact added", Toast.LENGTH_SHORT).show();
            // changeActivity(Activities.CHT_CHAT_OPEN_CONTACTLIST, appSession.getAppPublicKey());
            // dismiss();
          } else {
            Toast.makeText(getActivity(), "Contact already exist", Toast.LENGTH_SHORT).show();

            // changeActivity(Activities.CHT_CHAT_OPEN_CONTACTLIST, appSession.getAppPublicKey());
            // dismiss();
          }
          dismiss();
          mAdapterCallback.onMethodCallbackContacts(); // solution to access to update contacts. j

        } catch (CantSaveContactException e) {
          errorManager.reportUnexpectedSubAppException(
              SubApps.CHT_CHAT,
              UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
              e);
        } catch (Exception e) {
          errorManager.reportUnexpectedSubAppException(
              SubApps.CHT_CHAT,
              UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
              e);
        }
        // changeActivity(Activities.CHT_CHAT_OPEN_CHATLIST, appSession.getAppPublicKey());
      } else if (AlertType == 2) {
        try {
          Contact con = chatSession.getSelectedContact();
          chatManager.deleteContact(con);
          List<Contact> cont = chatManager.getContacts();
          if (cont.size() > 0) {
            for (int i = 0; i < cont.size(); i++) {
              contactname.add(cont.get(i).getAlias());
              contactid.add(cont.get(i).getContactId());
              ByteArrayInputStream bytes = new ByteArrayInputStream(cont.get(i).getProfileImage());
              BitmapDrawable bmd = new BitmapDrawable(bytes);
              contacticon.add(bmd.getBitmap());
            }
            final ContactListAdapter adaptador =
                new ContactListAdapter(
                    getActivity(),
                    contactname,
                    contacticon,
                    contactid,
                    chatManager,
                    moduleManager,
                    errorManager,
                    chatSession,
                    getSession(),
                    null);
            adaptador.refreshEvents(contactname, contacticon, contactid);
          }
        } catch (CantGetContactException e) {
          errorManager.reportUnexpectedSubAppException(
              SubApps.CHT_CHAT,
              UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
              e);
        } catch (Exception e) {
          errorManager.reportUnexpectedSubAppException(
              SubApps.CHT_CHAT,
              UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
              e);
        }
        delete_contact = true;
      }
    }

    if (id == R.id.cht_alert_btn_no) {
      dismiss();
    }
  }
  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View layout = inflater.inflate(R.layout.contact_edit_fragment, container, false);
    try {
      // Contact cont= chatSession.getSelectedContact();
      // TODO: metodo nuevo que lo buscara del module del actor
      // connections//chatManager.getChatUserIdentities();
      for (ChatActorCommunityInformation cont :
          chatManager.listAllConnectedChatActor(
              chatManager.newInstanceChatActorCommunitySelectableIdentity(
                  chatManager.getIdentityChatUsersFromCurrentDeviceUser().get(0)),
              2000,
              0)) {
        if (cont.getPublicKey() == chatSession.getData(ChatSession.CONTACT_DATA)) {
          contactname.add(cont.getAlias());
          contactid.add(cont.getPublicKey());
          contactalias.add(cont.getAlias());
          ByteArrayInputStream bytes = new ByteArrayInputStream(cont.getImage());
          BitmapDrawable bmd = new BitmapDrawable(bytes);
          contacticon.add(bmd.getBitmap());
          ContactAdapter adapter =
              new ContactAdapter(
                  getActivity(), contactname, contactalias, contactid, "edit", errorManager);
          // FermatTextView name =(FermatTextView)layout.findViewById(R.id.contact_name);
          // name.setText(contactname.get(0));
          // FermatTextView id =(FermatTextView)layout.findViewById(R.id.uuid);
          // id.setText(contactid.get(0).toString());

          // create bitmap from resource
          // Bitmap bm = BitmapFactory.decodeResource(getResources(), contacticon.get(0));

          // set circle bitmap
          ImageView mImage = (ImageView) layout.findViewById(R.id.contact_image);
          mImage.setImageBitmap(getCircleBitmap(contacticon.get(0)));
          break;
        }
      }
      aliasET = (EditText) layout.findViewById(R.id.aliasEdit);
      aliasET.setText(contactalias.get(0));
      saveBtn = (Button) layout.findViewById(R.id.saveContactButton);
      RelativeLayout contain = (RelativeLayout) layout.findViewById(R.id.containere);
    } catch (Exception e) {
      if (errorManager != null)
        errorManager.reportUnexpectedSubAppException(
            SubApps.CHT_CHAT,
            UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
            e);
    }

    toolbar.setNavigationOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            changeActivity(Activities.CHT_CHAT_OPEN_CHATLIST, appSession.getAppPublicKey());
          }
        });

    //        saveBtn.setOnClickListener(new View.OnClickListener() {
    //            @Override
    //            public void onClick(View v) {
    //                String aliasText = aliasET.getText().toString();
    //                if (TextUtils.isEmpty(aliasText)) {
    //                    return;
    //                }
    //                try {
    //                    for (ChatActorCommunityInformation cont:
    // chatManager.listAllConnectedChatActor(
    //                            (ChatActorCommunitySelectableIdentity) chatManager.
    //                                    getIdentityChatUsersFromCurrentDeviceUser().get(0), 2000,
    // 0)) {
    //                        if (cont.getPublicKey() ==
    // chatSession.getData(ChatSession.CONTACT_DATA)) {
    //                            cont.setAlias(aliasText);
    //                            //TODO:Cardozo revisar esta logica ya no aplica, esto viene de un
    // metodo nuevo que lo buscara del module del actor
    // connections//chatManager.getChatUserIdentities();
    //                            //chatManager.saveContact(con);
    //                            Toast.makeText(getActivity(), "Contact Updated",
    // Toast.LENGTH_SHORT).show();
    //                            //} catch (CantSaveContactException e) {
    //                            //
    // errorManager.reportUnexpectedSubAppException(SubApps.CHT_CHAT,
    // UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, e);
    //
    //                        }
    //                    }
    //                }catch (Exception e){
    //                    if (errorManager != null)
    //                        errorManager.reportUnexpectedSubAppException(SubApps.CHT_CHAT,
    // UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT, e);
    //                }
    //            }
    //        });

    return layout;
    // loadDummyHistory();
    // Inflate the list fragment layout
    // return inflater.inflate(R.layout.contact_list_fragment, container, false);
  }