Java Code Examples for org.telegram.tgnet.TLRPC#TL_inputGeoPoint
The following examples show how to use
org.telegram.tgnet.TLRPC#TL_inputGeoPoint .
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: WebFile.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static WebFile createWithGeoPoint(double lat, double _long, long access_hash, int w, int h, int zoom, int scale) { WebFile webFile = new WebFile(); TLRPC.TL_inputWebFileGeoPointLocation location = new TLRPC.TL_inputWebFileGeoPointLocation(); webFile.location = location; location.geo_point = webFile.geo_point = new TLRPC.TL_inputGeoPoint(); location.access_hash = access_hash; webFile.geo_point.lat = lat; webFile.geo_point._long = _long; location.w = webFile.w = w; location.h = webFile.h = h; location.zoom = webFile.zoom = zoom; location.scale = webFile.scale = scale; webFile.mime_type = "image/png"; webFile.url = String.format(Locale.US, "maps_%.6f_%.6f_%d_%d_%d_%d.png", lat, _long, w, h, zoom, scale); webFile.attributes = new ArrayList<>(); return webFile; }
Example 2
Source File: WebFile.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static WebFile createWithGeoPoint(double lat, double _long, long access_hash, int w, int h, int zoom, int scale) { WebFile webFile = new WebFile(); TLRPC.TL_inputWebFileGeoPointLocation location = new TLRPC.TL_inputWebFileGeoPointLocation(); webFile.location = location; location.geo_point = webFile.geo_point = new TLRPC.TL_inputGeoPoint(); location.access_hash = access_hash; webFile.geo_point.lat = lat; webFile.geo_point._long = _long; location.w = webFile.w = w; location.h = webFile.h = h; location.zoom = webFile.zoom = zoom; location.scale = webFile.scale = scale; webFile.mime_type = "image/png"; webFile.url = String.format(Locale.US, "maps_%.6f_%.6f_%d_%d_%d_%d.png", lat, _long, w, h, zoom, scale); webFile.attributes = new ArrayList<>(); return webFile; }
Example 3
Source File: WebFile.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static WebFile createWithGeoPoint(double lat, double _long, long access_hash, int w, int h, int zoom, int scale) { WebFile webFile = new WebFile(); TLRPC.TL_inputWebFileGeoPointLocation location = new TLRPC.TL_inputWebFileGeoPointLocation(); webFile.location = location; location.geo_point = webFile.geo_point = new TLRPC.TL_inputGeoPoint(); location.access_hash = access_hash; webFile.geo_point.lat = lat; webFile.geo_point._long = _long; location.w = webFile.w = w; location.h = webFile.h = h; location.zoom = webFile.zoom = zoom; location.scale = webFile.scale = scale; webFile.mime_type = "image/png"; webFile.url = String.format(Locale.US, "maps_%.6f_%.6f_%d_%d_%d_%d.png", lat, _long, w, h, zoom, scale); webFile.attributes = new ArrayList<>(); return webFile; }
Example 4
Source File: WebFile.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static WebFile createWithGeoPoint(double lat, double _long, long access_hash, int w, int h, int zoom, int scale) { WebFile webFile = new WebFile(); TLRPC.TL_inputWebFileGeoPointLocation location = new TLRPC.TL_inputWebFileGeoPointLocation(); webFile.location = location; location.geo_point = webFile.geo_point = new TLRPC.TL_inputGeoPoint(); location.access_hash = access_hash; webFile.geo_point.lat = lat; webFile.geo_point._long = _long; location.w = webFile.w = w; location.h = webFile.h = h; location.zoom = webFile.zoom = zoom; location.scale = webFile.scale = scale; webFile.mime_type = "image/png"; webFile.url = String.format(Locale.US, "maps_%.6f_%.6f_%d_%d_%d_%d.png", lat, _long, w, h, zoom, scale); webFile.attributes = new ArrayList<>(); return webFile; }
Example 5
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void broadcastLastKnownLocation() { if (lastKnownLocation == null) { return; } if (requests.size() != 0) { for (int a = 0; a < requests.size(); a++) { ConnectionsManager.getInstance(currentAccount).cancelRequest(requests.keyAt(a), false); } requests.clear(); } int date = ConnectionsManager.getInstance(currentAccount).getCurrentTime(); for (int a = 0; a < sharingLocations.size(); a++) { final SharingLocationInfo info = sharingLocations.get(a); if (info.messageObject.messageOwner.media != null && info.messageObject.messageOwner.media.geo != null) { int messageDate = info.messageObject.messageOwner.edit_date != 0 ? info.messageObject.messageOwner.edit_date : info.messageObject.messageOwner.date; TLRPC.GeoPoint point = info.messageObject.messageOwner.media.geo; if (Math.abs(date - messageDate) < 30 && Math.abs(point.lat - lastKnownLocation.getLatitude()) <= eps && Math.abs(point._long - lastKnownLocation.getLongitude()) <= eps) { continue; } } TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) info.did); req.id = info.mid; req.stop_geo_live = false; req.flags |= 8192; req.geo_point = new TLRPC.TL_inputGeoPoint(); req.geo_point.lat = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLatitude()); req.geo_point._long = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLongitude()); final int[] reqId = new int[1]; reqId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error != null) { if (error.text.equals("MESSAGE_ID_INVALID")) { sharingLocations.remove(info); sharingLocationsMap.remove(info.did); saveSharingLocation(info, 1); requests.delete(reqId[0]); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { sharingLocationsUI.remove(info); sharingLocationsMapUI.remove(info.did); if (sharingLocationsUI.isEmpty()) { stopService(); } NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged); } }); } return; } TLRPC.Updates updates = (TLRPC.Updates) response; boolean updated = false; for (int a = 0; a < updates.updates.size(); a++) { TLRPC.Update update = updates.updates.get(a); if (update instanceof TLRPC.TL_updateEditMessage) { updated = true; info.messageObject.messageOwner = ((TLRPC.TL_updateEditMessage) update).message; } else if (update instanceof TLRPC.TL_updateEditChannelMessage) { updated = true; info.messageObject.messageOwner = ((TLRPC.TL_updateEditChannelMessage) update).message; } } if (updated) { saveSharingLocation(info, 0); } MessagesController.getInstance(currentAccount).processUpdates(updates, false); } }); requests.put(reqId[0], 0); } ConnectionsManager.getInstance(currentAccount).resumeNetworkMaybe(); stop(false); }
Example 6
Source File: BaseLocationAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void searchPlacesWithQuery(final String query, final Location coordinate, boolean searchUser) { if (coordinate == null || lastSearchLocation != null && coordinate.distanceTo(lastSearchLocation) < 200) { return; } lastSearchLocation = coordinate; lastSearchQuery = query; if (searching) { searching = false; if (currentRequestNum != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(currentRequestNum, true); currentRequestNum = 0; } } searching = true; TLObject object = MessagesController.getInstance(currentAccount).getUserOrChat(MessagesController.getInstance(currentAccount).venueSearchBot); if (!(object instanceof TLRPC.User)) { if (searchUser) { searchBotUser(); } return; } TLRPC.User user = (TLRPC.User) object; TLRPC.TL_messages_getInlineBotResults req = new TLRPC.TL_messages_getInlineBotResults(); req.query = query == null ? "" : query; req.bot = MessagesController.getInstance(currentAccount).getInputUser(user); req.offset = ""; req.geo_point = new TLRPC.TL_inputGeoPoint(); req.geo_point.lat = AndroidUtilities.fixLocationCoord(coordinate.getLatitude()); req.geo_point._long = AndroidUtilities.fixLocationCoord(coordinate.getLongitude()); req.flags |= 1; int lower_id = (int) dialogId; int high_id = (int) (dialogId >> 32); if (lower_id != 0) { req.peer = MessagesController.getInstance(currentAccount).getInputPeer(lower_id); } else { req.peer = new TLRPC.TL_inputPeerEmpty(); } currentRequestNum = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { currentRequestNum = 0; searching = false; places.clear(); iconUrls.clear(); if (error != null) { if (delegate != null) { delegate.didLoadedSearchResult(places); } } else { TLRPC.messages_BotResults res = (TLRPC.messages_BotResults) response; for (int a = 0, size = res.results.size(); a < size; a++) { TLRPC.BotInlineResult result = res.results.get(a); if (!"venue".equals(result.type) || !(result.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue)) { continue; } TLRPC.TL_botInlineMessageMediaVenue mediaVenue = (TLRPC.TL_botInlineMessageMediaVenue) result.send_message; iconUrls.add("https://ss3.4sqi.net/img/categories_v2/" + mediaVenue.venue_type + "_64.png"); TLRPC.TL_messageMediaVenue venue = new TLRPC.TL_messageMediaVenue(); venue.geo = mediaVenue.geo; venue.address = mediaVenue.address; venue.title = mediaVenue.title; venue.venue_type = mediaVenue.venue_type; venue.venue_id = mediaVenue.venue_id; venue.provider = mediaVenue.provider; places.add(venue); } } notifyDataSetChanged(); })); notifyDataSetChanged(); }
Example 7
Source File: LocationController.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void broadcastLastKnownLocation() { if (lastKnownLocation == null) { return; } if (requests.size() != 0) { for (int a = 0; a < requests.size(); a++) { ConnectionsManager.getInstance(currentAccount).cancelRequest(requests.keyAt(a), false); } requests.clear(); } int date = ConnectionsManager.getInstance(currentAccount).getCurrentTime(); for (int a = 0; a < sharingLocations.size(); a++) { final SharingLocationInfo info = sharingLocations.get(a); if (info.messageObject.messageOwner.media != null && info.messageObject.messageOwner.media.geo != null) { int messageDate = info.messageObject.messageOwner.edit_date != 0 ? info.messageObject.messageOwner.edit_date : info.messageObject.messageOwner.date; TLRPC.GeoPoint point = info.messageObject.messageOwner.media.geo; if (Math.abs(date - messageDate) < 30 && Math.abs(point.lat - lastKnownLocation.getLatitude()) <= eps && Math.abs(point._long - lastKnownLocation.getLongitude()) <= eps) { continue; } } TLRPC.TL_messages_editMessage req = new TLRPC.TL_messages_editMessage(); req.peer = MessagesController.getInstance(currentAccount).getInputPeer((int) info.did); req.id = info.mid; req.stop_geo_live = false; req.flags |= 8192; req.geo_point = new TLRPC.TL_inputGeoPoint(); req.geo_point.lat = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLatitude()); req.geo_point._long = AndroidUtilities.fixLocationCoord(lastKnownLocation.getLongitude()); final int[] reqId = new int[1]; reqId[0] = ConnectionsManager.getInstance(currentAccount).sendRequest(req, new RequestDelegate() { @Override public void run(TLObject response, TLRPC.TL_error error) { if (error != null) { if (error.text.equals("MESSAGE_ID_INVALID")) { sharingLocations.remove(info); sharingLocationsMap.remove(info.did); saveSharingLocation(info, 1); requests.delete(reqId[0]); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { sharingLocationsUI.remove(info); sharingLocationsMapUI.remove(info.did); if (sharingLocationsUI.isEmpty()) { stopService(); } NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.liveLocationsChanged); } }); } return; } TLRPC.Updates updates = (TLRPC.Updates) response; boolean updated = false; for (int a = 0; a < updates.updates.size(); a++) { TLRPC.Update update = updates.updates.get(a); if (update instanceof TLRPC.TL_updateEditMessage) { updated = true; info.messageObject.messageOwner = ((TLRPC.TL_updateEditMessage) update).message; } else if (update instanceof TLRPC.TL_updateEditChannelMessage) { updated = true; info.messageObject.messageOwner = ((TLRPC.TL_updateEditChannelMessage) update).message; } } if (updated) { saveSharingLocation(info, 0); } MessagesController.getInstance(currentAccount).processUpdates(updates, false); } }); requests.put(reqId[0], 0); } ConnectionsManager.getInstance(currentAccount).resumeNetworkMaybe(); stop(false); }
Example 8
Source File: BaseLocationAdapter.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void searchPlacesWithQuery(final String query, final Location coordinate, boolean searchUser) { if (coordinate == null || lastSearchLocation != null && coordinate.distanceTo(lastSearchLocation) < 200) { return; } lastSearchLocation = coordinate; lastSearchQuery = query; if (searching) { searching = false; if (currentRequestNum != 0) { ConnectionsManager.getInstance(currentAccount).cancelRequest(currentRequestNum, true); currentRequestNum = 0; } } searching = true; TLObject object = MessagesController.getInstance(currentAccount).getUserOrChat(MessagesController.getInstance(currentAccount).venueSearchBot); if (!(object instanceof TLRPC.User)) { if (searchUser) { searchBotUser(); } return; } TLRPC.User user = (TLRPC.User) object; TLRPC.TL_messages_getInlineBotResults req = new TLRPC.TL_messages_getInlineBotResults(); req.query = query == null ? "" : query; req.bot = MessagesController.getInstance(currentAccount).getInputUser(user); req.offset = ""; req.geo_point = new TLRPC.TL_inputGeoPoint(); req.geo_point.lat = AndroidUtilities.fixLocationCoord(coordinate.getLatitude()); req.geo_point._long = AndroidUtilities.fixLocationCoord(coordinate.getLongitude()); req.flags |= 1; int lower_id = (int) dialogId; int high_id = (int) (dialogId >> 32); if (lower_id != 0) { req.peer = MessagesController.getInstance(currentAccount).getInputPeer(lower_id); } else { req.peer = new TLRPC.TL_inputPeerEmpty(); } currentRequestNum = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { currentRequestNum = 0; searching = false; places.clear(); iconUrls.clear(); if (error != null) { if (delegate != null) { delegate.didLoadedSearchResult(places); } } else { TLRPC.messages_BotResults res = (TLRPC.messages_BotResults) response; for (int a = 0, size = res.results.size(); a < size; a++) { TLRPC.BotInlineResult result = res.results.get(a); if (!"venue".equals(result.type) || !(result.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue)) { continue; } TLRPC.TL_botInlineMessageMediaVenue mediaVenue = (TLRPC.TL_botInlineMessageMediaVenue) result.send_message; iconUrls.add("https://ss3.4sqi.net/img/categories_v2/" + mediaVenue.venue_type + "_64.png"); TLRPC.TL_messageMediaVenue venue = new TLRPC.TL_messageMediaVenue(); venue.geo = mediaVenue.geo; venue.address = mediaVenue.address; venue.title = mediaVenue.title; venue.venue_type = mediaVenue.venue_type; venue.venue_id = mediaVenue.venue_id; venue.provider = mediaVenue.provider; places.add(venue); } } notifyDataSetChanged(); })); notifyDataSetChanged(); }