Exemplo n.º 1
0
  @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);
  }