mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-27 00:23:11 +00:00
parent
33669a43c1
commit
1f341837b9
1 changed files with 28 additions and 16 deletions
|
@ -18,6 +18,8 @@ import com.squareup.picasso.Picasso;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.UnknownHostException;
|
import java.net.UnknownHostException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class LogAdapter extends CursorAdapter {
|
public class LogAdapter extends CursorAdapter {
|
||||||
private int colTime;
|
private int colTime;
|
||||||
|
@ -30,6 +32,7 @@ public class LogAdapter extends CursorAdapter {
|
||||||
private int colConnection;
|
private int colConnection;
|
||||||
private int colInteractive;
|
private int colInteractive;
|
||||||
private int colAllowed;
|
private int colAllowed;
|
||||||
|
private Map<String, String> mapIPHost = new HashMap<String, String>();
|
||||||
|
|
||||||
public LogAdapter(Context context, Cursor cursor) {
|
public LogAdapter(Context context, Cursor cursor) {
|
||||||
super(context, cursor, 0);
|
super(context, cursor, 0);
|
||||||
|
@ -140,8 +143,11 @@ public class LogAdapter extends CursorAdapter {
|
||||||
// tvFlags.setText("+APFR");
|
// tvFlags.setText("+APFR");
|
||||||
// tvUid.setText("18888");
|
// tvUid.setText("18888");
|
||||||
|
|
||||||
|
synchronized (mapIPHost) {
|
||||||
|
if (mapIPHost.containsKey(whois))
|
||||||
|
tvIP.setText(mapIPHost.get(whois));
|
||||||
|
else {
|
||||||
tvIP.setText(whois);
|
tvIP.setText(whois);
|
||||||
|
|
||||||
new AsyncTask<String, Object, String>() {
|
new AsyncTask<String, Object, String>() {
|
||||||
@Override
|
@Override
|
||||||
protected String doInBackground(String... args) {
|
protected String doInBackground(String... args) {
|
||||||
|
@ -149,14 +155,20 @@ public class LogAdapter extends CursorAdapter {
|
||||||
// This requires internet permission
|
// This requires internet permission
|
||||||
return InetAddress.getByName(args[0]).getHostName();
|
return InetAddress.getByName(args[0]).getHostName();
|
||||||
} catch (UnknownHostException ignored) {
|
} catch (UnknownHostException ignored) {
|
||||||
return null;
|
return whois;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPostExecute(String host) {
|
protected void onPostExecute(String host) {
|
||||||
|
synchronized (mapIPHost) {
|
||||||
|
if (!mapIPHost.containsKey(host))
|
||||||
|
mapIPHost.put(host, host);
|
||||||
|
}
|
||||||
tvIP.setText(host);
|
tvIP.setText(host);
|
||||||
}
|
}
|
||||||
}.execute(whois);
|
}.execute(whois);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue