From 2490c6bdd1e9b7e4ed5dafc0c8b6747080b520f3 Mon Sep 17 00:00:00 2001 From: 18142669586 <1669783059@qq.com> Date: Tue, 27 Sep 2022 14:53:01 +0800 Subject: [PATCH] 1 --- common/src/main/res/layout/view_title.xml | 12 +++ .../yunbao/main/activity/GoogleFragment.java | 1 + .../main/activity/MyWalletActivity.java | 93 ++++++++++++++++++- 3 files changed, 102 insertions(+), 4 deletions(-) diff --git a/common/src/main/res/layout/view_title.xml b/common/src/main/res/layout/view_title.xml index 620bb7cfc..ae73a9d7b 100644 --- a/common/src/main/res/layout/view_title.xml +++ b/common/src/main/res/layout/view_title.xml @@ -40,5 +40,17 @@ android:tint="@color/textColor" android:visibility="gone" /> + diff --git a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java index 268a25f29..6838196d4 100644 --- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java +++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java @@ -15,6 +15,7 @@ import android.view.animation.DecelerateInterpolator; import android.webkit.JavascriptInterface; import android.webkit.WebSettings; import android.webkit.WebView; +import android.widget.TextView; import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; diff --git a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java index 5db7ad9ac..ff2c94dba 100644 --- a/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java +++ b/main/src/main/java/com/yunbao/main/activity/MyWalletActivity.java @@ -3,23 +3,34 @@ package com.yunbao.main.activity; import android.content.Context; import android.graphics.Color; +import androidx.annotation.NonNull; import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentPagerAdapter; import androidx.viewpager.widget.ViewPager; import androidx.appcompat.app.AppCompatActivity; +import android.os.Bundle; import android.util.Log; import android.view.View; import android.view.animation.AccelerateInterpolator; import android.view.animation.DecelerateInterpolator; +import android.widget.TextView; import com.adjust.sdk.Adjust; import com.adjust.sdk.AdjustEvent; import com.alibaba.android.arouter.facade.annotation.Route; +import com.android.billingclient.api.Purchase; +import com.android.billingclient.api.SkuDetails; +import com.facebook.appevents.AppEventsConstants; import com.yunbao.common.CommonAppConfig; import com.yunbao.common.activity.AbsActivity; +import com.yunbao.common.http.CommonHttpUtil; +import com.yunbao.common.http.HttpCallback; +import com.yunbao.common.utils.GoogleBillingUtil; +import com.yunbao.common.utils.OnGoogleBillingListener; import com.yunbao.common.utils.RouteUtil; +import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.WordUtil; import com.yunbao.main.R; import com.yunbao.main.utils.HXLinePagerIndicator; @@ -37,16 +48,80 @@ import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.ColorT import static com.yunbao.common.CommonAppContext.logger; import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics; +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; + String TAG = "GooglePay"; @Override protected int getLayoutId() { return R.layout.activity_my_wallet; } + private GoogleBillingUtil googleBillingUtil; + + private OnGoogleBillingListener mOnMyGoogleBillingListener=new OnGoogleBillingListener(){ + @Override + public void onSetupSuccess(boolean isSelf) { + super.onSetupSuccess(isSelf); + Log.d(TAG,"内购服务初始化完成"); + } + + @Override + public void onQuerySuccess(@NonNull String skuType, @NonNull List list, boolean isSelf) { + + + + } + + @Override + public boolean onPurchaseSuccess(@NonNull Purchase purchase, boolean isSelf) { + StringBuffer tempBuffer =new StringBuffer(); + + return true ;//自动消耗(只有当isSelf为true,并且支付状态为PURCHASED时,该值才会生效) + } + + @Override + public boolean onRecheck(@NonNull String skuType, @NonNull Purchase purchase, boolean isSelf) { + StringBuffer tempBuffer =new StringBuffer(); + tempBuffer.append("检测到未处理的订单($skuType):${purchase.sku}()"); + Log.d(TAG,tempBuffer.toString()); + return true; + } + + @Override + public void onBillingServiceDisconnected() { + super.onBillingServiceDisconnected(); + } + + @Override + public void onConsumeSuccess(@NonNull String purchaseToken, boolean isSelf) { + Log.d(TAG,"消耗商品成功:$purchaseToken"); + + } + + @Override + public void onAcknowledgePurchaseSuccess(boolean isSelf) { + Log.d(TAG,"确认购买商品成功"); + + } + + @Override + public void onFail(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, int responseCode, boolean isSelf) { + Log.d(TAG,"操作失败:tag=${" + tag.name() + "responseCode=" + responseCode); + } + + @Override + public void onError(@NonNull GoogleBillingUtil.GoogleBillingListenerTag tag, boolean isSelf) { + Log.d(TAG,"发生错误:tag="+tag.name()); + } + + }; + @Override protected void main() { @@ -59,6 +134,14 @@ public class MyWalletActivity extends AbsActivity { logger.logEvent("FB_initiated_checkout"); vp_content = (ViewPager)findViewById(R.id.vp_content); + TextView rView = (TextView) findViewById(R.id.rView); + rView.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); + final String[] titles = {WordUtil.getString(R.string.diamond), WordUtil.getString(R.string.coins),WordUtil.getString(R.string.golden_beans)}; if(getIntent().getStringExtra("tag")!=null) { Log.i("tss","首充"); @@ -67,8 +150,9 @@ public class MyWalletActivity extends AbsActivity { fragments = new Fragment[]{new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; // fragments = new Fragment[]{new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&first_page=1&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new GoogleFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; }else{ - fragments = new Fragment[]{new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), - new GoogleFragment(CommonAppConfig.HOST +"/index.php?g=Appapi&m=Mall&a=googlepaygole&uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken()), + rView.setVisibility(View.VISIBLE); + fragments = new Fragment[]{new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&package_name=pd"), + new GoogleFragment(CommonAppConfig.HOST +"/index.php?g=Appapi&m=Mall&a=googlepaygole&uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken()+"&package_name=pd"), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; } }else{ @@ -77,8 +161,9 @@ public class MyWalletActivity extends AbsActivity { //链接版本 fragments = new Fragment[]{new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletcoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletgold&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; }else{ - fragments = new Fragment[]{new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()), - new GoogleFragment(CommonAppConfig.HOST +"/index.php?g=Appapi&m=Mall&a=googlepaygole&uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken()), + rView.setVisibility(View.VISIBLE); + fragments = new Fragment[]{new GoogleFragment( CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&a=googlepaycoin&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken()+"&package_name=pd"), + new GoogleFragment(CommonAppConfig.HOST +"/index.php?g=Appapi&m=Mall&a=googlepaygole&uid="+CommonAppConfig.getInstance().getUid()+"&token="+CommonAppConfig.getInstance().getToken()+"&package_name=pd"), new WalletFragment(CommonAppConfig.HOST + "/index.php?g=Appapi&m=Mall&first_page=1&a=walletbean&uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken())}; } }