attempting to fix race condition.
This commit is contained in:
@@ -43,7 +43,7 @@ public class GameCenter {
|
||||
*/
|
||||
|
||||
/** Do the login logic. If the user has never loged, a dialog will be shown. */
|
||||
public void login () {
|
||||
public void login (final UIWindow window) {
|
||||
GKLocalPlayer.getLocalPlayer().setAuthenticateHandler(new VoidBlock2<UIViewController, NSError>() {
|
||||
@Override
|
||||
public void invoke (UIViewController viewController, NSError error) {
|
||||
@@ -51,7 +51,7 @@ public class GameCenter {
|
||||
if (viewController != null) {
|
||||
System.out.println("Not logged in");
|
||||
|
||||
// keyWindow.getRootViewController().presentViewController(viewController, true, null);
|
||||
window.getRootViewController().presentViewController(viewController, true, null);
|
||||
}
|
||||
// If the viewController is null and the player is authenticated, the login is completed
|
||||
else if (GKLocalPlayer.getLocalPlayer().isAuthenticated()) {
|
||||
|
||||
@@ -20,6 +20,7 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
public boolean didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) {
|
||||
transactionObserver = new TransactionObserver();
|
||||
SKPaymentQueue.getDefaultQueue().addTransactionObserver(transactionObserver);
|
||||
new GameCenter().login(application.getKeyWindow());
|
||||
return super.didFinishLaunching(application, launchOptions);
|
||||
}
|
||||
|
||||
@@ -31,7 +32,6 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
||||
|
||||
protected IOSApplication createApplication() {
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
new GameCenter().login();
|
||||
// config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888;
|
||||
// config.depthFormat = GLKViewDrawableDepthFormat._24;
|
||||
config.orientationPortrait = false;
|
||||
|
||||
@@ -18,26 +18,57 @@ public class TransactionObserver extends SKPaymentTransactionObserverAdapter {
|
||||
|
||||
@Override
|
||||
public void updatedTransactions(SKPaymentQueue queue, NSArray<SKPaymentTransaction> transactions) {
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.ios"));
|
||||
try {
|
||||
((IFn) RT.var("advent.ios", "updated-transactions").deref()).invoke(queue, transactions);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updatedDownloads(SKPaymentQueue queue, NSArray<SKDownload> downloads) {
|
||||
((IFn) RT.var("advent.ios", "updated-downloads").deref()).invoke(queue, downloads);
|
||||
try {
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.ios"));
|
||||
((IFn) RT.var("advent.ios", "updated-downloads").deref()).invoke(queue, downloads);
|
||||
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreCompletedTransactionsFinished(SKPaymentQueue queue) {
|
||||
((IFn) RT.var("advent.ios", "restore-completed-transactions-finished").deref()).invoke(queue);
|
||||
try {
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.ios"));
|
||||
((IFn) RT.var("advent.ios", "restore-completed-transactions-finished").deref()).invoke(queue);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restoreCompletedTransactionsFailed(SKPaymentQueue queue, NSError error) {
|
||||
((IFn) RT.var("advent.ios", "restore-completed-transactions-failed").deref()).invoke(queue, error);
|
||||
try {
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.ios"));
|
||||
((IFn) RT.var("advent.ios", "restore-completed-transactions-failed").deref()).invoke(queue, error);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removedTransactions(SKPaymentQueue queue, NSArray<SKPaymentTransaction> transactions) {
|
||||
((IFn) RT.var("advent.ios", "removed-transactions").deref()).invoke(queue, transactions);
|
||||
try {
|
||||
RT.var("clojure.core", "require").invoke(Symbol.intern("advent.ios"));
|
||||
((IFn) RT.var("advent.ios", "removed-transactions").deref()).invoke(queue, transactions);
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.toString());
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user