Compare commits
1 Commits
master
...
gong_dev_g
Author | SHA1 | Date | |
---|---|---|---|
|
1deb197af6 |
@ -1,26 +0,0 @@
|
||||
package com.yunbao.faceunity;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.Instrimport com.yunbao.common.utils.MobclickAgent;ntationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.yunbao.faceunity.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
@ -81,9 +81,9 @@ import myname.pdlive.shayu.R;
|
||||
@Route(path = RouteUtil.PATH_LAUNCHER)
|
||||
public class LauncherActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = "LauncherActivity";
|
||||
private static final int WHAT_GET_CONFIG = 0;
|
||||
private static final int WHAT_COUNT_DOWN = 1;
|
||||
private final String TAG = "LauncherActivity";
|
||||
private final int WHAT_GET_CONFIG = 0;
|
||||
private final int WHAT_COUNT_DOWN = 1;
|
||||
protected Context mContext;
|
||||
private Handler mHandler;
|
||||
private ViewGroup mRoot;
|
||||
|
@ -20,7 +20,7 @@ public class CommonHttpConsts {
|
||||
public static final String DOWNLOAD_GIF = "downloadGif";
|
||||
public static final String GET_BALANCE = "getBalance";
|
||||
public static final String CHECK_TOKEN_INVALID = "checkTokenInvalid";
|
||||
public static final String NOTIFY_GOOGLE = "Charge.google_pay";
|
||||
public static final String NOTIFY_GOOGLE = "Charge.goole_validate_pd";
|
||||
public static final String COMMUNITY_SETREPORT = "Community.setReport";
|
||||
|
||||
public static final String GET_USER_HOME = "getUserHome";
|
||||
|
@ -14,7 +14,6 @@ import com.lzy.okgo.callback.StringCallback;
|
||||
import com.lzy.okgo.model.Response;
|
||||
import com.lzy.okgo.request.PostRequest;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.activity.ErrorActivity;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
@ -400,8 +399,12 @@ public class CommonHttpUtil {
|
||||
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE).params("purchaseToken", purchaseToken).params("productId", productId).params("orderno", orderno).params("package_name", "com.pdlive.shayu").execute(callback);
|
||||
}
|
||||
|
||||
public static void notifyGoogle(String purchaseToken, String orderNo, String tradeNo, String allData, String gps_adid, HttpCallback callback) {
|
||||
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE).params("purchaseToken", purchaseToken).params("orderno", orderNo).params("trade_no", tradeNo).params("allData", allData).params("gps_adid", gps_adid).params("package_name", "com.pdlive.shayu").execute(callback);
|
||||
public static void notifyGoogle(String purchaseToken, String productId, HttpCallback callback) {
|
||||
HttpClient.getInstance().get(CommonHttpConsts.NOTIFY_GOOGLE, CommonHttpConsts.NOTIFY_GOOGLE)
|
||||
.params("purchaseToken", purchaseToken)
|
||||
.params("productId", productId)
|
||||
.params("package_name", "com.pdlive.shayu")
|
||||
.execute(callback);
|
||||
}
|
||||
|
||||
public static void Google_sec_pay(String purchaseToken, String orderNo, String tradeNo, HttpCallback callback) {
|
||||
|
@ -0,0 +1,297 @@
|
||||
package com.yunbao.common.pay.google;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.billingclient.api.BillingClient;
|
||||
import com.android.billingclient.api.BillingClientStateListener;
|
||||
import com.android.billingclient.api.BillingFlowParams;
|
||||
import com.android.billingclient.api.BillingResult;
|
||||
import com.android.billingclient.api.ConsumeParams;
|
||||
import com.android.billingclient.api.ProductDetails;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.android.billingclient.api.PurchasesUpdatedListener;
|
||||
import com.android.billingclient.api.QueryProductDetailsParams;
|
||||
import com.android.billingclient.api.QueryPurchasesParams;
|
||||
import com.google.android.gms.ads.identifier.AdvertisingIdClient;
|
||||
import com.google.android.gms.common.ConnectionResult;
|
||||
import com.google.android.gms.common.GoogleApiAvailability;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.R;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
//谷歌支付
|
||||
public class GooglePlay implements PurchasesUpdatedListener {
|
||||
|
||||
private String TAG = "mLog";
|
||||
private BillingClient billingClient;
|
||||
private GoogleBillingListener billingListener;
|
||||
|
||||
private GooglePlay() {
|
||||
init();
|
||||
}
|
||||
|
||||
private boolean init() {
|
||||
if (getGoogleService() && billingClient == null) {
|
||||
billingClient = BillingClient.newBuilder(CommonAppContext.sInstance)
|
||||
.setListener(this)
|
||||
.enablePendingPurchases()
|
||||
.build();
|
||||
startConnection();
|
||||
return true;
|
||||
}
|
||||
if (billingClient != null && !billingClient.isReady()) {//没有连接的话去连接
|
||||
startConnection();
|
||||
}
|
||||
if (billingClient == null)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
private void startConnection() {
|
||||
if (!billingClient.isReady()) {
|
||||
//请求连接到GooglePay
|
||||
billingClient.startConnection(new BillingClientStateListener() {
|
||||
@Override
|
||||
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
|
||||
int code = billingResult.getResponseCode();
|
||||
if (code != BillingClient.BillingResponseCode.OK) {
|
||||
String msg = billingResult.getDebugMessage();
|
||||
Log.e(TAG, "连接到GooglePay失败 code = " + code + " msg = " + msg);
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "连接到GooglePay成功");
|
||||
}
|
||||
|
||||
//连接失败
|
||||
@Override
|
||||
public void onBillingServiceDisconnected() {
|
||||
Log.e(TAG, "连接到GooglePay失败,请重试");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//点击商品,先查询商品 然后出来支付界面,调用下单
|
||||
public void purchase(Activity activity, String orderNumber, String id) {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
ImmutableList<QueryProductDetailsParams.Product> productList = ImmutableList.of(QueryProductDetailsParams.Product.newBuilder()
|
||||
.setProductId(id)
|
||||
.setProductType(BillingClient.ProductType.INAPP)
|
||||
.build());
|
||||
QueryProductDetailsParams queryProductDetailsParams =
|
||||
QueryProductDetailsParams.newBuilder()
|
||||
.setProductList(productList)
|
||||
.build();
|
||||
billingClient.queryProductDetailsAsync(
|
||||
queryProductDetailsParams,
|
||||
(billingResult, list) -> {
|
||||
//查询商品成功
|
||||
int code = billingResult.getResponseCode();
|
||||
if (code != BillingClient.BillingResponseCode.OK || list == null || list.isEmpty()) {
|
||||
String msg = billingResult.getDebugMessage();
|
||||
Log.e(TAG, "查询商品失败 code = " + code + " msg = " + msg);
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "查询商品成功");
|
||||
buyIt(activity, orderNumber, list.get(0));
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
//开始下单,准备生成订单了
|
||||
private void buyIt(Activity activity, String orderNumber, ProductDetails productDetails) {
|
||||
List<BillingFlowParams.ProductDetailsParams> productDetailsParamsList = new ArrayList<>();
|
||||
productDetailsParamsList.add(BillingFlowParams.ProductDetailsParams.newBuilder()
|
||||
// retrieve a value for "productDetails" by calling queryProductDetailsAsync()
|
||||
.setProductDetails(productDetails)
|
||||
// For one-time products, "setOfferToken" method shouldn't be called.
|
||||
// For subscriptions, to get an offer token, call
|
||||
// ProductDetails.subscriptionOfferDetails() for a list of offers
|
||||
// that are available to the user.
|
||||
//一次性商品不需要传token
|
||||
// .setOfferToken(selectedOfferToken)
|
||||
.build());
|
||||
|
||||
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
|
||||
.setProductDetailsParamsList(productDetailsParamsList)
|
||||
.setObfuscatedAccountId(orderNumber)//好像是账号id
|
||||
.build();
|
||||
|
||||
BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);
|
||||
int code = billingResult.getResponseCode();
|
||||
if (code != BillingClient.BillingResponseCode.OK) {
|
||||
String msg = billingResult.getDebugMessage();
|
||||
Log.e(TAG, "购买商品失败 code = " + code + " msg = " + msg);
|
||||
// ToastUtil.show(getString(R.string.pay_suc));
|
||||
return;
|
||||
}
|
||||
Log.e(TAG, "购买商品 " + productDetails.toString());
|
||||
}
|
||||
|
||||
//消耗商品 支付成功之后,调用我们后台下发商品成功之后,调用消耗
|
||||
public void consume(List<Purchase> list) {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
for (Purchase purchase : list) {
|
||||
getConsumeGoods(purchase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗所有商品
|
||||
*/
|
||||
public void consumeAll() {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
//以下示例展示了如何提取用户的订阅购买交易。请注意,queryPurchasesAsync() 仅返回有效订阅和非消耗型一次性购买交易。
|
||||
QueryPurchasesParams inAppPurchasesQuery = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP).build();
|
||||
billingClient.queryPurchasesAsync(inAppPurchasesQuery, (billingResult, list) -> {
|
||||
if (BillingClient.BillingResponseCode.OK == billingResult.getResponseCode()) {
|
||||
for (Purchase purchase : list) {
|
||||
//0:PurchaseState.UNSPECIFIED_STATE:未知状态
|
||||
//1:PurchaseState.PURCHASED:付款完成
|
||||
//2:PurchaseState.PENDING:购买正在等待付款完成。
|
||||
if (Purchase.PurchaseState.PURCHASED == purchase.getPurchaseState()) {
|
||||
//调用google去消费
|
||||
//如果之后有问题再研究怎么解决掉单的问题
|
||||
CommonHttpUtil.notifyGoogle(purchase.getPurchaseToken(),
|
||||
purchase.getProducts().get(0), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
getConsumeGoods(purchase);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共消费商品接口
|
||||
*/
|
||||
private void getConsumeGoods(Purchase purchase) {
|
||||
if (purchase != null) {
|
||||
Log.i(TAG, "-----开始消耗商品:" + purchase.toString());
|
||||
ConsumeParams.Builder consumeParams = ConsumeParams.newBuilder();
|
||||
consumeParams.setPurchaseToken(purchase.getPurchaseToken());
|
||||
//调用消耗商品方法
|
||||
consumeAsync(consumeParams.build(), purchase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗商品
|
||||
* int SERVICE_TIMEOUT = -3; //服务超时
|
||||
* int FEATURE_NOT_SUPPORTED = -2; //不支持功能
|
||||
* int SERVICE_DISCONNECTED = -1; //服务单元已断开
|
||||
* int OK = 0; //成功
|
||||
* int USER_CANCELED = 1; //用户按上一步或取消对话框
|
||||
* int SERVICE_UNAVAILABLE = 2; //网络连接断开
|
||||
* int BILLING_UNAVAILABLE = 3; //所请求的类型不支持 Google Play 结算服务 AIDL 版本
|
||||
* int ITEM_UNAVAILABLE = 4; //请求的商品已不再出售。
|
||||
* int DEVELOPER_ERROR = 5; //提供给 API 的参数无效。此错误也可能说明应用未针对结算服务正确签名或设置,或者在其清单中缺少必要的权限。
|
||||
* int ERROR = 6; //API 操作期间出现严重错误
|
||||
* int ITEM_ALREADY_OWNED = 7; //未能购买,因为已经拥有此商品
|
||||
* int ITEM_NOT_OWNED = 8; //未能消费,因为尚未拥有此商品
|
||||
*/
|
||||
private void consumeAsync(ConsumeParams consumeParams, Purchase purchase) {
|
||||
if (!init()) {
|
||||
return;
|
||||
}
|
||||
billingClient.consumeAsync(consumeParams, (billingResult, purchaseToken) -> {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
Log.i(TAG, "-----消耗商品成功");
|
||||
} else {
|
||||
Log.i(TAG, "-----消耗商品失败" + billingResult.toString() + "---" + purchaseToken + "--code:" + billingResult.getResponseCode());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List<Purchase> purchases) {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK
|
||||
&& purchases != null) {
|
||||
//支付成功
|
||||
if (billingListener != null)//消耗掉商品放到外面调用我们服务器成功的时候去消耗 todo 暂时注释掉 这样可以模拟掉单的问题
|
||||
billingListener.onPaySuccess(purchases);
|
||||
/*
|
||||
* 一旦您验证了购买交易,您的应用就可以向用户授予使用权了。若要确认与购买交易相关联的用户账号,
|
||||
* 您可以使用 Purchases.products:get 返回的 ProductPurchase.obfuscatedExternalAccountId(适用于应用内商品的购买交易)
|
||||
* 和 Purchases.subscriptions:get 返回的 SubscriptionPurchase.obfuscatedExternalAccountId(适用于服务器端的订阅),
|
||||
* 或者 Purchase.getAccountIdentifiers() 在客户端返回的 obfuscatedAccountId(如果在交易时已使用 setObfuscatedAccountId 设置该 ID)。
|
||||
* */
|
||||
// purchases.get(0).getAccountIdentifiers()
|
||||
for (Purchase purchase : purchases) {
|
||||
Log.d("mLog", "谷歌支付的回调 " + purchase);
|
||||
}
|
||||
} else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {
|
||||
//取消支付了
|
||||
if (billingListener != null)
|
||||
billingListener.onPayFailed(CommonAppContext.sInstance.getString(R.string.pay_cancel));
|
||||
} else {
|
||||
//支付失败
|
||||
if (billingListener != null)
|
||||
billingListener.onPayFailed(CommonAppContext.sInstance.getString(R.string.pay_fail));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测GooglePlay服务是否可用(需要导入包api "com.google.android.gms:play-services-location:11.8.0",也可以不检查,跳过这个代码)
|
||||
*/
|
||||
public boolean getGoogleService() {
|
||||
GoogleApiAvailability googleApiAvailability = GoogleApiAvailability.getInstance();
|
||||
if (googleApiAvailability != null) {
|
||||
int resultCode = googleApiAvailability.isGooglePlayServicesAvailable(CommonAppContext.sInstance);
|
||||
return resultCode == ConnectionResult.SUCCESS;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getAdId() {
|
||||
try {
|
||||
return AdvertisingIdClient.getAdvertisingIdInfo(CommonAppContext.sInstance).getId();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
Log.e("GooglePlay", "获取谷歌的id错误了");
|
||||
}
|
||||
return "google_default_id";
|
||||
}
|
||||
|
||||
public void setBillingListener(GoogleBillingListener listener) {
|
||||
billingListener = listener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 定义接口返回支付结果
|
||||
*/
|
||||
public interface GoogleBillingListener {
|
||||
void onPaySuccess(List<Purchase> purchases);
|
||||
|
||||
void onPayFailed(String msg);
|
||||
}
|
||||
|
||||
public static class GooglePlayHelper {
|
||||
static GooglePlay googlePlay = new GooglePlay();
|
||||
}
|
||||
|
||||
public static GooglePlay getInstance() {
|
||||
return GooglePlayHelper.googlePlay;
|
||||
}
|
||||
}
|
@ -1,10 +1,8 @@
|
||||
package com.yunbao.common.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
@ -108,23 +106,6 @@ public class ToastUtil {
|
||||
Log.i("ts", "ll");
|
||||
Toast.makeText(CommonAppContext.sInstance, s, Toast.LENGTH_SHORT).show();
|
||||
Log.i("ts", "22");
|
||||
|
||||
// long curTime = System.currentTimeMillis();
|
||||
// if (curTime - sLastTime > 2000) {
|
||||
// sLastTime = curTime;
|
||||
// sLastString = s;
|
||||
//// sToast.setText(s);
|
||||
//// sToast.show();
|
||||
// } else {
|
||||
// if (!s.equals(sLastString)) {
|
||||
// sLastTime = curTime;
|
||||
// sLastString = s;
|
||||
// sToast = makeToast();
|
||||
// sToast.setText(s);
|
||||
// sToast.show();
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -43,6 +43,7 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
|
||||
|
||||
public GoogleBillingManage(Activity activity) {
|
||||
this.mContext = activity;
|
||||
queryFailOrder();
|
||||
}
|
||||
|
||||
public void initGooglePay() {
|
||||
@ -117,6 +118,82 @@ public class GoogleBillingManage implements PurchasesUpdatedListener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询失败的订单
|
||||
* skuType :,BillingClient.SkuType.INAPP 内购 BillingClient.SkuType.SUBS订阅
|
||||
* 0:PurchaseState.UNSPECIFIED_STATE:未知状态
|
||||
* 1:PurchaseState.PURCHASED:付款完成
|
||||
* 2:PurchaseState.PENDING:购买正在等待付款完成。
|
||||
*/
|
||||
public void queryFailOrder(/*String skuType*/) {
|
||||
Log.i(TAG, "-查询失败订单(支付成功未消耗)");
|
||||
if (billingClient != null) {
|
||||
billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, new PurchasesResponseListener() {
|
||||
@Override
|
||||
public void onQueryPurchasesResponse(@NonNull BillingResult result, @NonNull List<Purchase> list) {
|
||||
if (BillingClient.BillingResponseCode.OK == result.getResponseCode()) {
|
||||
for (Purchase purchase : list) {
|
||||
//PURCHASED --已购买
|
||||
if (Purchase.PurchaseState.PURCHASED == purchase.getPurchaseState()) {
|
||||
//todo 这里可以同步发送消息到后台 看订单是否下发了 没有就下发一下
|
||||
//调用google去消费
|
||||
getConsumeGoods(purchase);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 公共消费商品接口
|
||||
*/
|
||||
private void getConsumeGoods(Purchase purchase) {
|
||||
if (purchase != null) {
|
||||
Log.i(TAG, "-----开始消耗商品:" + purchase.toString());
|
||||
ConsumeParams.Builder consumeParams = ConsumeParams.newBuilder();
|
||||
consumeParams.setPurchaseToken(purchase.getPurchaseToken());
|
||||
//调用消耗商品方法
|
||||
consumeAsync(consumeParams.build(), purchase);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 消耗商品
|
||||
* int SERVICE_TIMEOUT = -3; //服务超时
|
||||
* int FEATURE_NOT_SUPPORTED = -2; //不支持功能
|
||||
* int SERVICE_DISCONNECTED = -1; //服务单元已断开
|
||||
* int OK = 0; //成功
|
||||
* int USER_CANCELED = 1; //用户按上一步或取消对话框
|
||||
* int SERVICE_UNAVAILABLE = 2; //网络连接断开
|
||||
* int BILLING_UNAVAILABLE = 3; //所请求的类型不支持 Google Play 结算服务 AIDL 版本
|
||||
* int ITEM_UNAVAILABLE = 4; //请求的商品已不再出售。
|
||||
* int DEVELOPER_ERROR = 5; //提供给 API 的参数无效。此错误也可能说明应用未针对结算服务正确签名或设置,或者在其清单中缺少必要的权限。
|
||||
* int ERROR = 6; //API 操作期间出现严重错误
|
||||
* int ITEM_ALREADY_OWNED = 7; //未能购买,因为已经拥有此商品
|
||||
* int ITEM_NOT_OWNED = 8; //未能消费,因为尚未拥有此商品
|
||||
*/
|
||||
public void consumeAsync(ConsumeParams consumeParams, Purchase purchase) {
|
||||
if (billingClient == null) {
|
||||
return;
|
||||
}
|
||||
billingClient.consumeAsync(consumeParams, new ConsumeResponseListener() {
|
||||
@Override
|
||||
public void onConsumeResponse(@NonNull BillingResult billingResult, @NonNull String s) {
|
||||
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
|
||||
Log.i(TAG, "-----消耗商品成功");
|
||||
String pId = purchase.getSkus().get(0);
|
||||
// String price = CommonOkHttpUtils.INSTANCE.getPayPrice(pId);
|
||||
Log.i(TAG, "-----消耗商品成功 ");
|
||||
String productToken = purchase.getPurchaseToken();
|
||||
} else {
|
||||
Log.i(TAG, "-----消耗商品失败" + billingResult.toString() + "---" + s + "--code:" + billingResult.getResponseCode());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean getGoogleService() {
|
||||
int code = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(mContext);
|
||||
return code == 0;
|
||||
|
@ -1,11 +1,8 @@
|
||||
package com.yunbao.main.activity;
|
||||
|
||||
|
||||
import static com.yunbao.main.activity.MyWalletActivity.dis;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -16,29 +13,31 @@ import android.webkit.WebView;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.facebook.appevents.AppEventsConstants;
|
||||
import com.android.billingclient.api.Purchase;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.pay.google.GooglePlay;
|
||||
import com.yunbao.common.utils.StringUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
import com.yunbao.main.views.TestWebViewClient;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@SuppressLint("ValidFragment")
|
||||
public class GoogleFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
private String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
String adid = null;
|
||||
|
||||
GoogleUtils googleUtils;
|
||||
private GooglePlay googlePlay;
|
||||
|
||||
boolean isGoogleService = true;
|
||||
|
||||
@ -62,17 +61,16 @@ public class GoogleFragment extends Fragment {
|
||||
Log.e("ttt", url);
|
||||
rlWebview.loadUrl(url);
|
||||
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
googlePlay = GooglePlay.getInstance();
|
||||
|
||||
// 验证是否已在此设备上安装并启用Google Play服务,以及此设备上安装的旧版本是否为此客户端所需的版本
|
||||
if (googleUtils.getGoogleService()) {
|
||||
if (googlePlay.getGoogleService()) {
|
||||
isGoogleService = true;
|
||||
// 支持Google服务
|
||||
initGooglePay();
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
adid = googleUtils.getAdid();
|
||||
adid = googlePlay.getAdId();
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
@ -100,13 +98,6 @@ public class GoogleFragment extends Fragment {
|
||||
|
||||
String TAG = "GooglePay";
|
||||
|
||||
private void initGooglePay() {
|
||||
googleUtils = new GoogleUtils(getActivity());
|
||||
googleUtils.initGooglePay();
|
||||
}
|
||||
|
||||
private Handler payHandler = new Handler();
|
||||
|
||||
//js调用原生
|
||||
public class JsInteration {
|
||||
|
||||
@ -117,54 +108,32 @@ public class GoogleFragment extends Fragment {
|
||||
mProductId = ProductId;
|
||||
mOrderid = OrderNumber;
|
||||
MoneyUsds = MoneyUsd;
|
||||
|
||||
googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() {
|
||||
googlePlay.setBillingListener(new GooglePlay.GoogleBillingListener() {
|
||||
@Override
|
||||
public void onPaySuccess(String token, String orderId) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() {
|
||||
public void onPaySuccess(List<Purchase> purchases) {
|
||||
CommonHttpUtil.notifyGoogle(purchases.get(0).getPurchaseToken(),
|
||||
purchases.get(0).getProducts().get(0), new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (code == 0) {
|
||||
Bundle params = new Bundle();
|
||||
params.putString("currency", "HKD");
|
||||
params.putString("money", MoneyUsds);
|
||||
Bundle fb_params = new Bundle();
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CURRENCY, "HKD");
|
||||
fb_params.putString(AppEventsConstants.EVENT_PARAM_CONTENT_ID, mProductId);
|
||||
//Google官方充值通知
|
||||
Bundle google_params = new Bundle();
|
||||
google_params.putString("currency", "HKD");
|
||||
google_params.putString("product_id", mProductId);
|
||||
google_params.putString("transaction_id", mOrderid);
|
||||
google_params.putString("value", MoneyUsds);
|
||||
google_params.putString("price", MoneyUsds);
|
||||
google_params.putString("quantity", "1");
|
||||
dis();
|
||||
googlePlay.consume(purchases);
|
||||
getActivity().finish();
|
||||
ToastUtil.show(getString(R.string.pay_suc));
|
||||
}else {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPayFailed(String msg) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
googleUtils.purchase(mProductId);
|
||||
}
|
||||
googlePlay.purchase(getActivity(),mOrderid, mProductId);
|
||||
lastClickTime = currentTime;
|
||||
|
||||
}
|
||||
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
|
||||
}
|
||||
|
||||
@ -180,9 +149,5 @@ public class GoogleFragment extends Fragment {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void release() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,9 @@ import com.yunbao.main.views.TestWebViewClient;
|
||||
@SuppressLint("ValidFragment")
|
||||
public class HuaWeiFragment extends Fragment {
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private final long INTERVAL_TIME = 1500;
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
public String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
|
@ -11,24 +11,22 @@ import android.view.animation.AccelerateInterpolator;
|
||||
import android.view.animation.DecelerateInterpolator;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.activity.AbsActivity;
|
||||
import com.yunbao.common.fragment.LoadingDialog;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.http.HttpCallback;
|
||||
import com.yunbao.common.manager.IMLoginManager;
|
||||
import com.yunbao.common.pay.google.GooglePlay;
|
||||
import com.yunbao.common.pay.hw.HwBuilder;
|
||||
import com.yunbao.common.pay.samsung.SamsungUtil;
|
||||
import com.yunbao.common.utils.GoogleUtils;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MobclickAgent;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.main.R;
|
||||
@ -45,24 +43,20 @@ import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTit
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorTransitionPagerTitleView;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Route(path = RouteUtil.PATH_COIN)
|
||||
public class MyWalletActivity extends AbsActivity {
|
||||
ViewPager vp_content;
|
||||
static MyWalletActivity mw;
|
||||
Fragment[] fragments = null;
|
||||
private Handler payHandler = new Handler();
|
||||
public static String orderId;
|
||||
|
||||
HwBuilder hwBuilder;
|
||||
GoogleUtils googleUtils;
|
||||
GooglePlay googlePlay;
|
||||
|
||||
LoadingDialog loadingDialog;
|
||||
SamsungUtil samsungUtil;
|
||||
@ -72,26 +66,53 @@ public class MyWalletActivity extends AbsActivity {
|
||||
return R.layout.activity_my_wallet;
|
||||
}
|
||||
|
||||
protected void main() {
|
||||
private WalletFragment getWalletFragment(String url) {
|
||||
WalletFragment walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
walletFragment.setArguments(bundle);
|
||||
return walletFragment;
|
||||
}
|
||||
|
||||
private GoogleFragment getGoogleFragment(String url) {
|
||||
GoogleFragment fragment = new GoogleFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private HuaWeiFragment getHuaWeiFragment(String url) {
|
||||
HuaWeiFragment fragment = new HuaWeiFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
private SamsungFragment getSamsungFragment(String url) {
|
||||
SamsungFragment fragment = new SamsungFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", url);
|
||||
fragment.setArguments(bundle);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
protected void main() {
|
||||
super.main();
|
||||
mw = MyWalletActivity.this;
|
||||
setTitle(mContext.getString(R.string.wallet));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
googleUtils = new GoogleUtils(mContext);
|
||||
googleUtils.initGooglePay();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder = new HwBuilder(MyWalletActivity.this);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
samsungUtil = SamsungUtil.newInstance(mContext);
|
||||
samsungUtil.init();
|
||||
}else{
|
||||
googleUtils = new GoogleUtils(mContext);
|
||||
googleUtils.initGooglePay();
|
||||
} else {
|
||||
googlePlay = GooglePlay.getInstance();
|
||||
//消耗所有商品
|
||||
googlePlay.consumeAll();
|
||||
}
|
||||
|
||||
|
||||
vp_content = (ViewPager) findViewById(R.id.vp_content);
|
||||
TextView rView = (TextView) findViewById(R.id.rView);
|
||||
findViewById(R.id.redPacketMain).setVisibility(View.VISIBLE);
|
||||
@ -102,52 +123,9 @@ public class MyWalletActivity extends AbsActivity {
|
||||
loadingDialog = new LoadingDialog();
|
||||
loadingDialog.show(getSupportFragmentManager(), "LoadingDialog");
|
||||
loadingDialog.setShowText(getString(R.string.order_query));
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
googleUtils.setQueryPurchaseListener(mContext, new GoogleUtils.QueryPurchasesListener() {
|
||||
@Override
|
||||
public void onResult(JSONObject obj) {
|
||||
try {
|
||||
int code = obj.getInt("querySize");
|
||||
if (code == 0) {
|
||||
payHandler.post(runnable1);
|
||||
payHandler.postDelayed(runnable2, 1000);
|
||||
} else {
|
||||
JSONArray tokenList = obj.getJSONArray("tokenList");
|
||||
JSONArray orderList = obj.getJSONArray("orderList");
|
||||
String tradeNo = obj.getString("tradeNo");
|
||||
|
||||
for (int i = 0; i < tokenList.length(); i++) {
|
||||
int finalI = i;
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
//谷歌掉单处理
|
||||
try {
|
||||
CommonHttpUtil.Google_sec_pay(tokenList.getString(finalI), orderList.getString(finalI), tradeNo, new HttpCallback() {
|
||||
@Override
|
||||
public void onSuccess(int code, String msg, String[] info) {
|
||||
if (finalI == tokenList.length() - 1) {
|
||||
loadingDialog.setShowText(getString(R.string.order_query_success));
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
ToastUtil.show("充值已到账");
|
||||
finish();
|
||||
}
|
||||
});
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (JSONException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
googleUtils.queryPurchasesAsync();
|
||||
//消耗所有商品
|
||||
googlePlay.consumeAll();
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
hwBuilder.consume();
|
||||
payHandler.post(runnable1);
|
||||
@ -162,168 +140,36 @@ public class MyWalletActivity extends AbsActivity {
|
||||
}
|
||||
});
|
||||
|
||||
WalletFragment walletFragment = null;
|
||||
|
||||
GoogleFragment googleFragment1 = null;
|
||||
GoogleFragment googleFragment2 = null;
|
||||
|
||||
HuaWeiFragment huaWeiFragment1 = null;
|
||||
HuaWeiFragment huaWeiFragment2 = null;
|
||||
|
||||
SamsungFragment samsungFragment1 = null;
|
||||
SamsungFragment samsungFragment2 = null;
|
||||
|
||||
WalletFragment walletFragment;
|
||||
Fragment fragment1;
|
||||
Fragment fragment2;
|
||||
final String[] titles = {mContext.getString(R.string.diamond), mContext.getString(R.string.coins), mContext.getString(R.string.golden_beans)};
|
||||
walletFragment = getWalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragment1 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragment1 = getHuaWeiFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
fragment2 = getHuaWeiFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
fragment1 = getSamsungFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getSamsungFragment(CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
} else {
|
||||
if (getIntent().getStringExtra("tag") != null) {
|
||||
Log.i("tss", "首充");
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
//google
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
//华为
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
huaWeiFragment1 = new HuaWeiFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment1.setArguments(bundle1);
|
||||
|
||||
huaWeiFragment2 = new HuaWeiFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
samsungFragment1 = new SamsungFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment1.setArguments(bundle1);
|
||||
|
||||
samsungFragment2 = new SamsungFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment2.setArguments(bundle2);
|
||||
} else {
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
}
|
||||
} else {
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaygole&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
huaWeiFragment1 = new HuaWeiFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment1.setArguments(bundle1);
|
||||
|
||||
huaWeiFragment2 = new HuaWeiFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/huaweipaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd");
|
||||
huaWeiFragment2.setArguments(bundle2);
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
rView.setVisibility(View.VISIBLE);
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
samsungFragment1 = new SamsungFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaycoin.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment1.setArguments(bundle1);
|
||||
|
||||
samsungFragment2 = new SamsungFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/themes/simplebootx/appapi/mall/samsungpaygole.html?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
samsungFragment2.setArguments(bundle2);
|
||||
fragment1 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
} else {
|
||||
Log.i("tss", "不是首充");
|
||||
//链接版本
|
||||
|
||||
walletFragment = new WalletFragment();
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
walletFragment.setArguments(bundle);
|
||||
|
||||
googleFragment1 = new GoogleFragment();
|
||||
Bundle bundle1 = new Bundle();
|
||||
bundle1.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment1.setArguments(bundle1);
|
||||
|
||||
googleFragment2 = new GoogleFragment();
|
||||
Bundle bundle2 = new Bundle();
|
||||
bundle2.putString("url", CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
googleFragment2.setArguments(bundle2);
|
||||
fragment1 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
fragment2 = getGoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken() + "&package_name=pd" + "&isZh=" + ((IMLoginManager.get(mContext).getLocaleLanguage() == Locale.SIMPLIFIED_CHINESE) ? "1" : "0"));
|
||||
}
|
||||
}
|
||||
fragments = new Fragment[]{fragment1, fragment2, walletFragment};
|
||||
|
||||
if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
|
||||
fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
|
||||
fragments = new Fragment[]{huaWeiFragment1, huaWeiFragment2, walletFragment};
|
||||
} else if (CommonAppConfig.IS_GOOGLE_PLAY == 3) {
|
||||
fragments = new Fragment[]{samsungFragment1, samsungFragment2, walletFragment};
|
||||
} else {
|
||||
fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
|
||||
}
|
||||
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
|
||||
CommonNavigator commonNavigator = new CommonNavigator(this);
|
||||
commonNavigator.setAdjustMode(true);
|
||||
@ -422,16 +268,6 @@ public class MyWalletActivity extends AbsActivity {
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
CommonHttpUtil.cancel("Charge.Google_sec_pay");
|
||||
if (payHandler != null) {
|
||||
payHandler.removeCallbacks(runnable1);
|
||||
payHandler.removeCallbacks(runnable2);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
@ -496,8 +332,4 @@ public class MyWalletActivity extends AbsActivity {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public static void dis() {
|
||||
mw.finish();
|
||||
}
|
||||
}
|
||||
|
@ -24,10 +24,10 @@ import com.yunbao.main.views.TestWebViewClient;
|
||||
public class SamsungFragment extends Fragment {
|
||||
|
||||
private long lastClickTime = 0;
|
||||
private static final long INTERVAL_TIME = 1500;
|
||||
private final long INTERVAL_TIME = 1500;
|
||||
|
||||
private View view;
|
||||
public static String mOrderid, mProductId, MoneyUsds;
|
||||
public String mOrderid, mProductId, MoneyUsds;
|
||||
|
||||
private WebView rlWebview;
|
||||
private String url;
|
||||
@ -99,9 +99,7 @@ public class SamsungFragment extends Fragment {
|
||||
@Override
|
||||
public void onPaymentSuccess(String purchaseVo) {
|
||||
SamsungUtil.newInstance(getActivity()).consume(purchaseVo);
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
payHandler.post(() -> {
|
||||
// CommonHttpUtil.notifySamsung(_purchaseVO.getPurchaseId(), mOrderid, new HttpCallback() {
|
||||
// @Override
|
||||
// public void onSuccess(int code, String msg, String[] info) {
|
||||
@ -111,18 +109,12 @@ public class SamsungFragment extends Fragment {
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPaymentFailed(String errorVo) {
|
||||
payHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ToastUtil.show(errorVo);
|
||||
}
|
||||
});
|
||||
payHandler.post(() -> ToastUtil.show(errorVo));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user