Permalink
Browse files

Hopefully fix crash when not running

Signed-off-by: Jimmy Theis <jimmy@jetheis.com>
  • Loading branch information...
1 parent 281999f commit c238b97de2e6aa4df9c0052e04bf1c70b96176e9 @jetheis committed Apr 29, 2012
@@ -87,6 +87,10 @@ public void onCreate(Bundle savedInstanceState) {
activateVipMode();
} else if (Constants.LICENSE_TYPE == LicenseType.GOOGLE_PLAY) {
+ if (GooglePlayBillingWrapper.isInitialized()) {
+ GooglePlayBillingWrapper.destroyInstance();
+ }
+
mBilling = GooglePlayBillingWrapper.initializeInstance(this,
new OnGooglePlayBillingReadyListener() {
@@ -36,6 +36,10 @@
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
+
+ if (!GooglePlayBillingWrapper.isInitialized()) {
+ GooglePlayBillingWrapper.initializeInstance(context, null, null);
+ }
Log.v(Constants.TAG, "Received Google Play intent: " + action);
@@ -98,6 +98,10 @@ public static GooglePlayBillingWrapper getInstance() {
return sInstance;
}
+
+ public static boolean isInitialized() {
+ return sInstance == null;
+ }
public static void destroyInstance() {
if (sInstance != null) {
@@ -130,10 +134,14 @@ public void onGooglePlayBillingSupportResultFound(
boolean billingSupported) {
if (billingSupported) {
Log.i(Constants.TAG, "Google Play billing ready");
- mOnReadyListener.onGooglePlayBillingReady();
+ if (mOnReadyListener != null) {
+ mOnReadyListener.onGooglePlayBillingReady();
+ }
} else {
Log.i(Constants.TAG, "Google Play billing is not supported");
- mOnReadyListener.onGooglePlayBillingNotSupported();
+ if (mOnReadyListener != null) {
+ mOnReadyListener.onGooglePlayBillingNotSupported();
+ }
}
}
@@ -273,7 +281,9 @@ public void handleJsonResponse(String response, String signature) {
+ DateFormat.getLongDateFormat(mContext).format(purchaseDate));
if (productId.equals(Constants.GOOGLE_PLAY_PRODUCT_ID)) {
- mOnPurchaseListnener.onGooglePlayVipModePurchaseFound();
+ if (mOnPurchaseListnener != null) {
+ mOnPurchaseListnener.onGooglePlayVipModePurchaseFound();
+ }
} else {
Log.e(Constants.TAG, "Product id " + productId + " not recognized");
}

0 comments on commit c238b97

Please sign in to comment.