mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-26 16:13:01 +00:00
Log view async resolving of IP addresses in host names
This commit is contained in:
parent
868ddf0bef
commit
6ffb7eb861
1 changed files with 21 additions and 1 deletions
|
@ -5,6 +5,7 @@ import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.os.AsyncTask;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
@ -14,6 +15,8 @@ import android.widget.TextView;
|
||||||
|
|
||||||
import com.squareup.picasso.Picasso;
|
import com.squareup.picasso.Picasso;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
|
import java.net.UnknownHostException;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
||||||
public class LogAdapter extends CursorAdapter {
|
public class LogAdapter extends CursorAdapter {
|
||||||
|
@ -72,7 +75,7 @@ public class LogAdapter extends CursorAdapter {
|
||||||
TextView tvFlags = (TextView) view.findViewById(R.id.tvFlags);
|
TextView tvFlags = (TextView) view.findViewById(R.id.tvFlags);
|
||||||
ImageView ivIcon = (ImageView) view.findViewById(R.id.ivIcon);
|
ImageView ivIcon = (ImageView) view.findViewById(R.id.ivIcon);
|
||||||
TextView tvUid = (TextView) view.findViewById(R.id.tvUid);
|
TextView tvUid = (TextView) view.findViewById(R.id.tvUid);
|
||||||
TextView tvIP = (TextView) view.findViewById(R.id.tvIP);
|
final TextView tvIP = (TextView) view.findViewById(R.id.tvIP);
|
||||||
|
|
||||||
// Set values
|
// Set values
|
||||||
tvTime.setText(new SimpleDateFormat("HH:mm:ss").format(time));
|
tvTime.setText(new SimpleDateFormat("HH:mm:ss").format(time));
|
||||||
|
@ -138,5 +141,22 @@ public class LogAdapter extends CursorAdapter {
|
||||||
// tvUid.setText("18888");
|
// tvUid.setText("18888");
|
||||||
|
|
||||||
tvIP.setText(whois);
|
tvIP.setText(whois);
|
||||||
|
|
||||||
|
new AsyncTask<String, Object, String>() {
|
||||||
|
@Override
|
||||||
|
protected String doInBackground(String... args) {
|
||||||
|
try {
|
||||||
|
// This requires internet permission
|
||||||
|
return InetAddress.getByName(args[0]).getHostName();
|
||||||
|
} catch (UnknownHostException ignored) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPostExecute(String host) {
|
||||||
|
tvIP.setText(host);
|
||||||
|
}
|
||||||
|
}.execute(whois);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue