Remove "otherJid" when receiving unavailable presence.
This commit is contained in:
parent
ebe4208502
commit
27f506c253
|
|
@ -172,22 +172,28 @@ public class ServiceXmpp extends Observable implements PresenceEventListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void presenceAvailable(FullJid address, Presence availablePresence) {
|
public void presenceAvailable(FullJid address, Presence presence) {
|
||||||
String fullJid = address.asFullJidIfPossible().toString();
|
String fullJid = address.asFullJidIfPossible().toString();
|
||||||
if (!fullJid.equals(jid) && (otherJid == null || !fullJid.equals(otherJid))) {
|
if (presence.getType() == Presence.Type.available) {
|
||||||
Log.i(TAG, "PRESENCE AVAILABLE RECEIVED FROM "+fullJid);
|
if (!fullJid.equals(jid) && (otherJid == null || !fullJid.equals(otherJid))) {
|
||||||
otherJid = fullJid;
|
Log.i(TAG, "PRESENCE AVAILABLE RECEIVED FROM " + fullJid);
|
||||||
try {
|
otherJid = fullJid;
|
||||||
sendPresenceAvailable(fullJid);
|
try {
|
||||||
} catch (SmackException.NotConnectedException e) {
|
sendPresenceAvailable(fullJid);
|
||||||
e.printStackTrace();
|
} catch (SmackException.NotConnectedException e) {
|
||||||
} catch (InterruptedException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
} catch (InterruptedException e) {
|
||||||
} catch (XmppStringprepException e) {
|
e.printStackTrace();
|
||||||
e.printStackTrace();
|
} catch (XmppStringprepException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
setChanged();
|
||||||
|
notifyObservers(new Notification(NOTIF_NEW_PRESENCE_RECEIVED).addExtra(NOTIF_NEW_PRESENCE_RECEIVED_VALUE_JID, otherJid));
|
||||||
|
}
|
||||||
|
} else if (presence.getType() == Presence.Type.unavailable) {
|
||||||
|
if (otherJid != null && otherJid.equals(fullJid)) {
|
||||||
|
otherJid = null;
|
||||||
}
|
}
|
||||||
setChanged();
|
|
||||||
notifyObservers(new Notification(NOTIF_NEW_PRESENCE_RECEIVED).addExtra(NOTIF_NEW_PRESENCE_RECEIVED_VALUE_JID, otherJid));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue