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. */
|
/** 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>() {
|
GKLocalPlayer.getLocalPlayer().setAuthenticateHandler(new VoidBlock2<UIViewController, NSError>() {
|
||||||
@Override
|
@Override
|
||||||
public void invoke (UIViewController viewController, NSError error) {
|
public void invoke (UIViewController viewController, NSError error) {
|
||||||
@@ -51,7 +51,7 @@ public class GameCenter {
|
|||||||
if (viewController != null) {
|
if (viewController != null) {
|
||||||
System.out.println("Not logged in");
|
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
|
// If the viewController is null and the player is authenticated, the login is completed
|
||||||
else if (GKLocalPlayer.getLocalPlayer().isAuthenticated()) {
|
else if (GKLocalPlayer.getLocalPlayer().isAuthenticated()) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
public boolean didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) {
|
public boolean didFinishLaunching (UIApplication application, UIApplicationLaunchOptions launchOptions) {
|
||||||
transactionObserver = new TransactionObserver();
|
transactionObserver = new TransactionObserver();
|
||||||
SKPaymentQueue.getDefaultQueue().addTransactionObserver(transactionObserver);
|
SKPaymentQueue.getDefaultQueue().addTransactionObserver(transactionObserver);
|
||||||
|
new GameCenter().login(application.getKeyWindow());
|
||||||
return super.didFinishLaunching(application, launchOptions);
|
return super.didFinishLaunching(application, launchOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,7 +32,6 @@ public class IOSLauncher extends IOSApplication.Delegate {
|
|||||||
|
|
||||||
protected IOSApplication createApplication() {
|
protected IOSApplication createApplication() {
|
||||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||||
new GameCenter().login();
|
|
||||||
// config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888;
|
// config.colorFormat = GLKViewDrawableColorFormat.SRGBA8888;
|
||||||
// config.depthFormat = GLKViewDrawableDepthFormat._24;
|
// config.depthFormat = GLKViewDrawableDepthFormat._24;
|
||||||
config.orientationPortrait = false;
|
config.orientationPortrait = false;
|
||||||
|
|||||||
@@ -18,26 +18,57 @@ public class TransactionObserver extends SKPaymentTransactionObserverAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatedTransactions(SKPaymentQueue queue, NSArray<SKPaymentTransaction> transactions) {
|
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);
|
((IFn) RT.var("advent.ios", "updated-transactions").deref()).invoke(queue, transactions);
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.toString());
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updatedDownloads(SKPaymentQueue queue, NSArray<SKDownload> downloads) {
|
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
|
@Override
|
||||||
public void restoreCompletedTransactionsFinished(SKPaymentQueue queue) {
|
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
|
@Override
|
||||||
public void restoreCompletedTransactionsFailed(SKPaymentQueue queue, NSError error) {
|
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
|
@Override
|
||||||
public void removedTransactions(SKPaymentQueue queue, NSArray<SKPaymentTransaction> transactions) {
|
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