Skip to content

Commit

Permalink
Merge pull request jarnik#3 from joonjoonjoon/patch-1
Browse files Browse the repository at this point in the history
Added code to get GamerInfo
  • Loading branch information
jarnik committed Jan 30, 2014
2 parents 9c133a5 + af4795b commit 9accfb7
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/IAPHandler.hx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class IAPHandler
public var requestProductListCall:Dynamic;
public var getProductListIDsCall:Dynamic;
public var requestReceiptsCall:Dynamic;
public var requestGamerInfoCall:Dynamic;
public var getReceiptProductIDsCall:Dynamic;
public var requestPurchaseCall:Dynamic;
public var getLastPurchasedProductIDCall:Dynamic;
Expand All @@ -35,6 +36,8 @@ class IAPHandler
trace("=================== JNI linking methods...");
initCall = openfl.utils.JNI.createStaticMethod
("com.jarnik.iaptest.OUYA_IAP", "init", "(Lorg/haxe/lime/HaxeObject;Ltv/ouya/console/api/OuyaFacade;Ljava/lang/String;)V", true);
requestGamerInfoCall = openfl.utils.JNI.createStaticMethod
("com.jarnik.iaptest.OUYA_IAP", "requestGamerInfo", "()V", true);
requestProductListCall = openfl.utils.JNI.createStaticMethod
("com.jarnik.iaptest.OUYA_IAP", "requestProductList", "([Ljava/lang/String;)V", true);
getProductListIDsCall = openfl.utils.JNI.createStaticMethod
Expand Down Expand Up @@ -89,6 +92,22 @@ class IAPHandler

// ==================================== CALLBACKS - OVERRIDE THESE! =======================

// === get username
public function onGamerInfoReceived(username:String)
{
trace("=== onGamerInfoReceived! " + username);
}

public function onGamerInfoFailed(error:String)
{
trace("=== onGamerInfoFailed! " + error);
}

public function onGamerInfoCanceled()
{
trace("=== onGamerInfoCanceled! " );
}

// ==== Product List
public function onProductListReceived()
{
Expand Down
24 changes: 24 additions & 0 deletions src/java/com/jarnik/iaptest/OUYA_IAP.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,31 @@ public static void init(final HaxeObject callback, OuyaFacade ouyaFacade, String
Log.e("IAP", "Unable to create encryption key", e);
}
}
// ======================================== GAMER INFO ======================================
public static void requestGamerInfo()
{
mOuyaFacade.requestGamerInfo(new GamerInfoLister());
}

public static class GamerInfoLister implements OuyaResponseListener<GamerInfo>
{
@Override
public void onSuccess(GamerInfo gamerInfoResponse) {
mCallback.call("onGamerInfoReceived", new Object[] { gamerInfoResponse.getUsername() } );
}

@Override
public void onFailure(int errorCode, String errorMessage, Bundle optionalData) {
mCallback.call("onGamerInfoFailed", new Object[] { errorCode+": "+errorMessage } );
}

@Override
public void onCancel() {
mCallback.call("onGamerInfoCanceled", new Object[] {} );
}
}


// ======================================= PRODUCT LIST =====================================================

public static void requestProductList(String[] products)
Expand Down

0 comments on commit 9accfb7

Please sign in to comment.