Search in sources :

Example 21 with IContactListManager

use of org.awesomeapp.messenger.service.IContactListManager in project Zom-Android by zom.

the class ContactListFilterView method removeContact.

void removeContact(Cursor c) {
    final IImConnection conn = getConnection(c);
    String nickname = c.getString(c.getColumnIndexOrThrow(Imps.Contacts.NICKNAME));
    final String address = c.getString(c.getColumnIndexOrThrow(Imps.Contacts.USERNAME));
    DialogInterface.OnClickListener confirmListener = new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int whichButton) {
            try {
                IContactListManager manager = conn.getContactListManager();
                int res = manager.removeContact(address);
                if (res != ImErrorInfo.NO_ERROR) {
                    mHandler.showAlert(R.string.error, ErrorResUtils.getErrorRes(getResources(), res, address));
                }
            } catch (RemoteException e) {
                mHandler.showServiceErrorAlert(e.getLocalizedMessage());
                LogCleaner.error(ImApp.LOG_TAG, "remote error", e);
            }
        }
    };
    Resources r = getResources();
    new AlertDialog.Builder(mContext).setTitle(R.string.confirm).setMessage(r.getString(R.string.confirm_delete_contact, nickname)).setPositiveButton(R.string.yes, // default button
    confirmListener).setNegativeButton(R.string.no, null).setCancelable(false).show();
}
Also used : IImConnection(org.awesomeapp.messenger.service.IImConnection) DialogInterface(android.content.DialogInterface) Resources(android.content.res.Resources) IContactListManager(org.awesomeapp.messenger.service.IContactListManager) RemoteException(android.os.RemoteException)

Aggregations

RemoteException (android.os.RemoteException)21 IContactListManager (org.awesomeapp.messenger.service.IContactListManager)21 IImConnection (org.awesomeapp.messenger.service.IImConnection)9 ImApp (org.awesomeapp.messenger.ImApp)6 IOException (java.io.IOException)5 Contact (org.awesomeapp.messenger.model.Contact)5 XmppAddress (org.awesomeapp.messenger.plugin.xmpp.XmppAddress)5 CursorIndexOutOfBoundsException (android.database.CursorIndexOutOfBoundsException)4 IContactList (org.awesomeapp.messenger.service.IContactList)4 Activity (android.app.Activity)3 DialogInterface (android.content.DialogInterface)3 Resources (android.content.res.Resources)3 Paint (android.graphics.Paint)3 IBinder (android.os.IBinder)3 IChatSession (org.awesomeapp.messenger.service.IChatSession)2 IChatSessionManager (org.awesomeapp.messenger.service.IChatSessionManager)2 ContentResolver (android.content.ContentResolver)1 Cursor (android.database.Cursor)1 Uri (android.net.Uri)1 SpannableStringBuilder (android.text.SpannableStringBuilder)1