use of im.actor.core.viewmodel.UserPresence in project actor-platform by actorapp.
the class PresenceActor method onUserOnline.
@Verified
private void onUserOnline(int uid, long updateDate) {
// Log.d(TAG, "onUserOnline #" + uid + " at " + updateDate);
if (lastUidState.containsKey(uid) && lastUidState.get(uid) >= updateDate) {
// Log.d(TAG, "onUserOnline:ignored - too old");
return;
}
lastUidState.put(uid, updateDate);
// Log.d(TAG, "onUserOnline:updated");
UserVM vm = getUserVM(uid);
if (vm != null) {
vm.getPresence().change(new UserPresence(UserPresence.State.ONLINE));
}
// Updating timeout
if (uidCancellables.containsKey(uid)) {
uidCancellables.remove(uid).cancel();
}
uidCancellables.put(uid, schedule(new OnlineUserTimeout(uid, (int) ((updateDate + ONLINE_TIMEOUT) / 1000L), updateDate + ONLINE_TIMEOUT), ONLINE_TIMEOUT));
}
Aggregations