正在查看: Telegram v11.13.0 应用的 BaseLocationAdapter.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Telegram v11.13.0 应用的 BaseLocationAdapter.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package org.telegram.ui.Adapters;
import android.location.Location;
import android.text.TextUtils;
import java.util.ArrayList;
import java.util.Locale;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.DialogObject;
import org.telegram.messenger.DispatchQueue;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.UserConfig;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.RequestDelegate;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.Components.ListView.AdapterWithDiffUtils;
public abstract class BaseLocationAdapter extends AdapterWithDiffUtils {
public final boolean biz;
private int currentRequestNum;
private BaseLocationAdapterDelegate delegate;
private long dialogId;
private String lastFoundQuery;
private Location lastSearchLocation;
private String lastSearchQuery;
protected boolean searchInProgress;
private Runnable searchRunnable;
protected boolean searching;
protected boolean searchingLocations;
private boolean searchingUser;
public final boolean stories;
protected boolean searched = false;
protected ArrayList locations = new ArrayList();
protected ArrayList places = new ArrayList();
private int currentAccount = UserConfig.selectedAccount;
public interface BaseLocationAdapterDelegate {
void didLoadSearchResult(ArrayList arrayList);
}
public BaseLocationAdapter(boolean z, boolean z2) {
this.stories = z;
this.biz = z2;
}
public void lambda$searchBotUser$2(TLObject tLObject) {
TLRPC.TL_contacts_resolvedPeer tL_contacts_resolvedPeer = (TLRPC.TL_contacts_resolvedPeer) tLObject;
MessagesController.getInstance(this.currentAccount).putUsers(tL_contacts_resolvedPeer.users, false);
MessagesController.getInstance(this.currentAccount).putChats(tL_contacts_resolvedPeer.chats, false);
MessagesStorage.getInstance(this.currentAccount).putUsersAndChats(tL_contacts_resolvedPeer.users, tL_contacts_resolvedPeer.chats, true, true);
Location location = this.lastSearchLocation;
this.lastSearchLocation = null;
searchPlacesWithQuery(this.lastSearchQuery, location, false);
}
public void lambda$searchBotUser$3(final TLObject tLObject, TLRPC.TL_error tL_error) {
if (tLObject != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$searchBotUser$2(tLObject);
}
});
}
}
public void lambda$searchDelayed$0(String str, Location location) {
this.searchRunnable = null;
this.lastSearchLocation = null;
searchPlacesWithQuery(str, location, true);
}
public void lambda$searchDelayed$1(final String str, final Location location) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$searchDelayed$0(str, location);
}
});
}
public void lambda$searchPlacesWithQuery$4(Location location, String str, ArrayList arrayList) {
this.searchingLocations = false;
if (location == null) {
this.currentRequestNum = 0;
this.searching = false;
this.places.clear();
this.searchInProgress = false;
this.lastFoundQuery = str;
}
this.locations.clear();
this.locations.addAll(arrayList);
update(true);
}
public void lambda$searchPlacesWithQuery$5(java.util.Locale r30, java.lang.String r31, java.util.Locale r32, final android.location.Location r33, final java.lang.String r34) {
throw new UnsupportedOperationException("Method not decompiled: org.telegram.ui.Adapters.BaseLocationAdapter.lambda$searchPlacesWithQuery$5(java.util.Locale, java.lang.String, java.util.Locale, android.location.Location, java.lang.String):void");
}
public void lambda$searchPlacesWithQuery$6(TLRPC.TL_error tL_error, String str, TLObject tLObject) {
if (tL_error == null) {
this.currentRequestNum = 0;
this.searching = false;
this.places.clear();
this.searchInProgress = false;
this.lastFoundQuery = str;
TLRPC.messages_BotResults messages_botresults = (TLRPC.messages_BotResults) tLObject;
int size = messages_botresults.results.size();
for (int i = 0; i < size; i++) {
TLRPC.BotInlineResult botInlineResult = (TLRPC.BotInlineResult) messages_botresults.results.get(i);
if ("venue".equals(botInlineResult.type)) {
TLRPC.TL_botInlineMessageMediaVenue tL_botInlineMessageMediaVenue = botInlineResult.send_message;
if (tL_botInlineMessageMediaVenue instanceof TLRPC.TL_botInlineMessageMediaVenue) {
TLRPC.TL_botInlineMessageMediaVenue tL_botInlineMessageMediaVenue2 = tL_botInlineMessageMediaVenue;
TLRPC.TL_messageMediaVenue tL_messageMediaVenue = new TLRPC.TL_messageMediaVenue();
((TLRPC.MessageMedia) tL_messageMediaVenue).geo = ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).geo;
((TLRPC.MessageMedia) tL_messageMediaVenue).address = ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).address;
((TLRPC.MessageMedia) tL_messageMediaVenue).title = ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).title;
tL_messageMediaVenue.icon = "https://ss3.4sqi.net/img/categories_v2/" + ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).venue_type + "_64.png";
((TLRPC.MessageMedia) tL_messageMediaVenue).venue_type = ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).venue_type;
((TLRPC.MessageMedia) tL_messageMediaVenue).venue_id = ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).venue_id;
((TLRPC.MessageMedia) tL_messageMediaVenue).provider = ((TLRPC.BotInlineMessage) tL_botInlineMessageMediaVenue2).provider;
tL_messageMediaVenue.query_id = messages_botresults.query_id;
tL_messageMediaVenue.result_id = botInlineResult.id;
this.places.add(tL_messageMediaVenue);
}
}
}
}
BaseLocationAdapterDelegate baseLocationAdapterDelegate = this.delegate;
if (baseLocationAdapterDelegate != null) {
baseLocationAdapterDelegate.didLoadSearchResult(this.places);
}
update(true);
}
public void lambda$searchPlacesWithQuery$7(final String str, final TLObject tLObject, final TLRPC.TL_error tL_error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$searchPlacesWithQuery$6(tL_error, str, tLObject);
}
});
}
private void searchBotUser() {
if (this.searchingUser) {
return;
}
this.searchingUser = true;
TLRPC.TL_contacts_resolveUsername tL_contacts_resolveUsername = new TLRPC.TL_contacts_resolveUsername();
tL_contacts_resolveUsername.username = this.stories ? MessagesController.getInstance(this.currentAccount).storyVenueSearchBot : MessagesController.getInstance(this.currentAccount).venueSearchBot;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_contacts_resolveUsername, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
BaseLocationAdapter.this.lambda$searchBotUser$3(tLObject, tL_error);
}
});
}
public void destroy() {
if (this.currentRequestNum != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.currentRequestNum, true);
this.currentRequestNum = 0;
}
}
public String getLastSearchString() {
return this.lastFoundQuery;
}
public boolean isSearching() {
return this.searchInProgress;
}
public void searchDelayed(final String str, final Location location) {
if (str == null || str.length() == 0) {
this.places.clear();
this.locations.clear();
this.searchInProgress = false;
update(true);
return;
}
if (this.searchRunnable != null) {
Utilities.searchQueue.cancelRunnable(this.searchRunnable);
this.searchRunnable = null;
}
this.searchInProgress = true;
DispatchQueue dispatchQueue = Utilities.searchQueue;
Runnable runnable = new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$searchDelayed$1(str, location);
}
};
this.searchRunnable = runnable;
dispatchQueue.postRunnable(runnable, 400L);
}
public void searchPlacesWithQuery(String str, Location location, boolean z) {
searchPlacesWithQuery(str, location, z, false);
}
public void searchPlacesWithQuery(final String str, final Location location, boolean z, boolean z2) {
final Locale locale;
if (location != null || this.stories) {
Location location2 = this.lastSearchLocation;
if (location2 == null || location == null || location.distanceTo(location2) >= 200.0f) {
Locale locale2 = null;
this.lastSearchLocation = location == null ? null : new Location(location);
this.lastSearchQuery = str;
if (this.searching) {
this.searching = false;
if (this.currentRequestNum != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.currentRequestNum, true);
this.currentRequestNum = 0;
}
}
getItemCount();
this.searching = true;
this.searched = true;
TLRPC.User userOrChat = MessagesController.getInstance(this.currentAccount).getUserOrChat(this.stories ? MessagesController.getInstance(this.currentAccount).storyVenueSearchBot : MessagesController.getInstance(this.currentAccount).venueSearchBot);
if (!(userOrChat instanceof TLRPC.User)) {
if (z) {
searchBotUser();
return;
}
return;
}
TLRPC.User user = userOrChat;
TLRPC.TL_messages_getInlineBotResults tL_messages_getInlineBotResults = new TLRPC.TL_messages_getInlineBotResults();
tL_messages_getInlineBotResults.query = str == null ? "" : str;
tL_messages_getInlineBotResults.bot = MessagesController.getInstance(this.currentAccount).getInputUser(user);
tL_messages_getInlineBotResults.offset = "";
if (location != null) {
TLRPC.TL_inputGeoPoint tL_inputGeoPoint = new TLRPC.TL_inputGeoPoint();
tL_messages_getInlineBotResults.geo_point = tL_inputGeoPoint;
((TLRPC.InputGeoPoint) tL_inputGeoPoint).lat = AndroidUtilities.fixLocationCoord(location.getLatitude());
tL_messages_getInlineBotResults.geo_point._long = AndroidUtilities.fixLocationCoord(location.getLongitude());
tL_messages_getInlineBotResults.flags |= 1;
}
tL_messages_getInlineBotResults.peer = DialogObject.isEncryptedDialog(this.dialogId) ? new TLRPC.TL_inputPeerEmpty() : MessagesController.getInstance(this.currentAccount).getInputPeer(this.dialogId);
if (TextUtils.isEmpty(str) || !(this.stories || this.biz)) {
this.searchingLocations = false;
} else {
this.searchingLocations = true;
final Locale currentLocale = LocaleController.getInstance().getCurrentLocale();
if (this.stories) {
if (currentLocale.getLanguage().contains("en")) {
locale = currentLocale;
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$searchPlacesWithQuery$5(currentLocale, str, locale, location, str);
}
});
} else {
locale2 = Locale.US;
}
}
locale = locale2;
Utilities.globalQueue.postRunnable(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$searchPlacesWithQuery$5(currentLocale, str, locale, location, str);
}
});
}
if (location == null) {
return;
}
this.currentRequestNum = ConnectionsManager.getInstance(this.currentAccount).sendRequest(tL_messages_getInlineBotResults, new RequestDelegate() {
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
BaseLocationAdapter.this.lambda$searchPlacesWithQuery$7(str, tLObject, tL_error);
}
});
update(true);
}
}
}
public void setDelegate(long j, BaseLocationAdapterDelegate baseLocationAdapterDelegate) {
this.dialogId = j;
this.delegate = baseLocationAdapterDelegate;
}
protected void update(boolean z) {
notifyDataSetChanged();
}
}