Removing static Context access using LauncherAppState

> This ensures that LauncherAppState is only accessed in the presence of
a valid context

Bug: 33032833
Change-Id: I955e5cb022f8bd6374681ae6c0720a2666d5b750
This commit is contained in:
Sunny Goyal
2017-01-11 10:48:34 -08:00
parent 4130705141
commit 87f784c285
34 changed files with 117 additions and 126 deletions

View File

@@ -16,6 +16,7 @@
package com.android.launcher3.graphics;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.BlurMaskFilter;
@@ -52,8 +53,8 @@ public class ShadowGenerator {
private final Paint mBlurPaint;
private final Paint mDrawPaint;
private ShadowGenerator() {
mIconSize = LauncherAppState.getInstance().getInvariantDeviceProfile().iconBitmapSize;
private ShadowGenerator(Context context) {
mIconSize = LauncherAppState.getIDP(context).iconBitmapSize;
mCanvas = new Canvas();
mBlurPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
mBlurPaint.setMaskFilter(new BlurMaskFilter(mIconSize * BLUR_FACTOR, Blur.NORMAL));
@@ -82,11 +83,11 @@ public class ShadowGenerator {
return result;
}
public static ShadowGenerator getInstance() {
public static ShadowGenerator getInstance(Context context) {
Preconditions.assertNonUiThread();
synchronized (LOCK) {
if (sShadowGenerator == null) {
sShadowGenerator = new ShadowGenerator();
sShadowGenerator = new ShadowGenerator(context);
}
}
return sShadowGenerator;