mirror of
https://github.com/M66B/NetGuard.git
synced 2025-02-24 07:10:50 +00:00
Fixed displaying wrong data
This commit is contained in:
parent
a5b1d3cf31
commit
4463f5b18c
2 changed files with 31 additions and 36 deletions
|
@ -26,6 +26,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -130,11 +131,11 @@ public class AdapterAccess extends CursorAdapter {
|
|||
Util.getProtocolName(protocol, version, true) +
|
||||
" " + daddr + (dport > 0 ? "/" + dport : ""));
|
||||
|
||||
if (Util.isNumericAddress(daddr) && tvDest.getTag() == null)
|
||||
if (Util.isNumericAddress(daddr))
|
||||
new AsyncTask<String, Object, String>() {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
tvDest.setTag(id);
|
||||
ViewCompat.setHasTransientState(tvDest, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -148,12 +149,10 @@ public class AdapterAccess extends CursorAdapter {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(String addr) {
|
||||
Object tag = tvDest.getTag();
|
||||
if (tag != null && (Long) tag == id)
|
||||
tvDest.setText(
|
||||
Util.getProtocolName(protocol, version, true) +
|
||||
" >" + addr + (dport > 0 ? "/" + dport : ""));
|
||||
tvDest.setTag(null);
|
||||
tvDest.setText(
|
||||
Util.getProtocolName(protocol, version, true) +
|
||||
" >" + addr + (dport > 0 ? "/" + dport : ""));
|
||||
ViewCompat.setHasTransientState(tvDest, false);
|
||||
}
|
||||
}.execute(daddr);
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ import android.os.AsyncTask;
|
|||
import android.os.Build;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.util.TypedValue;
|
||||
|
@ -237,32 +238,28 @@ public class AdapterLog extends CursorAdapter {
|
|||
// Show destination address
|
||||
if (resolve && !isKnownAddress(daddr))
|
||||
if (dname == null) {
|
||||
if (tvDaddr.getTag() == null) {
|
||||
tvDaddr.setText(daddr);
|
||||
new AsyncTask<String, Object, String>() {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
tvDaddr.setTag(id);
|
||||
}
|
||||
tvDaddr.setText(daddr);
|
||||
new AsyncTask<String, Object, String>() {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
ViewCompat.setHasTransientState(tvDaddr, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String doInBackground(String... args) {
|
||||
try {
|
||||
return InetAddress.getByName(args[0]).getHostName();
|
||||
} catch (UnknownHostException ignored) {
|
||||
return args[0];
|
||||
}
|
||||
@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) {
|
||||
Object tag = tvDaddr.getTag();
|
||||
if (tag != null && (Long) tag == id)
|
||||
tvDaddr.setText(">" + name);
|
||||
tvDaddr.setTag(null);
|
||||
}
|
||||
}.execute(daddr);
|
||||
}
|
||||
@Override
|
||||
protected void onPostExecute(String name) {
|
||||
tvDaddr.setText(">" + name);
|
||||
ViewCompat.setHasTransientState(tvDaddr, false);
|
||||
}
|
||||
}.execute(daddr);
|
||||
} else
|
||||
tvDaddr.setText(dname);
|
||||
else
|
||||
|
@ -271,11 +268,11 @@ public class AdapterLog extends CursorAdapter {
|
|||
// Show organization
|
||||
tvOrganization.setVisibility(View.GONE);
|
||||
if (organization) {
|
||||
if (!isKnownAddress(daddr) && tvOrganization.getTag() == null)
|
||||
if (!isKnownAddress(daddr))
|
||||
new AsyncTask<String, Object, String>() {
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
tvOrganization.setTag(id);
|
||||
ViewCompat.setHasTransientState(tvOrganization, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -290,12 +287,11 @@ public class AdapterLog extends CursorAdapter {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(String organization) {
|
||||
Object tag = tvOrganization.getTag();
|
||||
if (organization != null && tag != null && (Long) tag == id) {
|
||||
if (organization != null) {
|
||||
tvOrganization.setText(organization);
|
||||
tvOrganization.setVisibility(View.VISIBLE);
|
||||
}
|
||||
tvOrganization.setTag(null);
|
||||
ViewCompat.setHasTransientState(tvOrganization, false);
|
||||
}
|
||||
}.execute(daddr);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue