Search in sources :

Example 1 with ContactVcardViewerFragment

use of com.xabber.android.ui.fragment.ContactVcardViewerFragment in project xabber-android by redsolution.

the class AccountViewer method editAccountInfo.

private void editAccountInfo() {
    VCard vCard = ((ContactVcardViewerFragment) getFragmentManager().findFragmentById(R.id.scrollable_container)).getvCard();
    if (vCard != null) {
        Intent intent = AccountInfoEditor.createIntent(this, account, vCard.getChildElementXML().toString());
        startActivityForResult(intent, ACCOUNT_INFO_EDITOR_REQUEST_CODE);
    }
}
Also used : ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) Intent(android.content.Intent) VCard(org.jivesoftware.smackx.vcardtemp.packet.VCard)

Example 2 with ContactVcardViewerFragment

use of com.xabber.android.ui.fragment.ContactVcardViewerFragment in project xabber-android by redsolution.

the class AccountViewer method onActivityResult.

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    if (requestCode != ACCOUNT_INFO_EDITOR_REQUEST_CODE) {
        return;
    }
    final ContactVcardViewerFragment contactVcardViewerFragment = (ContactVcardViewerFragment) getFragmentManager().findFragmentById(R.id.scrollable_container);
    if (resultCode == AccountInfoEditorFragment.REQUEST_NEED_VCARD) {
        contactVcardViewerFragment.requestVCard();
    }
    if (resultCode == RESULT_OK) {
        String vCardXml = data.getStringExtra(AccountInfoEditorFragment.ARGUMENT_VCARD);
        VCard vCard = null;
        if (vCardXml != null) {
            try {
                vCard = ContactVcardViewerFragment.parseVCard(vCardXml);
            } catch (XmlPullParserException | IOException | SmackException e) {
                e.printStackTrace();
            }
        }
        if (vCard != null) {
            vCard.getField(VCardProperty.NICKNAME.name());
            contactVcardViewerFragment.onVCardReceived(account, Jid.getBareAddress(account), vCard);
        } else {
            contactVcardViewerFragment.requestVCard();
        }
    }
}
Also used : SmackException(org.jivesoftware.smack.SmackException) ContactVcardViewerFragment(com.xabber.android.ui.fragment.ContactVcardViewerFragment) XmlPullParserException(org.xmlpull.v1.XmlPullParserException) IOException(java.io.IOException) VCard(org.jivesoftware.smackx.vcardtemp.packet.VCard)

Aggregations

ContactVcardViewerFragment (com.xabber.android.ui.fragment.ContactVcardViewerFragment)2 VCard (org.jivesoftware.smackx.vcardtemp.packet.VCard)2 Intent (android.content.Intent)1 IOException (java.io.IOException)1 SmackException (org.jivesoftware.smack.SmackException)1 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)1