1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2024-12-26 09:48:46 +00:00

Prevent double name lookups

This commit is contained in:
M66B 2016-02-14 10:16:44 +01:00
parent bb3f4bf212
commit 46b054b9f8
2 changed files with 30 additions and 19 deletions

View file

@ -117,9 +117,13 @@ public class AdapterAccess extends CursorAdapter {
Util.getProtocolName(protocol, version, true) +
" " + daddr + (dport > 0 ? "/" + dport : ""));
if (Util.isNumericAddress(daddr)) {
tvDest.setTag(id);
if (Util.isNumericAddress(daddr) && tvDest.getTag() == null)
new AsyncTask<String, Object, String>() {
@Override
protected void onPreExecute() {
tvDest.setTag(id);
}
@Override
protected String doInBackground(String... args) {
try {
@ -135,9 +139,9 @@ public class AdapterAccess extends CursorAdapter {
tvDest.setText(
Util.getProtocolName(protocol, version, true) +
" " + addr + (dport > 0 ? "/" + dport : ""));
tvDest.setTag(null);
}
}.execute(daddr);
}
if (allowed < 0)
tvDest.setTextColor(colorText);

View file

@ -220,24 +220,31 @@ public class AdapterLog extends CursorAdapter {
if (resolve && !isKnownAddress(daddr))
if (dname == null) {
tvDaddr.setText(daddr);
tvDaddr.setTag(id);
new AsyncTask<String, Object, String>() {
@Override
protected String doInBackground(String... args) {
try {
return InetAddress.getByName(args[0]).getHostName();
} catch (UnknownHostException ignored) {
return args[0];
if (tvDaddr.getTag() == null) {
tvDaddr.setText(daddr);
new AsyncTask<String, Object, String>() {
@Override
protected void onPreExecute() {
tvDaddr.setTag(id);
}
}
@Override
protected void onPostExecute(String name) {
if ((Long) tvDaddr.getTag() == id)
tvDaddr.setText(name);
}
}.execute(daddr);
@Override
protected String doInBackground(String... args) {
try {
return InetAddress.getByName(args[0]).getHostName();
} catch (UnknownHostException ignored) {
return args[0];
}
}
@Override
protected void onPostExecute(String name) {
if ((Long) tvDaddr.getTag() == id)
tvDaddr.setText(name);
tvDaddr.setTag(null);
}
}.execute(daddr);
}
} else
tvDaddr.setText(dname);
else