1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-01-04 06:23:04 +00:00

Prevent crash

This commit is contained in:
M66B 2017-08-24 17:23:42 +02:00
parent 84cdf13a78
commit 2671c34976
2 changed files with 32 additions and 23 deletions

View file

@ -51,6 +51,7 @@ import java.net.InetAddress;
import java.net.UnknownHostException;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
public class AdapterLog extends CursorAdapter {
private static String TAG = "NetGuard.Log";
@ -227,6 +228,7 @@ public class AdapterLog extends CursorAdapter {
icon = Icon.createWithResource(context, android.R.drawable.sym_def_app_icon);
else
icon = Icon.createWithResource(info.packageName, info.icon);
try {
icon.loadDrawableAsync(context, new Icon.OnDrawableLoadedListener() {
@Override
public void onDrawableLoaded(Drawable drawable) {
@ -238,8 +240,10 @@ public class AdapterLog extends CursorAdapter {
ivIcon.setImageDrawable(drawable);
}
}, new Handler(context.getMainLooper()));
} catch (RejectedExecutionException ex) {
Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
} else {
if (info.icon == 0)
Picasso.with(context).load(android.R.drawable.sym_def_app_icon).into(ivIcon);
else {

View file

@ -76,6 +76,7 @@ import com.squareup.picasso.Picasso;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.RejectedExecutionException;
public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> implements Filterable {
private static final String TAG = "NetGuard.Adapter";
@ -342,6 +343,7 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
icon = Icon.createWithResource(context, android.R.drawable.sym_def_app_icon);
else
icon = Icon.createWithResource(rule.info.packageName, rule.info.applicationInfo.icon);
try {
icon.loadDrawableAsync(context, new Icon.OnDrawableLoadedListener() {
@Override
public void onDrawableLoaded(Drawable drawable) {
@ -353,6 +355,9 @@ public class AdapterRule extends RecyclerView.Adapter<AdapterRule.ViewHolder> im
holder.ivIcon.setImageDrawable(drawable);
}
}, new Handler(context.getMainLooper()));
} catch (RejectedExecutionException ex) {
Log.w(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
}
} else {
if (rule.info.applicationInfo.icon == 0)
Picasso.with(context).load(android.R.drawable.sym_def_app_icon).into(holder.ivIcon);