GAS v3.1.2版本的 MD5 值为:c77a6621f0cc481a15721546dcb9858c
以下内容为反编译后的 BaseLocationAdapter.java 源代码,内容仅作参考
package im.blhtcxatrz.ui.adapters;
import com.baidu.location.BDLocation;
import com.baidu.mapapi.model.LatLng;
import com.baidu.mapapi.utils.DistanceUtil;
import im.blhtcxatrz.messenger.AndroidUtilities;
import im.blhtcxatrz.messenger.FileLog;
import im.blhtcxatrz.messenger.MessagesController;
import im.blhtcxatrz.messenger.MessagesStorage;
import im.blhtcxatrz.messenger.UserConfig;
import im.blhtcxatrz.tgnet.ConnectionsManager;
import im.blhtcxatrz.tgnet.RequestDelegate;
import im.blhtcxatrz.tgnet.TLObject;
import im.blhtcxatrz.tgnet.TLRPC;
import im.blhtcxatrz.ui.adapters.BaseLocationAdapter;
import im.blhtcxatrz.ui.components.RecyclerListView;
import java.util.ArrayList;
import java.util.Timer;
import java.util.TimerTask;
public abstract class BaseLocationAdapter extends RecyclerListView.SelectionAdapter {
private int currentRequestNum;
private BaseLocationAdapterDelegate delegate;
private long dialogId;
private BDLocation lastSearchLocation;
private String lastSearchQuery;
private Timer searchTimer;
protected boolean searching;
private boolean searchingUser;
protected ArrayList<TLRPC.TL_messageMediaVenue> places = new ArrayList<>();
protected ArrayList<String> iconUrls = new ArrayList<>();
private int currentAccount = UserConfig.selectedAccount;
public interface BaseLocationAdapterDelegate {
void didLoadedSearchResult(ArrayList<TLRPC.TL_messageMediaVenue> arrayList);
}
public void destroy() {
if (this.currentRequestNum != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.currentRequestNum, true);
this.currentRequestNum = 0;
}
}
public void setDelegate(long did, BaseLocationAdapterDelegate delegate) {
this.dialogId = did;
this.delegate = delegate;
}
public void searchDelayed(String query, BDLocation coordinate) {
if (query == null || query.length() == 0) {
this.places.clear();
notifyDataSetChanged();
return;
}
try {
if (this.searchTimer != null) {
this.searchTimer.cancel();
}
} catch (Exception e) {
FileLog.e(e);
}
Timer timer = new Timer();
this.searchTimer = timer;
timer.schedule(new AnonymousClass1(query, coordinate), 200L, 500L);
}
public class AnonymousClass1 extends TimerTask {
final BDLocation val$coordinate;
final String val$query;
AnonymousClass1(String str, BDLocation bDLocation) {
this.val$query = str;
this.val$coordinate = bDLocation;
}
@Override
public void run() {
try {
BaseLocationAdapter.this.searchTimer.cancel();
BaseLocationAdapter.this.searchTimer = null;
} catch (Exception e) {
FileLog.e(e);
}
final String str = this.val$query;
final BDLocation bDLocation = this.val$coordinate;
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.AnonymousClass1.this.lambda$run$0$BaseLocationAdapter$1(str, bDLocation);
}
});
}
public void lambda$run$0$BaseLocationAdapter$1(String query, BDLocation coordinate) {
BaseLocationAdapter.this.lastSearchLocation = null;
BaseLocationAdapter.this.searchPlacesWithQuery(query, coordinate, true);
}
}
private void searchBotUser() {
if (this.searchingUser) {
return;
}
this.searchingUser = true;
TLRPC.TL_contacts_resolveUsername req = new TLRPC.TL_contacts_resolveUsername();
req.username = MessagesController.getInstance(this.currentAccount).venueSearchBot;
ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
BaseLocationAdapter.this.lambda$searchBotUser$1$BaseLocationAdapter(tLObject, tL_error);
}
});
}
public void lambda$searchBotUser$1$BaseLocationAdapter(final TLObject response, TLRPC.TL_error error) {
if (response != null) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$null$0$BaseLocationAdapter(response);
}
});
}
}
public void lambda$null$0$BaseLocationAdapter(TLObject response) {
TLRPC.TL_contacts_resolvedPeer res = (TLRPC.TL_contacts_resolvedPeer) response;
MessagesController.getInstance(this.currentAccount).putUsers(res.users, false);
MessagesController.getInstance(this.currentAccount).putChats(res.chats, false);
MessagesStorage.getInstance(this.currentAccount).putUsersAndChats(res.users, res.chats, true, true);
BDLocation coord = this.lastSearchLocation;
this.lastSearchLocation = null;
searchPlacesWithQuery(this.lastSearchQuery, coord, false);
}
public void searchPlacesWithQuery(String query, BDLocation coordinate, boolean searchUser) {
LatLng coordLatLng = new LatLng(coordinate.getLatitude(), coordinate.getLongitude());
LatLng lastLatLng = new LatLng(this.lastSearchLocation.getLatitude(), this.lastSearchLocation.getLongitude());
if (coordinate != null) {
if (this.lastSearchLocation != null && DistanceUtil.getDistance(lastLatLng, coordLatLng) < 200.0d) {
return;
}
this.lastSearchLocation = coordinate;
this.lastSearchQuery = query;
if (this.searching) {
this.searching = false;
if (this.currentRequestNum != 0) {
ConnectionsManager.getInstance(this.currentAccount).cancelRequest(this.currentRequestNum, true);
this.currentRequestNum = 0;
}
}
this.searching = true;
TLObject object = MessagesController.getInstance(this.currentAccount).getUserOrChat(MessagesController.getInstance(this.currentAccount).venueSearchBot);
if (!(object instanceof TLRPC.User)) {
if (searchUser) {
searchBotUser();
return;
}
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(this.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 | req.flags;
long j = this.dialogId;
int lower_id = (int) j;
int i = (int) (j >> 32);
if (lower_id != 0) {
req.peer = MessagesController.getInstance(this.currentAccount).getInputPeer(lower_id);
} else {
req.peer = new TLRPC.TL_inputPeerEmpty();
}
this.currentRequestNum = ConnectionsManager.getInstance(this.currentAccount).sendRequest(req, new RequestDelegate() {
@Override
public final void run(TLObject tLObject, TLRPC.TL_error tL_error) {
BaseLocationAdapter.this.lambda$searchPlacesWithQuery$3$BaseLocationAdapter(tLObject, tL_error);
}
});
notifyDataSetChanged();
}
}
public void lambda$searchPlacesWithQuery$3$BaseLocationAdapter(final TLObject response, final TLRPC.TL_error error) {
AndroidUtilities.runOnUIThread(new Runnable() {
@Override
public final void run() {
BaseLocationAdapter.this.lambda$null$2$BaseLocationAdapter(error, response);
}
});
}
public void lambda$null$2$BaseLocationAdapter(TLRPC.TL_error error, TLObject response) {
this.currentRequestNum = 0;
this.searching = false;
this.places.clear();
this.iconUrls.clear();
if (error != null) {
BaseLocationAdapterDelegate baseLocationAdapterDelegate = this.delegate;
if (baseLocationAdapterDelegate != null) {
baseLocationAdapterDelegate.didLoadedSearchResult(this.places);
}
} else {
TLRPC.messages_BotResults res = (TLRPC.messages_BotResults) response;
int size = res.results.size();
for (int a = 0; a < size; a++) {
TLRPC.BotInlineResult result = res.results.get(a);
if ("venue".equals(result.type) && (result.send_message instanceof TLRPC.TL_botInlineMessageMediaVenue)) {
TLRPC.TL_botInlineMessageMediaVenue mediaVenue = (TLRPC.TL_botInlineMessageMediaVenue) result.send_message;
ArrayList<String> arrayList = this.iconUrls;
arrayList.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;
this.places.add(venue);
}
}
}
notifyDataSetChanged();
}
}