完善魅族必接功能
This commit is contained in:
parent
936267cc85
commit
4a6801185c
@ -25,6 +25,7 @@ import com.meizu.gamesdk.model.model.LoginResultCode;
|
||||
import com.meizu.gamesdk.model.model.MzAccountInfo;
|
||||
import com.meizu.gamesdk.model.model.MzBuyInfo;
|
||||
import com.meizu.gamesdk.model.model.PayResultCode;
|
||||
import com.meizu.gamesdk.online.core.MzGameBarPlatform;
|
||||
import com.meizu.gamesdk.online.core.MzGameCenterPlatform;
|
||||
|
||||
import org.egret.egretnativeandroid.EgretNativeAndroid;
|
||||
@ -40,6 +41,7 @@ public class MainActivity extends Activity implements MzLoginListener, MzPayList
|
||||
private FrameLayout rootLayout = null;
|
||||
private Vibrator vibrator;
|
||||
private MzAccountInfo accountInfo;
|
||||
private MzGameBarPlatform mzGameBarPlatform;
|
||||
|
||||
|
||||
@Override
|
||||
@ -76,18 +78,29 @@ public class MainActivity extends Activity implements MzLoginListener, MzPayList
|
||||
rootLayout = nativeAndroid.getRootFrameLayout();
|
||||
showLoadingView();
|
||||
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
|
||||
//初始化,可以指定gamebar第一次显示的位置,在游戏退出时会记住用户操作的最后一次位置,再次启动时使用上一次的位置
|
||||
//第一次显示的位置可以指定四个方向,左上,左下,右上,右下
|
||||
// public static final int GRAVITY_LEFT_TOP = 1;
|
||||
// public static final int GRAVITY_LEFT_BOTTOM = 2;
|
||||
// public static final int GRAVITY_RIGHT_TOP = 3;
|
||||
// public static final int GRAVITY_RIGHT_BOTTOM = 4;
|
||||
mzGameBarPlatform = new MzGameBarPlatform(this, MzGameBarPlatform.GRAVITY_LEFT_TOP);
|
||||
mzGameBarPlatform.onActivityCreate();
|
||||
mzGameBarPlatform.showGameBar();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
nativeAndroid.pause();
|
||||
mzGameBarPlatform.onActivityPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
nativeAndroid.resume();
|
||||
mzGameBarPlatform.onActivityResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -188,26 +201,23 @@ public class MainActivity extends Activity implements MzLoginListener, MzPayList
|
||||
|
||||
try {
|
||||
JSONObject jsonObject = new JSONObject(message);
|
||||
String cpOrderId = jsonObject.getString("orderId");
|
||||
String productCode = jsonObject.getString("productCode");
|
||||
int count = jsonObject.getInt("count");
|
||||
//TODO: 平台的支付
|
||||
Log.i(TAG, "pay info: " + jsonObject.toString());
|
||||
Bundle buyBundle = new MzBuyInfo()
|
||||
.setBuyCount(1)
|
||||
// .setCpUserInfo(cpUserInfo)
|
||||
// .setOrderAmount(1)
|
||||
// .setOrderId(cpOrderId)
|
||||
// .setPerPrice(count)
|
||||
// .setProductBody(productBody)
|
||||
// .setProductId(productId)
|
||||
// .setProductSubject(productSubject)
|
||||
// .setProductUnit(productUnit)
|
||||
// .setSign(sign)
|
||||
// .setSignType(signType)
|
||||
// .setCreateTime(createTime)
|
||||
// .setAppid(appid)
|
||||
// .setUserUid(uid)
|
||||
// .setPayType(payType)
|
||||
.setBuyCount(jsonObject.getInt("buy_amount"))
|
||||
.setCpUserInfo(jsonObject.getString("user_info"))
|
||||
.setOrderAmount(jsonObject.getString("total_price"))
|
||||
.setOrderId(jsonObject.getString("cp_order_id"))
|
||||
.setPerPrice(jsonObject.getString("product_per_price"))
|
||||
.setProductBody(jsonObject.getString("product_body"))
|
||||
.setProductId(jsonObject.getString("product_id"))
|
||||
.setProductSubject(jsonObject.getString("product_subject"))
|
||||
.setProductUnit(jsonObject.getString("product_unit"))
|
||||
.setSign(jsonObject.getString("sign"))
|
||||
.setSignType(jsonObject.getString("sign_type"))
|
||||
.setCreateTime(jsonObject.getLong("create_time"))
|
||||
.setAppid(jsonObject.getString("app_id"))
|
||||
.setUserUid(jsonObject.getString("uid"))
|
||||
.setPayType(jsonObject.getInt("pay_type"))
|
||||
.toBundle();
|
||||
MzGameCenterPlatform.payOnline(MainActivity.this, buyBundle, MainActivity.this);
|
||||
} catch (JSONException e) {
|
||||
@ -239,6 +249,8 @@ public class MainActivity extends Activity implements MzLoginListener, MzPayList
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
//调一下onActivityDestroy
|
||||
mzGameBarPlatform.onActivityDestroy();
|
||||
}
|
||||
|
||||
private void showLoadingView() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user