From 1f8df36719d66b92920bb6b035ae7e3524e0a75e Mon Sep 17 00:00:00 2001 From: serso Date: Mon, 16 Feb 2015 22:33:58 +0100 Subject: [PATCH] cpp-134: NPE in Application#onCreate Hopefully the problem is fixed Fixes #134 --- .../calculator/CalculatorApplication.java | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java index c02a4f0e..f873a0de 100644 --- a/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java +++ b/android-app/src/main/java/org/solovyev/android/calculator/CalculatorApplication.java @@ -68,7 +68,7 @@ public class CalculatorApplication extends android.app.Application implements Sh @Nonnull static final String MAIL = "se.solovyev@gmail.com"; - private static final String TAG = "Calculator++ Application"; + private static final String TAG = "C++"; public static final String AD_FREE_PRODUCT_ID = "ad_free"; public static final String AD_FREE_P_KEY = "org.solovyev.android.calculator_ad_free"; @@ -94,9 +94,6 @@ public class CalculatorApplication extends android.app.Application implements Sh @Nonnull private final Wizards wizards = new CalculatorWizards(this); - private final boolean withAds; - - @Nonnull private Typeface typeFace; /* @@ -107,16 +104,10 @@ public class CalculatorApplication extends android.app.Application implements Sh ********************************************************************** */ - protected CalculatorApplication(boolean withAds) { - this.withAds = withAds; + public CalculatorApplication() { instance = this; } - public CalculatorApplication() { - this(true); - } - - /* ********************************************************************** * @@ -192,8 +183,6 @@ public class CalculatorApplication extends android.app.Application implements Sh Locator.getInstance().getLogger().debug(TAG, "Application started!"); Locator.getInstance().getNotifier().showDebugMessage(TAG, "Application started!"); - typeFace = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf"); - // we must update the widget when app starts App.getBroadcaster().sendEditorStateChangedIntent(); } @@ -230,6 +219,9 @@ public class CalculatorApplication extends android.app.Application implements Sh @Nonnull public Typeface getTypeFace() { + if (typeFace == null) { + typeFace = Typeface.createFromAsset(getAssets(), "fonts/Roboto-Regular.ttf"); + } return typeFace; }