Java Code Examples for org.telegram.tgnet.TLRPC#TL_peerLocated
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_peerLocated .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PeopleNearbyActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void checkForExpiredLocations(boolean cache) { if (checkExpiredRunnable != null) { AndroidUtilities.cancelRunOnUIThread(checkExpiredRunnable); checkExpiredRunnable = null; } int currentTime = getConnectionsManager().getCurrentTime(); int minExpired = Integer.MAX_VALUE; boolean changed = false; for (int a = 0; a < 2; a++) { ArrayList<TLRPC.TL_peerLocated> arrayList = a == 0 ? users : chats; for (int b = 0, N = arrayList.size(); b < N; b++) { TLRPC.TL_peerLocated peer = arrayList.get(b); if (peer.expires <= currentTime) { arrayList.remove(b); b--; N--; changed = true; } else { minExpired = Math.min(minExpired, peer.expires); } } } if (changed && listViewAdapter != null) { updateRows(); } if (changed || cache) { getLocationController().setCachedNearbyUsersAndChats(users, chats); } if (minExpired != Integer.MAX_VALUE) { AndroidUtilities.runOnUIThread(checkExpiredRunnable = () -> { checkExpiredRunnable = null; checkForExpiredLocations(false); }, (minExpired - currentTime) * 1000); } }
Example 2
Source File: PeopleNearbyActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void checkForExpiredLocations(boolean cache) { if (checkExpiredRunnable != null) { AndroidUtilities.cancelRunOnUIThread(checkExpiredRunnable); checkExpiredRunnable = null; } int currentTime = getConnectionsManager().getCurrentTime(); int minExpired = Integer.MAX_VALUE; boolean changed = false; for (int a = 0; a < 2; a++) { ArrayList<TLRPC.TL_peerLocated> arrayList = a == 0 ? users : chats; for (int b = 0, N = arrayList.size(); b < N; b++) { TLRPC.TL_peerLocated peer = arrayList.get(b); if (peer.expires <= currentTime) { arrayList.remove(b); b--; N--; changed = true; } else { minExpired = Math.min(minExpired, peer.expires); } } } if (changed && listViewAdapter != null) { updateRows(); } if (changed || cache) { getLocationController().setCachedNearbyUsersAndChats(users, chats); } if (minExpired != Integer.MAX_VALUE) { AndroidUtilities.runOnUIThread(checkExpiredRunnable = () -> { checkExpiredRunnable = null; checkForExpiredLocations(false); }, (minExpired - currentTime) * 1000); } }
Example 3
Source File: LocationController.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setCachedNearbyUsersAndChats(ArrayList<TLRPC.TL_peerLocated> u, ArrayList<TLRPC.TL_peerLocated> c) { cachedNearbyUsers = new ArrayList<>(u); cachedNearbyChats = new ArrayList<>(c); }
Example 4
Source File: LocationController.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public ArrayList<TLRPC.TL_peerLocated> getCachedNearbyUsers() { return cachedNearbyUsers; }
Example 5
Source File: LocationController.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public ArrayList<TLRPC.TL_peerLocated> getCachedNearbyChats() { return cachedNearbyChats; }
Example 6
Source File: PeopleNearbyActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.newLocationAvailable) { sendRequest(false, 0); } else if (id == NotificationCenter.newPeopleNearbyAvailable) { TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) args[0]; for (int b = 0, N2 = update.peers.size(); b < N2; b++) { TLRPC.PeerLocated object = update.peers.get(b); if (object instanceof TLRPC.TL_peerLocated) { TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object; boolean found = false; ArrayList<TLRPC.TL_peerLocated> arrayList; if (peerLocated.peer instanceof TLRPC.TL_peerUser) { arrayList = users; } else { arrayList = chats; } for (int a = 0, N = arrayList.size(); a < N; a++) { TLRPC.TL_peerLocated old = arrayList.get(a); if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) { arrayList.set(a, peerLocated); found = true; } } if (!found) { arrayList.add(peerLocated); } } } checkForExpiredLocations(true); updateRows(); } else if (id == NotificationCenter.needDeleteDialog) { if (fragmentView == null || isPaused) { return; } long dialogId = (Long) args[0]; TLRPC.User user = (TLRPC.User) args[1]; TLRPC.Chat chat = (TLRPC.Chat) args[2]; boolean revoke = (Boolean) args[3]; Runnable deleteRunnable = () -> { if (chat != null) { if (ChatObject.isNotInChat(chat)) { getMessagesController().deleteDialog(dialogId, 0, revoke); } else { getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, false, revoke); } } else { getMessagesController().deleteDialog(dialogId, 0, revoke); } }; if (undoView != null) { undoView.showWithAction(dialogId, UndoView.ACTION_DELETE, deleteRunnable); } else { deleteRunnable.run(); } } }
Example 7
Source File: PeopleNearbyActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private String formatDistance(TLRPC.TL_peerLocated located) { return LocaleController.formatDistance(located.distance); }
Example 8
Source File: LocationController.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setCachedNearbyUsersAndChats(ArrayList<TLRPC.TL_peerLocated> u, ArrayList<TLRPC.TL_peerLocated> c) { cachedNearbyUsers = new ArrayList<>(u); cachedNearbyChats = new ArrayList<>(c); }
Example 9
Source File: LocationController.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ArrayList<TLRPC.TL_peerLocated> getCachedNearbyUsers() { return cachedNearbyUsers; }
Example 10
Source File: LocationController.java From Telegram with GNU General Public License v2.0 | 4 votes |
public ArrayList<TLRPC.TL_peerLocated> getCachedNearbyChats() { return cachedNearbyChats; }
Example 11
Source File: PeopleNearbyActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@Override public void didReceivedNotification(int id, int account, Object... args) { if (id == NotificationCenter.newLocationAvailable) { sendRequest(false, 0); } else if (id == NotificationCenter.newPeopleNearbyAvailable) { TLRPC.TL_updatePeerLocated update = (TLRPC.TL_updatePeerLocated) args[0]; for (int b = 0, N2 = update.peers.size(); b < N2; b++) { TLRPC.PeerLocated object = update.peers.get(b); if (object instanceof TLRPC.TL_peerLocated) { TLRPC.TL_peerLocated peerLocated = (TLRPC.TL_peerLocated) object; boolean found = false; ArrayList<TLRPC.TL_peerLocated> arrayList; if (peerLocated.peer instanceof TLRPC.TL_peerUser) { arrayList = users; } else { arrayList = chats; } for (int a = 0, N = arrayList.size(); a < N; a++) { TLRPC.TL_peerLocated old = arrayList.get(a); if (old.peer.user_id != 0 && old.peer.user_id == peerLocated.peer.user_id || old.peer.chat_id != 0 && old.peer.chat_id == peerLocated.peer.chat_id || old.peer.channel_id != 0 && old.peer.channel_id == peerLocated.peer.channel_id) { arrayList.set(a, peerLocated); found = true; } } if (!found) { arrayList.add(peerLocated); } } } checkForExpiredLocations(true); updateRows(); } else if (id == NotificationCenter.needDeleteDialog) { if (fragmentView == null || isPaused) { return; } long dialogId = (Long) args[0]; TLRPC.User user = (TLRPC.User) args[1]; TLRPC.Chat chat = (TLRPC.Chat) args[2]; boolean revoke = (Boolean) args[3]; Runnable deleteRunnable = () -> { if (chat != null) { if (ChatObject.isNotInChat(chat)) { getMessagesController().deleteDialog(dialogId, 0, revoke); } else { getMessagesController().deleteUserFromChat((int) -dialogId, getMessagesController().getUser(getUserConfig().getClientUserId()), null, false, revoke); } } else { getMessagesController().deleteDialog(dialogId, 0, revoke); } }; if (undoView != null) { undoView.showWithAction(dialogId, UndoView.ACTION_DELETE, deleteRunnable); } else { deleteRunnable.run(); } } }
Example 12
Source File: PeopleNearbyActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private String formatDistance(TLRPC.TL_peerLocated located) { return LocaleController.formatDistance(located.distance); }