Commit e845715e17c4721e2bea0880f5e546e8f03c85c6
1 parent
e2adb8e366
Exists in
master
v1.0.4
隐藏支付方式,只显示支付宝
Showing 4 changed files with 4 additions and 4 deletions Inline Diff
InlandSDKDemo/src/com/gump/inland/sdk/demo/MainActivity.java
| 1 | package com.gump.inland.sdk.demo; | 1 | package com.gump.inland.sdk.demo; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | import android.content.Intent; | 4 | import android.content.Intent; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | import android.util.Log; | 6 | import android.util.Log; |
| 7 | import android.view.View; | 7 | import android.view.View; |
| 8 | import android.widget.Button; | 8 | import android.widget.Button; |
| 9 | import android.widget.TextView; | 9 | import android.widget.TextView; |
| 10 | 10 | ||
| 11 | import com.gump.inland.gamesdk.InlandSDK; | 11 | import com.gump.inland.gamesdk.InlandSDK; |
| 12 | import com.gump.inland.gamesdk.InlandSDKCallback; | 12 | import com.gump.inland.gamesdk.InlandSDKCallback; |
| 13 | import com.gump.inland.gamesdk.InlandSDKException; | 13 | import com.gump.inland.gamesdk.InlandSDKException; |
| 14 | import com.gump.inland.gamesdk.bean.GumpUser; | 14 | import com.gump.inland.gamesdk.bean.GumpUser; |
| 15 | import com.gump.inland.gamesdk.bean.PayRequest; | 15 | import com.gump.inland.gamesdk.bean.PayRequest; |
| 16 | import com.gump.inland.gamesdk.callback.PurchaseCallback; | 16 | import com.gump.inland.gamesdk.callback.PurchaseCallback; |
| 17 | import com.gump.inland.gamesdk.passport.Passport; | 17 | import com.gump.inland.gamesdk.passport.Passport; |
| 18 | import com.ninjaonline.R; | 18 | import com.ninjaonline.R; |
| 19 | 19 | ||
| 20 | public class MainActivity extends Activity { | 20 | public class MainActivity extends Activity { |
| 21 | 21 | ||
| 22 | private static final String TAG = "MainActivity"; | 22 | private static final String TAG = "MainActivity"; |
| 23 | private TextView tvSDKInfo; | 23 | private TextView tvSDKInfo; |
| 24 | private TextView tvUserInfo; | 24 | private TextView tvUserInfo; |
| 25 | private TextView tvPurchaseResult; | 25 | private TextView tvPurchaseResult; |
| 26 | private Button btnLogin; | 26 | private Button btnLogin; |
| 27 | private Button btnPay; | 27 | private Button btnPay; |
| 28 | 28 | ||
| 29 | @Override | 29 | @Override |
| 30 | protected void onCreate(Bundle savedInstanceState) { | 30 | protected void onCreate(Bundle savedInstanceState) { |
| 31 | super.onCreate(savedInstanceState); | 31 | super.onCreate(savedInstanceState); |
| 32 | setContentView(R.layout.activity_main); | 32 | setContentView(R.layout.activity_main); |
| 33 | tvSDKInfo = (TextView) findViewById(R.id.sdk_info); | 33 | tvSDKInfo = (TextView) findViewById(R.id.sdk_info); |
| 34 | tvUserInfo = (TextView) findViewById(R.id.user_info); | 34 | tvUserInfo = (TextView) findViewById(R.id.user_info); |
| 35 | tvPurchaseResult = (TextView) findViewById(R.id.purchase_result); | 35 | tvPurchaseResult = (TextView) findViewById(R.id.purchase_result); |
| 36 | btnLogin = (Button) findViewById(R.id.login); | 36 | btnLogin = (Button) findViewById(R.id.login); |
| 37 | btnPay = (Button) findViewById(R.id.purchase); | 37 | btnPay = (Button) findViewById(R.id.purchase); |
| 38 | 38 | ||
| 39 | Log.d(TAG, "MainActivity onCreate"); | 39 | Log.d(TAG, "MainActivity onCreate"); |
| 40 | InlandSDK.setIsDebugEnable(false); | 40 | InlandSDK.setIsDebugEnable(false); |
| 41 | InlandSDK.setScreenLandscape(true); | 41 | InlandSDK.setScreenLandscape(true); |
| 42 | InlandSDK.initializeSDK("10000", "dkfjgljdlgjldjgl"); | 42 | InlandSDK.initializeSDK("10006", "6731f0406495c0a92ea7931f94b307b7"); |
| 43 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { | 43 | Passport.getInstance().registerCallback(new InlandSDKCallback<GumpUser>() { |
| 44 | 44 | ||
| 45 | @Override | 45 | @Override |
| 46 | public void onSuccess(GumpUser result) { | 46 | public void onSuccess(GumpUser result) { |
| 47 | Log.d(TAG, "gumpUser:" + result.toString()); | 47 | Log.d(TAG, "gumpUser:" + result.toString()); |
| 48 | btnLogin.setVisibility(View.GONE); | 48 | btnLogin.setVisibility(View.GONE); |
| 49 | tvUserInfo.setText(formatUserInfo(result)); | 49 | tvUserInfo.setText(formatUserInfo(result)); |
| 50 | btnPay.setVisibility(View.VISIBLE); | 50 | btnPay.setVisibility(View.VISIBLE); |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | public void onError(InlandSDKException error) { | 54 | public void onError(InlandSDKException error) { |
| 55 | Log.d(TAG, "login error:" + error.getMessage()); | 55 | Log.d(TAG, "login error:" + error.getMessage()); |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | @Override | 58 | @Override |
| 59 | public void onCancel() { | 59 | public void onCancel() { |
| 60 | Log.d(TAG, "login be canceled"); | 60 | Log.d(TAG, "login be canceled"); |
| 61 | } | 61 | } |
| 62 | }); | 62 | }); |
| 63 | 63 | ||
| 64 | tvSDKInfo.setText(getSDKInfo()); | 64 | tvSDKInfo.setText(getSDKInfo()); |
| 65 | btnLogin.setOnClickListener(new View.OnClickListener() { | 65 | btnLogin.setOnClickListener(new View.OnClickListener() { |
| 66 | 66 | ||
| 67 | @Override | 67 | @Override |
| 68 | public void onClick(View v) { | 68 | public void onClick(View v) { |
| 69 | Passport.getInstance().login(MainActivity.this); | 69 | Passport.getInstance().login(MainActivity.this); |
| 70 | } | 70 | } |
| 71 | }); | 71 | }); |
| 72 | btnPay.setOnClickListener(new View.OnClickListener() { | 72 | btnPay.setOnClickListener(new View.OnClickListener() { |
| 73 | 73 | ||
| 74 | @Override | 74 | @Override |
| 75 | public void onClick(View v) { | 75 | public void onClick(View v) { |
| 76 | PayRequest payRequest = new PayRequest(); | 76 | PayRequest payRequest = new PayRequest(); |
| 77 | payRequest.setPrice(1); | 77 | payRequest.setPrice(1); |
| 78 | payRequest.setProduct("玄冥剑"); | 78 | payRequest.setProduct("玄冥剑"); |
| 79 | payRequest.setExtOrder("p100201508311731"); | 79 | payRequest.setExtOrder("p100201508311731"); |
| 80 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); | 80 | payRequest.setGumpUid(Passport.getInstance().getGumpUser().getUid()); |
| 81 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { | 81 | InlandSDK.purchase(MainActivity.this, payRequest, new PurchaseCallback() { |
| 82 | 82 | ||
| 83 | @Override | 83 | @Override |
| 84 | public void onPurchaseError(Exception e) { | 84 | public void onPurchaseError(Exception e) { |
| 85 | Log.w(TAG, "purchase error:" + e.getMessage()); | 85 | Log.w(TAG, "purchase error:" + e.getMessage()); |
| 86 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); | 86 | tvPurchaseResult.setText("purchase occured an error:" + e.getMessage()); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | @Override | 89 | @Override |
| 90 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { | 90 | public void onPurchaseSuccess(String gumpTransId, String extOrder) { |
| 91 | Log.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); | 91 | Log.d(TAG, "purchase success:" + gumpTransId + ",extorder:" + extOrder); |
| 92 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); | 92 | tvPurchaseResult.setText("purchase " + gumpTransId + " success,extorder:" + extOrder); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | @Override | 95 | @Override |
| 96 | public void onPurchaseCanceled() { | 96 | public void onPurchaseCanceled() { |
| 97 | Log.d(TAG, "purchase be canceled"); | 97 | Log.d(TAG, "purchase be canceled"); |
| 98 | tvPurchaseResult.setText("purchase be canceled"); | 98 | tvPurchaseResult.setText("purchase be canceled"); |
| 99 | } | 99 | } |
| 100 | }); | 100 | }); |
| 101 | } | 101 | } |
| 102 | }); | 102 | }); |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | @Override | 105 | @Override |
| 106 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { | 106 | protected void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 107 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) | 107 | if (!InlandSDK.onActivityResult(requestCode, resultCode, data)) |
| 108 | super.onActivityResult(requestCode, resultCode, data); | 108 | super.onActivityResult(requestCode, resultCode, data); |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | private String getSDKInfo() { | 111 | private String getSDKInfo() { |
| 112 | StringBuilder str = new StringBuilder(); | 112 | StringBuilder str = new StringBuilder(); |
| 113 | str.append("SDK version:"); | 113 | str.append("SDK version:"); |
| 114 | str.append(InlandSDK.getVersion()); | 114 | str.append(InlandSDK.getVersion()); |
| 115 | str.append("\nappId:"); | 115 | str.append("\nappId:"); |
| 116 | str.append(InlandSDK.getAppId()); | 116 | str.append(InlandSDK.getAppId()); |
| 117 | str.append("\nappKey:"); | 117 | str.append("\nappKey:"); |
| 118 | str.append(InlandSDK.getAppKey()); | 118 | str.append(InlandSDK.getAppKey()); |
| 119 | return str.toString(); | 119 | return str.toString(); |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | private String formatUserInfo(GumpUser user) { | 122 | private String formatUserInfo(GumpUser user) { |
| 123 | StringBuilder str = new StringBuilder(); | 123 | StringBuilder str = new StringBuilder(); |
| 124 | str.append("Logined User information:\n"); | 124 | str.append("Logined User information:\n"); |
| 125 | str.append("userId:" + user.getUid()); | 125 | str.append("userId:" + user.getUid()); |
| 126 | str.append("\nacccountType:" + user.getAccountType()); | 126 | str.append("\nacccountType:" + user.getAccountType()); |
| 127 | str.append("\nsessionKey:" + user.getSessionKey()); | 127 | str.append("\nsessionKey:" + user.getSessionKey()); |
| 128 | return str.toString(); | 128 | return str.toString(); |
| 129 | } | 129 | } |
| 130 | } | 130 | } |
| 131 | 131 |
InlandSDKRelease/libs/InlandSDK_v1.0.3_proguard.jar
No preview for this file type
InlandSDKRelease/libs/InlandSDK_v1.0.4_proguard.jar
No preview for this file type
InlandSDKRelease/res/values/strings.xml
| 1 | <resources> | 1 | <resources> |
| 2 | 2 | ||
| 3 | <string name="user_name_hint">邮箱</string> | 3 | <string name="user_name_hint">邮箱</string> |
| 4 | <string name="password_hint">密码</string> | 4 | <string name="password_hint">密码</string> |
| 5 | <string name="switch_user">切换用户</string> | 5 | <string name="switch_user">切换用户</string> |
| 6 | <string name="loging">加载中……</string> | 6 | <string name="loging">加载中……</string> |
| 7 | <string name="loading">加载中……</string> | 7 | <string name="loading">加载中……</string> |
| 8 | 8 | ||
| 9 | <string name="signup">注册</string> | 9 | <string name="signup">注册</string> |
| 10 | <string name="login">登录</string> | 10 | <string name="login">登录</string> |
| 11 | <string name="quick_play">一键登录</string> | 11 | <string name="quick_play">一键登录</string> |
| 12 | <!-- toast --> | 12 | <!-- toast --> |
| 13 | <string name="illegal_uname_tip">请输入正确的邮箱</string> | 13 | <string name="illegal_uname_tip">请输入正确的邮箱</string> |
| 14 | <string name="illegal_pwd_tip">密码格式不正确 (请输入6–20字符)</string> | 14 | <string name="illegal_pwd_tip">密码格式不正确 (请输入6–20字符)</string> |
| 15 | <string name="illegal_user_exist">邮箱已注册</string> | 15 | <string name="illegal_user_exist">邮箱已注册</string> |
| 16 | <string name="illegal_pwd_invalid">密码不正确,请重试</string> | 16 | <string name="illegal_pwd_invalid">密码不正确,请重试</string> |
| 17 | <string name="illegal_user_not_exist">邮箱未注册</string> | 17 | <string name="illegal_user_not_exist">邮箱未注册</string> |
| 18 | <string name="invalid_email">请输入正确的邮箱</string> | 18 | <string name="invalid_email">请输入正确的邮箱</string> |
| 19 | <string name="login_fail">登录失败</string> | 19 | <string name="login_fail">登录失败</string> |
| 20 | <string name="signup_fail">注册失败</string> | 20 | <string name="signup_fail">注册失败</string> |
| 21 | <string name="signup_success">注册成功</string> | 21 | <string name="signup_success">注册成功</string> |
| 22 | <string name="gen_quick_acc_err">登录失败,请重试</string> | 22 | <string name="gen_quick_acc_err">登录失败,请重试</string> |
| 23 | <string name="quick_login_err">登录失败,请重试</string> | 23 | <string name="quick_login_err">登录失败,请重试</string> |
| 24 | <string name="net_error">网络无法连接,请查看网络设置</string> | 24 | <string name="net_error">网络无法连接,请查看网络设置</string> |
| 25 | 25 | ||
| 26 | <string-array name="payment_channel"> | 26 | <string-array name="payment_channel"> |
| 27 | <item>微信支付</item> | ||
| 28 | <item>支付宝</item> | 27 | <item>支付宝</item> |
| 29 | <item>银联支付</item> | 28 | <!-- <item>银联支付</item> --> |
| 29 | <!-- <item>微信支付</item> --> | ||
| 30 | </string-array> | 30 | </string-array> |
| 31 | <string-array name="payment_channel_without_wx"> | 31 | <string-array name="payment_channel_without_wx"> |
| 32 | <item>支付宝</item> | 32 | <item>支付宝</item> |
| 33 | <item>银联支付</item> | 33 | <!-- <item>银联支付</item> --> |
| 34 | </string-array> | 34 | </string-array> |