mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-03 17:36:49 +00:00
Making LauncherIcons thread safe
Creating a pool of LauncherIcons so that they can be used from multiple threads Change-Id: Idc7b5ddb47b6e338a5389f3c4faa6f63de108c72
This commit is contained in:
@@ -46,17 +46,13 @@ public class ShadowGenerator {
|
||||
|
||||
private static final int AMBIENT_SHADOW_ALPHA = 30;
|
||||
|
||||
private static final Object LOCK = new Object();
|
||||
// Singleton object guarded by {@link #LOCK}
|
||||
private static ShadowGenerator sShadowGenerator;
|
||||
|
||||
private final int mIconSize;
|
||||
|
||||
private final Paint mBlurPaint;
|
||||
private final Paint mDrawPaint;
|
||||
private final BlurMaskFilter mDefaultBlurMaskFilter;
|
||||
|
||||
private ShadowGenerator(Context context) {
|
||||
public ShadowGenerator(Context context) {
|
||||
mIconSize = LauncherAppState.getIDP(context).iconBitmapSize;
|
||||
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
|
||||
mDrawPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
|
||||
@@ -86,18 +82,6 @@ public class ShadowGenerator {
|
||||
out.drawBitmap(icon, 0, 0, mDrawPaint);
|
||||
}
|
||||
|
||||
public static ShadowGenerator getInstance(Context context) {
|
||||
// TODO: This currently fails as the system default icon also needs a shadow as it
|
||||
// uses adaptive icon.
|
||||
// Preconditions.assertNonUiThread();
|
||||
synchronized (LOCK) {
|
||||
if (sShadowGenerator == null) {
|
||||
sShadowGenerator = new ShadowGenerator(context);
|
||||
}
|
||||
}
|
||||
return sShadowGenerator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minimum amount by which an icon with {@param bounds} should be scaled
|
||||
* so that the shadows do not get clipped.
|
||||
|
||||
Reference in New Issue
Block a user