diff --git a/app/src/main/java/eu/faircode/netguard/AdapterLog.java b/app/src/main/java/eu/faircode/netguard/AdapterLog.java index 6f042f21..def3b843 100644 --- a/app/src/main/java/eu/faircode/netguard/AdapterLog.java +++ b/app/src/main/java/eu/faircode/netguard/AdapterLog.java @@ -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,19 +228,22 @@ public class AdapterLog extends CursorAdapter { icon = Icon.createWithResource(context, android.R.drawable.sym_def_app_icon); else icon = Icon.createWithResource(info.packageName, info.icon); - icon.loadDrawableAsync(context, new Icon.OnDrawableLoadedListener() { - @Override - public void onDrawableLoaded(Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - Bitmap original = ((BitmapDrawable) drawable).getBitmap(); - Bitmap scaled = Bitmap.createScaledBitmap(original, iconSize, iconSize, false); - ivIcon.setImageDrawable(new BitmapDrawable(context.getResources(), scaled)); - } else - ivIcon.setImageDrawable(drawable); - } - }, new Handler(context.getMainLooper())); + try { + icon.loadDrawableAsync(context, new Icon.OnDrawableLoadedListener() { + @Override + public void onDrawableLoaded(Drawable drawable) { + if (drawable instanceof BitmapDrawable) { + Bitmap original = ((BitmapDrawable) drawable).getBitmap(); + Bitmap scaled = Bitmap.createScaledBitmap(original, iconSize, iconSize, false); + ivIcon.setImageDrawable(new BitmapDrawable(context.getResources(), scaled)); + } else + 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 { diff --git a/app/src/main/java/eu/faircode/netguard/AdapterRule.java b/app/src/main/java/eu/faircode/netguard/AdapterRule.java index 5588b1f6..ab62c706 100644 --- a/app/src/main/java/eu/faircode/netguard/AdapterRule.java +++ b/app/src/main/java/eu/faircode/netguard/AdapterRule.java @@ -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 implements Filterable { private static final String TAG = "NetGuard.Adapter"; @@ -342,17 +343,21 @@ public class AdapterRule extends RecyclerView.Adapter im icon = Icon.createWithResource(context, android.R.drawable.sym_def_app_icon); else icon = Icon.createWithResource(rule.info.packageName, rule.info.applicationInfo.icon); - icon.loadDrawableAsync(context, new Icon.OnDrawableLoadedListener() { - @Override - public void onDrawableLoaded(Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - Bitmap original = ((BitmapDrawable) drawable).getBitmap(); - Bitmap scaled = Bitmap.createScaledBitmap(original, iconSize, iconSize, false); - holder.ivIcon.setImageDrawable(new BitmapDrawable(context.getResources(), scaled)); - } else - holder.ivIcon.setImageDrawable(drawable); - } - }, new Handler(context.getMainLooper())); + try { + icon.loadDrawableAsync(context, new Icon.OnDrawableLoadedListener() { + @Override + public void onDrawableLoaded(Drawable drawable) { + if (drawable instanceof BitmapDrawable) { + Bitmap original = ((BitmapDrawable) drawable).getBitmap(); + Bitmap scaled = Bitmap.createScaledBitmap(original, iconSize, iconSize, false); + holder.ivIcon.setImageDrawable(new BitmapDrawable(context.getResources(), scaled)); + } else + 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);