Пример #1
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    txt_title = (TextView) this.findViewById(R.id.cht_alert_txt_title);
    txt_body = (TextView) this.findViewById(R.id.cht_alert_txt_body);
    btn_yes = (Button) this.findViewById(R.id.cht_alert_btn_yes);
    btn_no = (Button) this.findViewById(R.id.cht_alert_btn_no);
    try {
      chatSession = ((ChatSession) getSession());
      moduleManager = chatSession.getModuleManager();
      chatManager = moduleManager.getChatManager();
      errorManager = getSession().getErrorManager();

    } catch (Exception e) {
      if (errorManager != null)
        errorManager.reportUnexpectedSubAppException(
            SubApps.CHT_CHAT,
            UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
            e);
    }
    txt_title.setText(title);
    txt_body.setText(body);

    setUpListeners();
  }
Пример #2
0
 public ContactListAdapter(
     Context context,
     ArrayList contactinfo,
     ArrayList contacticon,
     ArrayList contactid,
     ChatManager chatManager,
     ChatModuleManager moduleManager,
     ErrorManager errorManager,
     ChatSession chatSession,
     FermatSession appSession,
     AdapterCallback mAdapterCallback) {
   super(context, R.layout.contact_list_item, contactinfo);
   // tf = Typeface.createFromAsset(context.getAssets(), "fonts/HelveticaNeue Medium.ttf");
   this.contactinfo = contactinfo;
   this.contacticon = contacticon;
   this.contactid = contactid;
   this.chatManager = chatManager;
   this.moduleManager = moduleManager;
   this.errorManager = errorManager;
   this.chatSession = chatSession;
   this.appSession = appSession;
   this.mContext = context;
   try {
     this.mAdapterCallback = mAdapterCallback;
   } catch (Exception e) {
     errorManager.reportUnexpectedSubAppException(
         SubApps.CHT_CHAT,
         UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
         e);
   }
 }
Пример #3
0
  public View getView(int position, View convertView, ViewGroup parent) {
    LayoutInflater inflater = LayoutInflater.from(getContext());
    View item = inflater.inflate(R.layout.contact_list_item, null, true);
    try {
      imagen =
          (ImageView)
              item.findViewById(
                  R.id
                      .icon); // imagen.setImageResource(contacticon.get(position));//contacticon[position]);
      imagen.setImageBitmap(
          getRoundedShape(
              contacticon.get(position),
              400)); // imagen.setImageBitmap(getRoundedShape(decodeFile(getContext(),
                     // contacticon.get(position)), 300));

      contactname = (TextView) item.findViewById(R.id.text1);
      contactname.setText(contactinfo.get(position));
      // contactname.setTypeface(tf, Typeface.NORMAL);

      final int pos = position;
      imagen.setOnClickListener(
          new View.OnClickListener() {
            // int pos = position;
            @Override
            public void onClick(View v) {
              try {

                // TODO:Cardozo revisar esta logica ya no aplica, esto viene de un metodo nuevo que
                // lo buscara del module del actor connections//chatManager.getChatUserIdentities();
                appSession.setData(
                    ChatSession.CONTACT_DATA,
                    null); // chatManager.getContactByContactId(contactid.get(pos)));
                mAdapterCallback.onMethodCallback(); // solution to access to changeactivity. j
                // } 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);
              }
            }
          });

    } catch (Exception e) {
      errorManager.reportUnexpectedSubAppException(
          SubApps.CHT_CHAT,
          UnexpectedSubAppExceptionSeverity.DISABLES_SOME_FUNCTIONALITY_WITHIN_THIS_FRAGMENT,
          e);
    }
    return item;
  }
Пример #4
0
  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();
    }
  }