Java Code Examples for org.telegram.tgnet.TLRPC#TL_messages_getRecentLocations
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_messages_getRecentLocations .
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: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void loadLiveLocations(final long did) { if (cacheRequests.indexOfKey(did) >= 0) { return; } cacheRequests.put(did, true); TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) did); req.limit = 100; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (error != null) { return; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { cacheRequests.delete(did); TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); locationsCache.put(did, res.messages); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsCacheChanged, did, currentAccount); } }); } }); }
Example 2
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void loadLiveLocations(final long did) { if (cacheRequests.indexOfKey(did) >= 0) { return; } cacheRequests.put(did, true); TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) did); req.limit = 100; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (error != null) { return; } AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { cacheRequests.delete(did); TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); locationsCache.put(did, res.messages); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsCacheChanged, did, currentAccount); } }); } }); }
Example 3
Source File: LocationController.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
public void loadLiveLocations(final long did) { if (cacheRequests.indexOfKey(did) >= 0) { return; } cacheRequests.put(did, true); TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); req.peer = getMessagesController().getInputPeer((int) did); req.limit = 100; getConnectionsManager().sendRequest(req, (response, error) -> { if (error != null) { return; } AndroidUtilities.runOnUIThread(() -> { cacheRequests.delete(did); TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true); getMessagesController().putUsers(res.users, false); getMessagesController().putChats(res.chats, false); locationsCache.put(did, res.messages); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsCacheChanged, did, currentAccount); }); }); }
Example 4
Source File: LocationController.java From Telegram with GNU General Public License v2.0 | 5 votes |
public void loadLiveLocations(final long did) { if (cacheRequests.indexOfKey(did) >= 0) { return; } cacheRequests.put(did, true); TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); req.peer = getMessagesController().getInputPeer((int) did); req.limit = 100; getConnectionsManager().sendRequest(req, (response, error) -> { if (error != null) { return; } AndroidUtilities.runOnUIThread(() -> { cacheRequests.delete(did); TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true); getMessagesController().putUsers(res.users, false); getMessagesController().putChats(res.chats, false); locationsCache.put(did, res.messages); NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsCacheChanged, did, currentAccount); }); }); }
Example 5
Source File: LocationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private boolean getRecentLocations() { ArrayList<TLRPC.Message> messages = LocationController.getInstance(currentAccount).locationsCache.get(messageObject.getDialogId()); if (messages != null && messages.isEmpty()) { fetchRecentLocations(messages); } else { messages = null; } int lower_id = (int) dialogId; if (lower_id < 0) { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); if (ChatObject.isChannel(chat) && !chat.megagroup) { return false; } } TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); final long dialog_id = messageObject.getDialogId(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) dialog_id); req.limit = 100; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (response != null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (googleMap == null) { return; } TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); LocationController.getInstance(currentAccount).locationsCache.put(dialog_id, res.messages); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.liveLocationsCacheChanged, dialog_id); fetchRecentLocations(res.messages); } }); } } }); return messages != null; }
Example 6
Source File: LocationActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private boolean getRecentLocations() { ArrayList<TLRPC.Message> messages = LocationController.getInstance(currentAccount).locationsCache.get(messageObject.getDialogId()); if (messages != null && messages.isEmpty()) { fetchRecentLocations(messages); } else { messages = null; } int lower_id = (int) dialogId; if (lower_id < 0) { TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-lower_id); if (ChatObject.isChannel(chat) && !chat.megagroup) { return false; } } TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); final long dialog_id = messageObject.getDialogId(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) dialog_id); req.limit = 100; ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(final TLObject response, TLRPC.TL_error error) { if (response != null) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (googleMap == null) { return; } TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } MessagesStorage.getInstance(currentAccount).putUsersAndChats(res.users, res.chats, true, true); MessagesController.getInstance(currentAccount).putUsers(res.users, false); MessagesController.getInstance(currentAccount).putChats(res.chats, false); LocationController.getInstance(currentAccount).locationsCache.put(dialog_id, res.messages); NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.liveLocationsCacheChanged, dialog_id); fetchRecentLocations(res.messages); } }); } } }); return messages != null; }
Example 7
Source File: LocationActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private boolean getRecentLocations() { ArrayList<TLRPC.Message> messages = getLocationController().locationsCache.get(messageObject.getDialogId()); if (messages != null && messages.isEmpty()) { fetchRecentLocations(messages); } else { messages = null; } int lower_id = (int) dialogId; if (lower_id < 0) { TLRPC.Chat chat = getMessagesController().getChat(-lower_id); if (ChatObject.isChannel(chat) && !chat.megagroup) { return false; } } TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); final long dialog_id = messageObject.getDialogId(); req.peer = getMessagesController().getInputPeer((int) dialog_id); req.limit = 100; getConnectionsManager().sendRequest(req, (response, error) -> { if (response != null) { AndroidUtilities.runOnUIThread(() -> { if (mapView == null) { return; } TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true); getMessagesController().putUsers(res.users, false); getMessagesController().putChats(res.chats, false); getLocationController().locationsCache.put(dialog_id, res.messages); getNotificationCenter().postNotificationName(NotificationCenter.liveLocationsCacheChanged, dialog_id); fetchRecentLocations(res.messages); getLocationController().markLiveLoactionsAsRead(dialogId); if (markAsReadRunnable == null) { markAsReadRunnable = () -> { getLocationController().markLiveLoactionsAsRead(dialogId); if (isPaused || markAsReadRunnable == null) { return; } AndroidUtilities.runOnUIThread(markAsReadRunnable, 5000); }; AndroidUtilities.runOnUIThread(markAsReadRunnable, 5000); } }); } }); return messages != null; }
Example 8
Source File: LocationActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private boolean getRecentLocations() { ArrayList<TLRPC.Message> messages = getLocationController().locationsCache.get(messageObject.getDialogId()); if (messages != null && messages.isEmpty()) { fetchRecentLocations(messages); } else { messages = null; } int lower_id = (int) dialogId; if (lower_id < 0) { TLRPC.Chat chat = getMessagesController().getChat(-lower_id); if (ChatObject.isChannel(chat) && !chat.megagroup) { return false; } } TLRPC.TL_messages_getRecentLocations req = new TLRPC.TL_messages_getRecentLocations(); final long dialog_id = messageObject.getDialogId(); req.peer = getMessagesController().getInputPeer((int) dialog_id); req.limit = 100; getConnectionsManager().sendRequest(req, (response, error) -> { if (response != null) { AndroidUtilities.runOnUIThread(() -> { if (googleMap == null) { return; } TLRPC.messages_Messages res = (TLRPC.messages_Messages) response; for (int a = 0; a < res.messages.size(); a++) { if (!(res.messages.get(a).media instanceof TLRPC.TL_messageMediaGeoLive)) { res.messages.remove(a); a--; } } getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true); getMessagesController().putUsers(res.users, false); getMessagesController().putChats(res.chats, false); getLocationController().locationsCache.put(dialog_id, res.messages); getNotificationCenter().postNotificationName(NotificationCenter.liveLocationsCacheChanged, dialog_id); fetchRecentLocations(res.messages); getLocationController().markLiveLoactionsAsRead(dialogId); if (markAsReadRunnable == null) { markAsReadRunnable = () -> { getLocationController().markLiveLoactionsAsRead(dialogId); if (isPaused || markAsReadRunnable == null) { return; } AndroidUtilities.runOnUIThread(markAsReadRunnable, 5000); }; AndroidUtilities.runOnUIThread(markAsReadRunnable, 5000); } }); } }); return messages != null; }