diff --git a/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java b/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java
index 2eceb9b43..a8cdcf558 100644
--- a/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java
+++ b/Share/src/main/java/com/yunbao/share/bean/ShareBuilder.java
@@ -34,14 +34,14 @@ public class ShareBuilder {
"/index.php?g=Appapi&m=home&a=share&uid=%s&user_id=%s&isGoogle=%s",
anchorId,
shareUid,
- CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"
- ) ;
+ CommonAppConfig.IS_GOOGLE_PLAY
+ );
}
public static String createInviteLink(String shareUid) {
return String.format("https://www.pdlive.com/public/app/download/index.html?user_id=%s&isGoogle=%s",
shareUid,
- CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0"
+ CommonAppConfig.IS_GOOGLE_PLAY
);
}
diff --git a/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java b/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java
index 32fad6d4a..fbfeeb53e 100644
--- a/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java
+++ b/Share/src/main/java/com/yunbao/share/ui/InvitePopDialog.java
@@ -152,7 +152,7 @@ public class InvitePopDialog extends AbsDialogPopupWindow {
}
public InvitePopDialog setUrl(String data) {
- this.url = data + "&isGoogle=" + (CommonAppConfig.IS_GOOGLE_PLAY ? "1" : "0");
+ this.url = data + "&isGoogle=" + CommonAppConfig.IS_GOOGLE_PLAY;
return this;
}
}
diff --git a/app/agconnect-services.json b/app/agconnect-services.json
index 34dcec94e..8b1cd7054 100644
--- a/app/agconnect-services.json
+++ b/app/agconnect-services.json
@@ -26,21 +26,21 @@
"SG_back":"connect-ws-dra.hispace.dbankcloud.com"
},
"client":{
- "cp_id":"30086000612391734",
- "product_id":"99536292102564216",
- "client_id":"964994320723627840",
- "client_secret":"6D5FE29D85B967D3A66BDCD473641E4C7B5524F7F4935CA0EF4A842730C3402D",
- "project_id":"99536292102564216",
- "app_id":"106936673",
- "api_key":"DAEDADYGta/0O4ZSdrnug52NgC67/w/RIyTq9A8LyAY0+mp6g6XeJDbxugpluFPLAhaqjaMs5c0PLnRx14UzWbPPADgi1EqihbWLoA==",
+ "cp_id":"30852000032486141",
+ "product_id":"388421841221767494",
+ "client_id":"1283893262452580800",
+ "client_secret":"17BC070420691D35650C694230D6348075CB549F7BBA94EDD49FA9E61A9E5434",
+ "project_id":"388421841221767494",
+ "app_id":"109612651",
+ "api_key":"DAEDAAlBbTFuTuyQWQsyYBZLuyjALH9Y9BNFkVZl1GhI0tRaa6HF1LgzXWy2MZiSFrmpbn1aAvcvzP6aKZtR6MVikS8V4SbBlYUPfQ==",
"package_name":"com.pdlive.shayu"
},
"oauth_client":{
- "client_id":"106936673",
+ "client_id":"109612651",
"client_type":1
},
"app_info":{
- "app_id":"106936673",
+ "app_id":"109612651",
"package_name":"com.pdlive.shayu"
},
"service":{
@@ -53,6 +53,10 @@
"resource_id":"p1",
"channel_id":""
},
+ "edukit":{
+ "edu_url":"edukit.cloud.huawei.com.cn",
+ "dh_url":"edukit.cloud.huawei.com.cn"
+ },
"search":{
"url":"https://search-drcn.cloud.huawei.com"
},
@@ -77,15 +81,15 @@
{
"package_name":"com.pdlive.shayu",
"client":{
- "app_id":"106936673"
+ "app_id":"109612651"
},
"app_info":{
"package_name":"com.pdlive.shayu",
- "app_id":"106936673"
+ "app_id":"109612651"
},
"oauth_client":{
"client_type":1,
- "client_id":"106936673"
+ "client_id":"109612651"
}
}
]
diff --git a/app/build.gradle b/app/build.gradle
index 22fa13570..637a4f0d6 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -170,8 +170,10 @@ android {
}
variant.outputs.all {
def isGoogle = "link"
- if (rootProject.ext.manifestPlaceholders.isGooglePlay) {
+ if (rootProject.ext.manifestPlaceholders.isGooglePlay == 1) {
isGoogle = "Google"
+ } else if(rootProject.ext.manifestPlaceholders.isGooglePlay == 2){
+ isGoogle = "Huawei"
}
def isPlugin = "all"
if (rootProject.ext.manifestPlaceholders.isPluginModel) {
@@ -266,8 +268,8 @@ dependencies {
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
- implementation platform('com.google.firebase:firebase-bom:30.5.0')
- implementation 'com.google.firebase:firebase-crashlytics'
+ //implementation platform('com.google.firebase:firebase-bom:30.5.0')
+ //implementation 'com.google.firebase:firebase-crashlytics'
//直播
api project(':main')
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 34148d476..6fde1835f 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -194,12 +194,13 @@
-
-
-
-
-
-
+
+
+
\ No newline at end of file
diff --git a/app/src/main/java/com/shayu/phonelive/AppContext.java b/app/src/main/java/com/shayu/phonelive/AppContext.java
index d26bdc5a8..b9ccbf533 100644
--- a/app/src/main/java/com/shayu/phonelive/AppContext.java
+++ b/app/src/main/java/com/shayu/phonelive/AppContext.java
@@ -24,9 +24,6 @@ import com.alibaba.fastjson.JSONObject;
import com.blankj.utilcode.util.Utils;
import com.facebook.appevents.AppEventsLogger;
import com.fm.openinstall.OpenInstall;
-import com.google.firebase.FirebaseApp;
-import com.google.firebase.analytics.FirebaseAnalytics;
-import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.shayu.phonelive.utils.LogUtils;
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
import com.tencent.imsdk.v2.V2TIMManager;
@@ -46,9 +43,9 @@ import com.yunbao.common.manager.imrongcloud.MessageIMManager;
import com.yunbao.common.manager.imrongcloud.RecommendLiveRoom;
import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.AppManager;
+import com.yunbao.common.utils.GoogleUtils;
import com.yunbao.common.utils.L;
import com.yunbao.common.utils.SpUtil;
-import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.socket.SocketReceiveBean;
import com.yunbao.live.socket.SocketRyClient;
import com.yunbao.live.utils.LiveImDeletUtil;
@@ -145,7 +142,6 @@ public class AppContext extends CommonAppContext {
sInstance = this;
L.setDeBug(BuildConfig.DEBUG);
AppEventsLogger.activateApp(this);
- FirebaseAnalytics.getInstance(this);
File httpCacheDir = new File(getCacheDir(), "https");
try {
@@ -170,8 +166,7 @@ public class AppContext extends CommonAppContext {
//友盟正式初始化
- UMConfigure.init(getApplicationContext(), "64e40ee55488fe7b3afa2c96", "PDLive", UMConfigure.DEVICE_TYPE_PHONE,
- "64e40ee55488fe7b3afa2c96");
+ UMConfigure.init(getApplicationContext(), "64e40ee55488fe7b3afa2c96", "PDLive", UMConfigure.DEVICE_TYPE_PHONE, "64e40ee55488fe7b3afa2c96");
//集成umeng-crash-vx.x.x.aar,则需要关闭原有统计SDK异常捕获功能
MobclickAgent.setCatchUncaughtExceptions(false);
@@ -212,9 +207,7 @@ public class AppContext extends CommonAppContext {
if (content.getContent().contains("_method_")) {
msg.obj = content.getContent();
//观众页面
- if (SocketRyClient.mSocketHandler != null
- && (TextUtils.equals("__system__", message.getTargetId())
- || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
+ if (SocketRyClient.mSocketHandler != null && (TextUtils.equals("__system__", message.getTargetId()) || ("g" + PortraitLiveManager.liveID).contains(message.getTargetId()))) {
SocketRyClient.mSocketHandler.sendMessage(msg);
} else if (content.getContent().contains("LivePK_anchorStartLiveNotify")) {//开播通知
SocketReceiveBean received = JSON.parseObject(content.getContent(), SocketReceiveBean.class);
@@ -313,40 +306,37 @@ public class AppContext extends CommonAppContext {
* 注册全局异常捕获,有需要时可以在onCreate调用
*/
private void registerError() {
- NeverCrashUtils.getInstance()
- .setDebugMode(BuildConfig.DEBUG)
- .setMainCrashHandler((t, e) -> {
- Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
- e.printStackTrace();
- AppManager.runDebugCode(() -> {
- //闪退后finish所有Activity并且杀死进程
- for (WeakReference activity : activities) {
- if (activity != null && activity.get() != null) {
- activity.get().finish();
- }
- }
- Process.killProcess(Process.myPid());
- System.exit(0);
- setFirebaseCrashData();
- new Handler(Looper.getMainLooper()).postDelayed(() -> {
- throw new RuntimeException(e);
- }, 100);
- });
+ NeverCrashUtils.getInstance().setDebugMode(BuildConfig.DEBUG).setMainCrashHandler((t, e) -> {
+ Log.e("ApplicationError", "主线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
+ e.printStackTrace();
+ AppManager.runDebugCode(() -> {
+ //闪退后finish所有Activity并且杀死进程
+ for (WeakReference activity : activities) {
+ if (activity != null && activity.get() != null) {
+ activity.get().finish();
+ }
+ }
+ Process.killProcess(Process.myPid());
+ System.exit(0);
+ setFirebaseCrashData();
+ new Handler(Looper.getMainLooper()).postDelayed(() -> {
+ throw new RuntimeException(e);
+ }, 100);
+ });
- })
- .setUncaughtCrashHandler((t, e) -> {
- Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
- e.printStackTrace();
- })
- .register(this);
+ }).setUncaughtCrashHandler((t, e) -> {
+ Log.e("ApplicationError", "子线程异常");//此处log只是展示,当debug为true时,主类内部log会打印异常信息
+ e.printStackTrace();
+ }).register(this);
}
public void registerFirebaseCrash() {
if (!CommonAppConfig.IS_UPLOAD_ERROR_LOG) {
return;
}
- FirebaseAnalytics.getInstance(this);
- FirebaseApp.initializeApp(this);
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ GoogleUtils.newInstance(this).initializeApp(this);
+ }
}
@@ -355,21 +345,5 @@ public class AppContext extends CommonAppContext {
return;
}
String uid = CommonAppConfig.getInstance().getUid();
- FirebaseCrashlytics.getInstance().setUserId(CommonAppConfig.getInstance().getUid());
- if (uid != null && !uid.isEmpty()) {
- FirebaseCrashlytics.getInstance().setCustomKey("uid", uid);
- } else {
- FirebaseCrashlytics.getInstance().setCustomKey("uid", "uid is null");
- }
- FirebaseCrashlytics.getInstance().setCustomKey("userData", SpUtil.getInstance().getStringValue(SpUtil.USER_INFO));
- FirebaseCrashlytics.getInstance().setCustomKey("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY);
- FirebaseCrashlytics.getInstance().setCustomKey("PhoneName", Build.BRAND);
- FirebaseCrashlytics.getInstance().setCustomKey("Phone", Build.MODEL);
- FirebaseCrashlytics.getInstance().setCustomKey("CPU", Arrays.toString(Build.SUPPORTED_ABIS));
- FirebaseCrashlytics.getInstance().setCustomKey("RunTime", (System.currentTimeMillis() - CrashSaveBean.getInstance().getStartTime()));
- FirebaseCrashlytics.getInstance().setCustomKey("enterRoom", CrashSaveBean.getInstance().getEnterRoom());
- FirebaseCrashlytics.getInstance().setCustomKey("slidingRoom", CrashSaveBean.getInstance().getSlidingRoom());
- FirebaseCrashlytics.getInstance().setCustomKey("playSvga", CrashSaveBean.getInstance().getPlaySvga());
- FirebaseCrashlytics.getInstance().setCustomKey("ActivitySize", CrashSaveBean.getInstance().getActivitySize());
}
}
diff --git a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java
index 350f23aab..a793f9b98 100644
--- a/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java
+++ b/app/src/main/java/com/shayu/phonelive/NeverCrashUtils.java
@@ -8,7 +8,6 @@ import android.os.Looper;
import android.util.Log;
import android.widget.Toast;
-import com.google.firebase.crashlytics.FirebaseCrashlytics;
import com.yunbao.common.BuildConfig;
import com.yunbao.common.bean.CrashSaveBean;
import com.yunbao.common.utils.AppManager;
@@ -108,7 +107,6 @@ public class NeverCrashUtils {
}
e.printStackTrace();
AppContext.setFirebaseCrashData();
- FirebaseCrashlytics.getInstance().recordException(e);
AppManager.runDebugCode(() -> Toast.makeText(application, "发生闪退:" + e.getMessage(), Toast.LENGTH_SHORT).show());
FileUtil.saveStringToFile(new File(application.getDir("files", Context.MODE_PRIVATE).getAbsolutePath()), throwableToString(e), "error.log");
getMainCrashHandler().mainException(Looper.getMainLooper().getThread(), e);
diff --git a/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java b/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java
index 7f01161ff..884c4c811 100644
--- a/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java
+++ b/app/src/main/java/com/shayu/phonelive/utils/MyNotificationService.java
@@ -1,3 +1,4 @@
+/*
package com.shayu.phonelive.utils;
import android.app.Notification;
@@ -108,3 +109,4 @@ public class MyNotificationService extends FirebaseMessagingService {
// }
}
+*/
diff --git a/build.gradle b/build.gradle
index 412a03df4..7212cbfef 100644
--- a/build.gradle
+++ b/build.gradle
@@ -12,6 +12,7 @@ buildscript {
maven { url 'https://maven.fabric.io/public' }
maven { url 'http://maven.faceunity.com/repository/maven-public/' }//美颜库
maven { url 'https://repo1.maven.org/maven2/' }//埋点
+ maven {url 'https://developer.huawei.com/repo/'}
google()
mavenCentral()
}
@@ -24,6 +25,7 @@ buildscript {
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
classpath "com.alibaba:arouter-register:1.0.2"
+ classpath 'com.huawei.agconnect:agcp:1.5.2.300'
}
diff --git a/common/build.gradle b/common/build.gradle
index 56dbc58bf..971eda0e7 100644
--- a/common/build.gradle
+++ b/common/build.gradle
@@ -146,7 +146,11 @@ dependencies {
//谷歌支付
//谷歌内购
- api 'com.android.billingclient:billing:5.0.0'
+ //api 'com.android.billingclient:billing:5.0.0'
+
+ //api 'com.google.firebase:firebase-messaging:23.0.6'
+ //api 'com.google.firebase:firebase-analytics:21.1.0'
+
api 'com.squareup.picasso:picasso:2.5.2'
api "com.immomo.cosmos.mediax:beautyutils:2.2.1_01071700"
api files('libs/liteavsdk.jar')
@@ -180,8 +184,7 @@ dependencies {
api 'com.jakewharton.rxbinding3:rxbinding:3.1.0'
//loading样式库
api 'com.wang.avi:library:2.1.3'
- api 'com.google.firebase:firebase-messaging:23.0.6'
- api 'com.google.firebase:firebase-analytics:21.1.0'
+
// api 'com.huawei.hms:push:4.0.2.300'
implementation 'com.github.tajchert:WaitingDots:0.6.1'
//悬浮窗
@@ -206,4 +209,11 @@ dependencies {
// 多语言语音识别扩展库(可选)
api 'tech.sud.mgp:SudASR:1.3.3.1158'
+
+ //华为支付插件包
+ api project(':lib_huawei')
+
+ //google插件包
+ api project(':lib_google')
+
}
diff --git a/common/src/main/java/com/yunbao/common/CommonAppConfig.java b/common/src/main/java/com/yunbao/common/CommonAppConfig.java
index 465b8606d..08715be7d 100644
--- a/common/src/main/java/com/yunbao/common/CommonAppConfig.java
+++ b/common/src/main/java/com/yunbao/common/CommonAppConfig.java
@@ -34,7 +34,7 @@ public class CommonAppConfig {
//域名
public static final String HOST = getMetaDataString("SERVER_HOST");
//是否使用谷歌支付
- public static final boolean IS_GOOGLE_PLAY = getMetaDataBoolean("IS_GOOGLE_PLAY");
+ public static final int IS_GOOGLE_PLAY = getMetaDataInt("IS_GOOGLE_PLAY");
//是否开启上报错误日志功能
public static final boolean IS_UPLOAD_ERROR_LOG = getMetaDataBoolean("IS_UPLOAD_ERROR_LOG");
//是否为插件包模式
@@ -470,6 +470,18 @@ public class CommonAppConfig {
}
+ private static int getMetaDataInt(String key) {
+ int res = 0;
+ try {
+ ApplicationInfo appInfo = CommonAppContext.sInstance.getPackageManager().getApplicationInfo(CommonAppContext.sInstance.getPackageName(), PackageManager.GET_META_DATA);
+ res = appInfo.metaData.getInt(key);
+ } catch (PackageManager.NameNotFoundException e) {
+ e.printStackTrace();
+ }
+ return res;
+ }
+
+
/**
* 个人中心功能列表
*/
diff --git a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java
index c90987dff..88f65b4b3 100644
--- a/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java
+++ b/common/src/main/java/com/yunbao/common/http/CommonHttpUtil.java
@@ -173,106 +173,97 @@ public class CommonHttpUtil {
}
Log.i("来了", lang);
//或者仅仅使用 locale = Locale.getDefault(); 不需要考虑接口 deprecated(弃用)问题
- HttpClient.getInstance().get("Home.getConfig", CommonHttpConsts.GET_CONFIG)
- .params("langue", lang)
- .params("version", "" + VersionUtil.getVersion())
- .params("from", "android")
- .params("appType", "1")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0 && info.length > 0) {
- try {
- JSONObject obj = JSON.parseObject(info[0]);
- ConfigBean bean = JSON.toJavaObject(obj, ConfigBean.class);
- CommonAppConfig.getInstance().setConfig(bean);
- CommonAppConfig.getInstance().setLevel(obj.getString("level"));
- CommonAppConfig.getInstance().setAnchorLevel(obj.getString("levelanchor"));
- CommonAppConfig.getInstance().alert_time = obj.getInteger("alert_time");
- CommonAppConfig.getInstance().alert_end_time = obj.getInteger("alert_end_time");
- //解析粉丝徽章
- CommonAppConfig.getInstance().setAnchorFansMedal(obj.getString("levelfans"));
- SpUtil.getInstance().setStringValue(SpUtil.CONFIG, info[0]);
- if (commonCallback != null) {
- commonCallback.callback(bean);
- }
- if (obj.containsKey("is_chat")) {
- IMLoginManager.get(context).initChat(String.valueOf(obj.getInteger("is_chat")));
- }
- if (obj.containsKey("levelfans")) {
- JSONArray levelArray = obj.getJSONArray("levelfans");
- new NewLevelManager(context).upDataFansLevel(levelArray.toJSONString());
- }
- if (obj.containsKey("level_new")) {//缓存等级数据
- JSONArray levelArray = obj.getJSONArray("level_new");
- new NewLevelManager(context).UpDataLevel(levelArray.toJSONString());
- }
- if (obj.containsKey("levelanchor_new")) {//缓存等级数据
- JSONArray levelArray = obj.getJSONArray("levelanchor_new");
- new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
- }
- if (obj.containsKey("liveclass")) {//缓存直播间分类
- JSONArray levelArray = obj.getJSONArray("liveclass");
- new LiveClassManager(context).UpDataLiveClass(levelArray.toJSONString());
- }
- if (obj.containsKey("apk_ver")) {
- APKManager.get().setApkVer(obj.getString("apk_ver"));
- }
- if (obj.containsKey("apk_url")) {
- APKManager.get().setAPKUrl(obj.getString("apk_url"));
- }
- if (obj.containsKey("apk_des")) {
- APKManager.get().setAPKDes(obj.getString("apk_des"));
- }
- if (obj.containsKey("google_isup")) {
- APKManager.get().setAPKGoogleIsUp(obj.getInteger("google_isup"));
- }
- if (obj.containsKey("isup")) {
- APKManager.get().setAPKIsUp(obj.getInteger("isup"));
- }
- if (obj.containsKey("clarity")) {
- IMLoginManager.get(context).setClarity(obj.getString("clarity"));
- }
- if (obj.containsKey("defaultBubbleUrl")) {
- IMLoginManager.get(context).setDefaultBubbleUrl(obj.getString("defaultBubbleUrl"));
- }
- if (obj.containsKey("gift_quantity")) {
- JSONArray giftQuantity = obj.getJSONArray("gift_quantity");
- new GiftQuantityManager(context).UpGiftQuantity(giftQuantity.toJSONString());
- }
- } catch (Exception e) {
- e.printStackTrace();
- String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
- ErrorActivity.forward("GetConfig接口返回数据异常", error);
- }
- } else if (code == 1000) {
- new DialogUitl
- .Builder(context)
- .setContent(msg)
- .setCancelable(false)
- .setClickCallback3(new DialogUitl.SimpleCallback3() {
- @Override
- public void onConfirmClick(Dialog dialog) {
- AppManager.getInstance().AppExit();
- }
-
- @Override
- public void onCancel() {
- AppManager.getInstance().AppExit();
- }
- }).build().show();
- } else {
- ToastUtil.show(context.getString(R.string.net_error) + "code:" + code + " msg:" + msg);
- }
- }
-
- @Override
- public void onError() {
+ HttpClient.getInstance().get("Home.getConfig", CommonHttpConsts.GET_CONFIG).params("langue", lang).params("version", "" + VersionUtil.getVersion()).params("from", "android").params("appType", "1").execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0 && info.length > 0) {
+ try {
+ JSONObject obj = JSON.parseObject(info[0]);
+ ConfigBean bean = JSON.toJavaObject(obj, ConfigBean.class);
+ CommonAppConfig.getInstance().setConfig(bean);
+ CommonAppConfig.getInstance().setLevel(obj.getString("level"));
+ CommonAppConfig.getInstance().setAnchorLevel(obj.getString("levelanchor"));
+ CommonAppConfig.getInstance().alert_time = obj.getInteger("alert_time");
+ CommonAppConfig.getInstance().alert_end_time = obj.getInteger("alert_end_time");
+ //解析粉丝徽章
+ CommonAppConfig.getInstance().setAnchorFansMedal(obj.getString("levelfans"));
+ SpUtil.getInstance().setStringValue(SpUtil.CONFIG, info[0]);
if (commonCallback != null) {
- commonCallback.callback(null);
+ commonCallback.callback(bean);
}
+ if (obj.containsKey("is_chat")) {
+ IMLoginManager.get(context).initChat(String.valueOf(obj.getInteger("is_chat")));
+ }
+ if (obj.containsKey("levelfans")) {
+ JSONArray levelArray = obj.getJSONArray("levelfans");
+ new NewLevelManager(context).upDataFansLevel(levelArray.toJSONString());
+ }
+ if (obj.containsKey("level_new")) {//缓存等级数据
+ JSONArray levelArray = obj.getJSONArray("level_new");
+ new NewLevelManager(context).UpDataLevel(levelArray.toJSONString());
+ }
+ if (obj.containsKey("levelanchor_new")) {//缓存等级数据
+ JSONArray levelArray = obj.getJSONArray("levelanchor_new");
+ new NewLevelManager(context).UpAnchorDataLevel(levelArray.toJSONString());
+ }
+ if (obj.containsKey("liveclass")) {//缓存直播间分类
+ JSONArray levelArray = obj.getJSONArray("liveclass");
+ new LiveClassManager(context).UpDataLiveClass(levelArray.toJSONString());
+ }
+ if (obj.containsKey("apk_ver")) {
+ APKManager.get().setApkVer(obj.getString("apk_ver"));
+ }
+ if (obj.containsKey("apk_url")) {
+ APKManager.get().setAPKUrl(obj.getString("apk_url"));
+ }
+ if (obj.containsKey("apk_des")) {
+ APKManager.get().setAPKDes(obj.getString("apk_des"));
+ }
+ if (obj.containsKey("google_isup")) {
+ APKManager.get().setAPKGoogleIsUp(obj.getInteger("google_isup"));
+ }
+ if (obj.containsKey("isup")) {
+ APKManager.get().setAPKIsUp(obj.getInteger("isup"));
+ }
+ if (obj.containsKey("clarity")) {
+ IMLoginManager.get(context).setClarity(obj.getString("clarity"));
+ }
+ if (obj.containsKey("defaultBubbleUrl")) {
+ IMLoginManager.get(context).setDefaultBubbleUrl(obj.getString("defaultBubbleUrl"));
+ }
+ if (obj.containsKey("gift_quantity")) {
+ JSONArray giftQuantity = obj.getJSONArray("gift_quantity");
+ new GiftQuantityManager(context).UpGiftQuantity(giftQuantity.toJSONString());
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ String error = "info[0]:" + info[0] + "\n\n\n" + "Exception:" + e.getClass() + "---message--->" + e.getMessage();
+ ErrorActivity.forward("GetConfig接口返回数据异常", error);
}
- });
+ } else if (code == 1000) {
+ new DialogUitl.Builder(context).setContent(msg).setCancelable(false).setClickCallback3(new DialogUitl.SimpleCallback3() {
+ @Override
+ public void onConfirmClick(Dialog dialog) {
+ AppManager.getInstance().AppExit();
+ }
+
+ @Override
+ public void onCancel() {
+ AppManager.getInstance().AppExit();
+ }
+ }).build().show();
+ } else {
+ ToastUtil.show(context.getString(R.string.net_error) + "code:" + code + " msg:" + msg);
+ }
+ }
+
+ @Override
+ public void onError() {
+ if (commonCallback != null) {
+ commonCallback.callback(null);
+ }
+ }
+ });
}
@@ -280,20 +271,18 @@ public class CommonHttpUtil {
* QQ登录的时候 获取unionID 与PC端互通的时候用
*/
public static void getQQLoginUnionID(String accessToken, final CommonCallback commonCallback) {
- OkGo.get("https://graph.qq.com/oauth2.0/me?access_token=" + accessToken + "&unionid=1")
- .tag(CommonHttpConsts.GET_QQ_LOGIN_UNION_ID)
- .execute(new StringCallback() {
- @Override
- public void onSuccess(Response response) {
- if (commonCallback != null) {
- String data = response.body();
- data = data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1);
- L.e("getQQLoginUnionID------>" + data);
- JSONObject obj = JSON.parseObject(data);
- commonCallback.callback(obj.getString("unionid"));
- }
- }
- });
+ OkGo.get("https://graph.qq.com/oauth2.0/me?access_token=" + accessToken + "&unionid=1").tag(CommonHttpConsts.GET_QQ_LOGIN_UNION_ID).execute(new StringCallback() {
+ @Override
+ public void onSuccess(Response response) {
+ if (commonCallback != null) {
+ String data = response.body();
+ data = data.substring(data.indexOf("{"), data.lastIndexOf("}") + 1);
+ L.e("getQQLoginUnionID------>" + data);
+ JSONObject obj = JSON.parseObject(data);
+ commonCallback.callback(obj.getString("unionid"));
+ }
+ }
+ });
}
@@ -312,13 +301,11 @@ public class CommonHttpUtil {
ToastUtil.show(WordUtil.getString(R.string.cannot_follow_self));
return;
}
- HttpClient.getInstance().get("User.setAttents", tag)
- .params("touid", touid)
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0 && info.length > 0 || code == 1001) {
- int isAttention = JSON.parseObject(info[0]).getIntValue("isattent");//1是 关注 0是未关注
+ HttpClient.getInstance().get("User.setAttents", tag).params("touid", touid).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0 && info.length > 0 || code == 1001) {
+ int isAttention = JSON.parseObject(info[0]).getIntValue("isattent");//1是 关注 0是未关注
/* if (code == 1001) {
if (WordUtil.isNewZh()) {
ToastUtil.show("粉絲團等級已清零,待領取獎勵已自動領取至【個性裝扮】");
@@ -326,13 +313,13 @@ public class CommonHttpUtil {
ToastUtil.show("The level of the fan club has been cleared, and the rewards to be claimed have been automatically received to [Personalized Dressing]");
}
}*/
- EventBus.getDefault().post(new FollowEvent(touid, isAttention));
- if (callback != null) {
- callback.callback(isAttention);
- }
- }
+ EventBus.getDefault().post(new FollowEvent(touid, isAttention));
+ if (callback != null) {
+ callback.callback(isAttention);
}
- });
+ }
+ }
+ });
}
/**
@@ -340,15 +327,14 @@ public class CommonHttpUtil {
*/
public static void getBalance(HttpCallback callback) {
String isGoogle;
- if (CommonAppConfig.IS_GOOGLE_PLAY) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
isGoogle = "1";
+ } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ isGoogle = "2";
} else {
isGoogle = "-1";
}
- HttpClient.getInstance().get("User.getBalance", CommonHttpConsts.GET_BALANCE)
- .params("type", 0)
- .params("isGooglePay", isGoogle)
- .execute(callback);
+ HttpClient.getInstance().get("User.getBalance", CommonHttpConsts.GET_BALANCE).params("type", 0).params("isGooglePay", isGoogle).execute(callback);
}
/**
@@ -357,8 +343,7 @@ public class CommonHttpUtil {
* @param callback
*/
public static void getAliOrder(String parmas, HttpCallback callback) {
- HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_ALI_ORDER)
- .execute(callback);
+ HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_ALI_ORDER).execute(callback);
}
/**
@@ -367,8 +352,7 @@ public class CommonHttpUtil {
* @param callback
*/
public static void getWxOrder(String parmas, HttpCallback callback) {
- HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_WX_ORDER)
- .execute(callback);
+ HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_WX_ORDER).execute(callback);
}
@@ -379,8 +363,7 @@ public class CommonHttpUtil {
*/
public static void getCashierOrder(String parmas, HttpCallback callback) {
- HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_CASHIER_ORDER)
- .execute(callback);
+ HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_CASHIER_ORDER).execute(callback);
}
@@ -392,8 +375,7 @@ public class CommonHttpUtil {
public static void getWxH5Order(String parmas, HttpCallback callback) {
- HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_WX_H5ORDER)
- .execute(callback);
+ HttpClient.getInstance().get(parmas, CommonHttpConsts.GET_WX_H5ORDER).execute(callback);
}
@@ -401,8 +383,7 @@ public class CommonHttpUtil {
* 检查token是否失效
*/
public static void checkTokenInvalid() {
- HttpClient.getInstance().get("User.ifToken", CommonHttpConsts.CHECK_TOKEN_INVALID)
- .execute(NO_CALLBACK);
+ HttpClient.getInstance().get("User.ifToken", CommonHttpConsts.CHECK_TOKEN_INVALID).execute(NO_CALLBACK);
}
@@ -410,32 +391,15 @@ public class CommonHttpUtil {
* 谷歌支付成功后,通知自己服务器
*/
public static void notifyMeGoogle(String purchaseToken, String productId, String orderno, HttpCallback callback) {
- 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);
+ 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);
+ 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 Google_sec_pay(String purchaseToken, String orderNo, String tradeNo, HttpCallback callback) {
- HttpClient.getInstance().get("Charge.Google_sec_pay", "Charge.Google_sec_pay")
- .params("purchaseToken", purchaseToken)
- .params("orderno", orderNo)
- .params("trade_no", tradeNo)
- .params("package_name", "com.pdlive.shayu")
- .execute(callback);
+ HttpClient.getInstance().get("Charge.Google_sec_pay", "Charge.Google_sec_pay").params("purchaseToken", purchaseToken).params("orderno", orderNo).params("trade_no", tradeNo).params("package_name", "com.pdlive.shayu").execute(callback);
}
//不做任何操作的HttpCallback
@@ -452,20 +416,9 @@ public class CommonHttpUtil {
public static void setCommunityReport(String community_type, String comment_id, String dynamic_id, String content, File file1, File file2, File file3, String report_type, HttpCallback callback) {
PostRequest request;
if ("2".equals(community_type)) {
- request = HttpClient.getInstance().post(CommonHttpConsts.COMMUNITY_SETREPORT, CommonHttpConsts.COMMUNITY_SETREPORT)
- .isMultipart(true)
- .params("dynamic_id", dynamic_id)
- .params("report_type", report_type)
- .params("content", content)
- .params("community_type", community_type)
- .params("comment_id", comment_id);
+ request = HttpClient.getInstance().post(CommonHttpConsts.COMMUNITY_SETREPORT, CommonHttpConsts.COMMUNITY_SETREPORT).isMultipart(true).params("dynamic_id", dynamic_id).params("report_type", report_type).params("content", content).params("community_type", community_type).params("comment_id", comment_id);
} else {
- request = HttpClient.getInstance().post(CommonHttpConsts.COMMUNITY_SETREPORT, CommonHttpConsts.COMMUNITY_SETREPORT)
- .isMultipart(true)
- .params("dynamic_id", dynamic_id)
- .params("report_type", report_type)
- .params("content", content)
- .params("community_type", community_type);
+ request = HttpClient.getInstance().post(CommonHttpConsts.COMMUNITY_SETREPORT, CommonHttpConsts.COMMUNITY_SETREPORT).isMultipart(true).params("dynamic_id", dynamic_id).params("report_type", report_type).params("content", content).params("community_type", community_type);
}
if (file1 != null) {
request.params("file1", file1);
@@ -483,9 +436,7 @@ public class CommonHttpUtil {
* 用户个人主页信息
*/
public static void getUserBaseinfo(String touid, HttpCallback callback) {
- HttpClient.getInstance().get("User.getUserBaseinfo", CommonHttpConsts.GET_USER_BASEINFO)
- .params("touid", touid)
- .execute(callback);
+ HttpClient.getInstance().get("User.getUserBaseinfo", CommonHttpConsts.GET_USER_BASEINFO).params("touid", touid).execute(callback);
}
//
// //埋点唯一性
diff --git a/common/src/main/java/com/yunbao/common/pay/hw/HwBuilder.java b/common/src/main/java/com/yunbao/common/pay/hw/HwBuilder.java
new file mode 100644
index 000000000..3f37f6bb6
--- /dev/null
+++ b/common/src/main/java/com/yunbao/common/pay/hw/HwBuilder.java
@@ -0,0 +1,62 @@
+package com.yunbao.common.pay.hw;
+
+import android.app.Activity;
+import android.content.Intent;
+
+
+import org.json.JSONObject;
+
+/**
+ * 华为支付
+ */
+public class HwBuilder {
+
+ private Activity mActivity;
+
+ public HwBuilder(Activity activity) {
+ mActivity = activity;
+ }
+
+ /**
+ * 支付
+ */
+ public void pay(String changeid) {
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_huawei.utils.HuaWeiPayManage");
+ Object invite = clz.getConstructor(Activity.class).newInstance(mActivity);
+ invite.getClass().getMethod("pay", String.class).invoke(invite, changeid);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 消耗所有商品
+ */
+ public void consume() {
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_huawei.utils.HuaWeiPayManage");
+ Object invite = clz.getConstructor(Activity.class).newInstance(mActivity);
+ invite.getClass().getMethod("consume").invoke(invite);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * 获取支付结果
+ *
+ * @return
+ */
+ public JSONObject getPayResult(Intent intent) {
+ JSONObject object;
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_huawei.utils.HuaWeiPayManage");
+ Object invite = clz.getConstructor(Activity.class).newInstance(mActivity);
+ object = (JSONObject) invite.getClass().getMethod("getPayResult", Intent.class).invoke(invite, intent);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return object;
+ }
+}
diff --git a/common/src/main/java/com/yunbao/common/utils/GoogleBillingUtilNew.java b/common/src/main/java/com/yunbao/common/utils/GoogleBillingUtilNew.java
index d6206a86b..9658d9975 100644
--- a/common/src/main/java/com/yunbao/common/utils/GoogleBillingUtilNew.java
+++ b/common/src/main/java/com/yunbao/common/utils/GoogleBillingUtilNew.java
@@ -134,7 +134,6 @@ public class GoogleBillingUtilNew {
Log.e(TAG, "支付失败:code = " + code + " msg = " + msg);
}
}
-
};
diff --git a/common/src/main/java/com/yunbao/common/utils/GoogleCallBack.java b/common/src/main/java/com/yunbao/common/utils/GoogleCallBack.java
new file mode 100644
index 000000000..fe8880de3
--- /dev/null
+++ b/common/src/main/java/com/yunbao/common/utils/GoogleCallBack.java
@@ -0,0 +1,7 @@
+package com.yunbao.common.utils;
+
+public class GoogleCallBack {
+ public void processResponse() {
+ L.e("___GoogleCallBack___processResponse");
+ }
+}
diff --git a/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java b/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java
new file mode 100644
index 000000000..c8d001a14
--- /dev/null
+++ b/common/src/main/java/com/yunbao/common/utils/GoogleUtils.java
@@ -0,0 +1,212 @@
+package com.yunbao.common.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.content.Intent;
+
+import com.android.billingclient.api.Purchase;
+import com.google.android.gms.ads.identifier.AdvertisingIdClient;
+import com.shayu.lib_google.utils.GoogleBillingManage;
+
+import org.json.JSONObject;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Date;
+import java.util.List;
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ * 谷歌工具类
+ */
+public class GoogleUtils {
+
+ Activity mActivity;
+
+ Context mContext;
+
+ Object googlePay;
+
+ public static GoogleUtils googleUtils;
+
+ public GoogleUtils(Activity activity) {
+ this.mActivity = activity;
+ }
+
+ public GoogleUtils(Context mContext) {
+ this.mContext = mContext;
+ }
+
+
+ public static GoogleUtils newInstance(Context mContext) {
+ if (googleUtils == null) {
+ googleUtils = new GoogleUtils(mContext);
+ }
+ return googleUtils;
+ }
+
+
+ public static GoogleUtils newInstance(Activity mContext) {
+ if (googleUtils == null) {
+ googleUtils = new GoogleUtils(mContext);
+ }
+ return googleUtils;
+ }
+
+
+ /**
+ * 获取登录Intnet
+ *
+ * @return
+ */
+ public Intent getIntent() {
+ Intent intent;
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleManage");
+ Object invite = clz.getConstructor(Activity.class).newInstance(mActivity);
+ intent = (Intent) invite.getClass().getMethod("googleLogin").invoke(invite);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return intent;
+ }
+
+ /**
+ * 获取支付结果
+ *
+ * @return
+ */
+ public JSONObject getLoginResult(Intent intent) {
+ JSONObject object;
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleManage");
+ Object invite = clz.getConstructor(Activity.class).newInstance(mActivity);
+ object = (JSONObject) invite.getClass().getMethod("getLoginResult", Intent.class).invoke(invite, intent);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return object;
+ }
+
+
+ /**
+ * 初始化谷歌支付
+ */
+ public void initGooglePay() {
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleBillingManage");
+ googlePay = clz.getConstructor(Activity.class).newInstance(mActivity);
+ googlePay.getClass().getMethod("initGooglePay").invoke(googlePay);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public String getAdid() {
+ String adId;
+ try {
+ Class> clz = mActivity.getClassLoader().loadClass("com.shayu.lib_google.utils.GoogleBillingManage");
+ Object invite = clz.getConstructor(Activity.class).newInstance(mActivity);
+ adId = (String) invite.getClass().getMethod("getAdid").invoke(googlePay);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ return adId;
+ }
+
+ /**
+ * 购买
+ */
+ public void purchase(String skuId) {
+ try {
+ googlePay.getClass().getMethod("checkSku", String.class).invoke(googlePay, skuId);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setBillingListener(GoogleBillingListener billingListener) {
+ Timer timer = new Timer();
+ TimerTask task = new TimerTask() {
+ @Override
+ public void run() {
+ try {
+ JSONObject resultCode = (JSONObject) googlePay.getClass().getMethod("getPayResult").invoke(googlePay);
+ int code = resultCode.getInt("resultCode");
+ String token = resultCode.getString("resultToken");
+ String orderId = resultCode.getString("resultOrderId");
+ if (code == 0) {
+ billingListener.onPaySuccess(token, orderId);
+ timer.cancel();
+ } else if (code == 1 || code == 2) {
+ billingListener.onPayFailed("支付失败");
+ timer.cancel();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ timer.scheduleAtFixedRate(task, 60000, 1000);
+ }
+
+ public void initializeApp(Context context) {
+ try {
+ Class> clz = context.getClassLoader().loadClass("com.shayu.lib_google.utils.FirebaseManage");
+ Object invite = clz.getConstructor(Context.class).newInstance(context);
+ invite.getClass().getMethod("initializeApp").invoke(invite);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public void setFirebaseTokenListener(Activity activity, FirebaseTokenListener firebaseTokenListener) {
+ Timer timer = new Timer();
+ TimerTask task = new TimerTask() {
+ @Override
+ public void run() {
+ try {
+ Class> clz = activity.getClassLoader().loadClass("com.shayu.lib_google.utils.FirebaseManage");
+ googlePay = clz.getConstructor(Activity.class).newInstance(activity);
+ String token = (String) googlePay.getClass().getMethod("getToken").invoke(googlePay);
+ if (!StringUtil.isEmpty(token)) {
+ firebaseTokenListener.onResultToken(token);
+ timer.cancel();
+ }
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+ };
+ timer.schedule(task, 10000, 1000);
+ }
+
+ public void initFireToken(Activity activity) {
+ try {
+ Class> clz = activity.getClassLoader().loadClass("com.shayu.lib_google.utils.FirebaseManage");
+ googlePay = clz.getConstructor(Activity.class).newInstance(activity);
+ googlePay.getClass().getMethod("initToken").invoke(googlePay);
+ } catch (Exception e) {
+
+ }
+ }
+
+
+ /**
+ * 定义接口返回支付结果
+ */
+ public interface GoogleBillingListener {
+ void onPaySuccess(String token, String orderId);
+
+ void onPayFailed(String msg);
+ }
+
+ public interface FirebaseTokenListener {
+ void onResultToken(String token);
+ }
+
+}
diff --git a/common/src/main/java/com/yunbao/common/utils/LogUtil.java b/common/src/main/java/com/yunbao/common/utils/LogUtil.java
index b5deb1c93..d94e6e365 100644
--- a/common/src/main/java/com/yunbao/common/utils/LogUtil.java
+++ b/common/src/main/java/com/yunbao/common/utils/LogUtil.java
@@ -99,50 +99,41 @@ public class LogUtil {
} else {
time = System.currentTimeMillis() + "";
}
- PostRequest request = OkGo.post("https://newht.yaoulive.com/index.php/api/error_log/report")
- .params("log", err)
- .params("uid", CommonAppConfig.getInstance().getUid())
- .params("time", time)
- .params("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY)
- .params("appVersion", CommonAppConfig.getInstance().getVersion())
- .tag("errorLog")
- .converter(new StringCallback() {
- String TAG = "异常上传";
+ PostRequest request = OkGo.post("https://newht.yaoulive.com/index.php/api/error_log/report").params("log", err).params("uid", CommonAppConfig.getInstance().getUid()).params("time", time).params("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY).params("appVersion", CommonAppConfig.getInstance().getVersion()).tag("errorLog").converter(new StringCallback() {
+ String TAG = "异常上传";
- @Override
- public void onSuccess(Response response) {
- Log.i(TAG, "onSuccess: " + response.message());
- file.delete();
- }
- });
- UploadTask task = OkUpload.request("errorLog", request)
- .save()
- .register(new UploadListener("errorLog") {
+ @Override
+ public void onSuccess(Response response) {
+ Log.i(TAG, "onSuccess: " + response.message());
+ file.delete();
+ }
+ });
+ UploadTask task = OkUpload.request("errorLog", request).save().register(new UploadListener("errorLog") {
- @Override
- public void onStart(Progress progress) {
+ @Override
+ public void onStart(Progress progress) {
- }
+ }
- @Override
- public void onProgress(Progress progress) {
+ @Override
+ public void onProgress(Progress progress) {
- }
+ }
- @Override
- public void onError(Progress progress) {
- }
+ @Override
+ public void onError(Progress progress) {
+ }
- @Override
- public void onFinish(String s, Progress progress) {
- file.delete();
- }
+ @Override
+ public void onFinish(String s, Progress progress) {
+ file.delete();
+ }
- @Override
- public void onRemove(Progress progress) {
+ @Override
+ public void onRemove(Progress progress) {
- }
- });
+ }
+ });
task.start();
}
}
@@ -160,12 +151,12 @@ public class LogUtil {
public static void shareFile(Context context) {
try {
IMLoginModel bean = IMLoginManager.get(context).getUserInfo();
- boolean isAnchor=false;
- if(bean!=null){
- isAnchor=bean.anchorUserType();
+ boolean isAnchor = false;
+ if (bean != null) {
+ isAnchor = bean.anchorUserType();
}
//有debug文件或主播才允许
- if (!new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "pdlive.debug").exists()&&!isAnchor) {
+ if (!new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "pdlive.debug").exists() && !isAnchor) {
return;
}
} catch (Exception e) {
@@ -225,7 +216,7 @@ public class LogUtil {
share.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
context.startActivity(Intent.createChooser(share, "分享文件"));
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && !CommonAppConfig.IS_GOOGLE_PLAY) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R && CommonAppConfig.IS_GOOGLE_PLAY == 0) {
if (!Environment.isExternalStorageManager()) {
Intent intent = new Intent(ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION);
context.startActivity(intent);
@@ -244,17 +235,14 @@ public class LogUtil {
}
}
- private static String TAG="Upload";
+
+ private static String TAG = "Upload";
+
private static void uploadLog(File log) {
JSONObject body = new JSONObject();
- MultipartBody requestBody = new MultipartBody.Builder()
- .addFormDataPart("uid", CommonAppConfig.getInstance().getUid())
- .addFormDataPart("time", new SimpleDateFormat("yyyy-DD-mm HH:mm:ss", Locale.getDefault()).format(new Date()))
- .addFormDataPart("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY+"")
- .addFormDataPart("appVersion", CommonAppConfig.getInstance().getVersion())
- .addFormDataPart("file","file", RequestBody.create(MediaType.parse("application/octet-stream"),log)) //上报日志文件
+ MultipartBody requestBody = new MultipartBody.Builder().addFormDataPart("uid", CommonAppConfig.getInstance().getUid()).addFormDataPart("time", new SimpleDateFormat("yyyy-DD-mm HH:mm:ss", Locale.getDefault()).format(new Date())).addFormDataPart("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY + "").addFormDataPart("appVersion", CommonAppConfig.getInstance().getVersion()).addFormDataPart("file", "file", RequestBody.create(MediaType.parse("application/octet-stream"), log)) //上报日志文件
.build();
body.put("uid", CommonAppConfig.getInstance().getUid());
@@ -262,28 +250,23 @@ public class LogUtil {
body.put("isGoogle", CommonAppConfig.IS_GOOGLE_PLAY);
body.put("appVersion", CommonAppConfig.getInstance().getVersion());
- OkHttpClient client = new OkHttpClient.Builder()
- .connectTimeout(3, TimeUnit.SECONDS)
- .build();
- Request request = new Request.Builder()
- .url("https://newht.yaoulive.com/index.php/api/error_log/report") //无法接受文件
- .post(requestBody)
- .build();
- client.newCall(request)
- .enqueue(new Callback() {
- @Override
- public void onFailure(@NonNull Call call, @NonNull IOException e) {
- Log.e(TAG, "error",e );
- }
+ OkHttpClient client = new OkHttpClient.Builder().connectTimeout(3, TimeUnit.SECONDS).build();
+ Request request = new Request.Builder().url("https://newht.yaoulive.com/index.php/api/error_log/report") //无法接受文件
+ .post(requestBody).build();
+ client.newCall(request).enqueue(new Callback() {
+ @Override
+ public void onFailure(@NonNull Call call, @NonNull IOException e) {
+ Log.e(TAG, "error", e);
+ }
- @Override
- public void onResponse(Call call, okhttp3.Response response) throws IOException {
- String body = response.body().string();
- Log.i(TAG, "onResponse: "+body);
- }
+ @Override
+ public void onResponse(Call call, okhttp3.Response response) throws IOException {
+ String body = response.body().string();
+ Log.i(TAG, "onResponse: " + body);
+ }
- });
+ });
}
diff --git a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java
index 0bea8f7e9..70439416c 100644
--- a/common/src/main/java/com/yunbao/common/utils/VersionUtil.java
+++ b/common/src/main/java/com/yunbao/common/utils/VersionUtil.java
@@ -40,11 +40,61 @@ public class VersionUtil {
}
-
//是否是谷歌版本
public void showDialog(Activity context, ConfigBean configBean, String downloadUrl) {
- //不是谷歌
- if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
+ //华为版本
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ //todo
+ //谷歌版本
+ } else if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ //谷歌强制更新
+ if (configBean.getGoogle_isup().equals("1")) {
+ DialogUitl.Builder builder = new DialogUitl.Builder(context);
+ builder.setTitle(context.getString(R.string.version_update))
+ .setContent(configBean.getUpdateDes())
+ .setConfirmString(context.getString(R.string.version_immediate_use))
+ .setCancelString(context.getString(R.string.version_not_update))
+ .setCancelable(false)
+ .setClickCallback(new DialogUitl.SimpleCallback2() {
+ public void onCancelClick() {
+ context.finish();
+ }
+
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ Intent i = new Intent(android.content.Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
+ context.startActivity(i);
+ context.finish();
+ }
+ })
+ .build()
+ .show();
+ //谷歌不强制
+ } else {
+ DialogUitl.Builder builder = new DialogUitl.Builder(context);
+ builder.setTitle(context.getString(R.string.version_update))
+ .setContent(configBean.getUpdateDes())
+ .setConfirmString(context.getString(R.string.version_immediate_use))
+ .setCancelString(context.getString(R.string.version_not_update))
+ .setCancelable(false)
+ .setClickCallback(new DialogUitl.SimpleCallback2() {
+ public void onCancelClick() {
+ }
+
+ @Override
+ public void onConfirmClick(Dialog dialog, String content) {
+ Intent i = new Intent(android.content.Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
+ context.startActivity(i);
+ context.finish();
+ }
+ })
+ .build()
+ .show();
+ }
+ } else {
+
//不强更
if (configBean.getForceUpdate() != 1) {
DialogUitl.Builder builder = new DialogUitl.Builder(context);
@@ -103,55 +153,6 @@ public class VersionUtil {
.build()
.show();
}
-
- //谷歌版本
- } else if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
- //谷歌强制更新
- if (configBean.getGoogle_isup().equals("1")) {
- DialogUitl.Builder builder = new DialogUitl.Builder(context);
- builder.setTitle(context.getString(R.string.version_update))
- .setContent(configBean.getUpdateDes())
- .setConfirmString(context.getString(R.string.version_immediate_use))
- .setCancelString(context.getString(R.string.version_not_update))
- .setCancelable(false)
- .setClickCallback(new DialogUitl.SimpleCallback2() {
- public void onCancelClick() {
- context.finish();
- }
-
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- Intent i = new Intent(android.content.Intent.ACTION_VIEW);
- i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
- context.startActivity(i);
- context.finish();
- }
- })
- .build()
- .show();
- //谷歌不强制
- } else {
- DialogUitl.Builder builder = new DialogUitl.Builder(context);
- builder.setTitle(context.getString(R.string.version_update))
- .setContent(configBean.getUpdateDes())
- .setConfirmString(context.getString(R.string.version_immediate_use))
- .setCancelString(context.getString(R.string.version_not_update))
- .setCancelable(false)
- .setClickCallback(new DialogUitl.SimpleCallback2() {
- public void onCancelClick() {
- }
-
- @Override
- public void onConfirmClick(Dialog dialog, String content) {
- Intent i = new Intent(android.content.Intent.ACTION_VIEW);
- i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
- context.startActivity(i);
- context.finish();
- }
- })
- .build()
- .show();
- }
}
}
diff --git a/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java b/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java
index c84312521..2813bfe9b 100644
--- a/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java
+++ b/common/src/main/java/com/yunbao/common/views/APKUpdateCustomPopup.java
@@ -69,10 +69,10 @@ public class APKUpdateCustomPopup extends CenterPopupView {
private void initView() {
if (!mInside) {
- if (!CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getAPKGoogleIsUp() == 1) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 0 && APKManager.get().getAPKGoogleIsUp() == 1) {
findViewById(R.id.dialog_close).setVisibility(GONE);
}
- if (!CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getAPKGoogleIsUp() == 1) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 0 && APKManager.get().getAPKGoogleIsUp() == 1) {
findViewById(R.id.dialog_close).setVisibility(GONE);
}
}
@@ -86,13 +86,16 @@ public class APKUpdateCustomPopup extends CenterPopupView {
ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.dialog_close), new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
- if (mInside){
+ if (mInside) {
dismiss();
- }else {
- if (CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getAPKGoogleIsUp() != 1) {
+ } else {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1 && APKManager.get().getAPKGoogleIsUp() != 1) {
dismiss();
}
- if (!CommonAppConfig.IS_GOOGLE_PLAY && APKManager.get().getApkIsUp() != 1) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 2 && APKManager.get().getAPKGoogleIsUp() != 1) {
+ dismiss();
+ }
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 0 && APKManager.get().getApkIsUp() != 1) {
dismiss();
}
}
@@ -103,8 +106,16 @@ public class APKUpdateCustomPopup extends CenterPopupView {
ViewClicksAntiShake.clicksAntiShake(versionImmediateUse, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
- //不是谷歌
- if (!CommonAppConfig.IS_GOOGLE_PLAY) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ Intent i = new Intent(android.content.Intent.ACTION_VIEW);
+ i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
+ mContext.startActivity(i);
+ mContext.finish();
+ } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ //华为
+ //todo
+
+ } else {
versionImmediateUse.setVisibility(GONE);
updateLine.setVisibility(VISIBLE);
downloadAPK(mContext, APKManager.get().getAPKUrl(), new APKDownloadUtil.OnUpdateListener() {
@@ -113,13 +124,7 @@ public class APKUpdateCustomPopup extends CenterPopupView {
ToastUtil.show(error);
}
});
- } else {
- Intent i = new Intent(android.content.Intent.ACTION_VIEW);
- i.setData(Uri.parse("https://play.google.com/store/apps/details?id=com.pdlive.shayu"));
- mContext.startActivity(i);
- mContext.finish();
}
-
}
});
}
diff --git a/config.gradle b/config.gradle
index 056734b2e..5b2b25b9c 100644
--- a/config.gradle
+++ b/config.gradle
@@ -9,20 +9,18 @@ ext {
]
manifestPlaceholders = [
//正式、
- serverHost : "https://napi.yaoulive.com",
+// serverHost : "https://napi.yaoulive.com",
// 测试
-// serverHost : " https://ceshi.yaoulive.com",
-
-
+ serverHost : " https://ceshi.yaoulive.com",
//百度语音识别
baiduAppId : "23774720",
- baiduAppKey : "zgCgFhUKEOV7I3ZXDFpTfnR B",
+ baiduAppKey : "zgCgFhUKEOV7I3ZXDFpTfnRB",
baiduAppSecretKey: "nEVSgmuGpU0pjPr6VleEGGAl0hzGW52S",
-// true表示谷歌支付 false
- isGooglePlay : true,
+// true表示谷歌支付 false 0 链接包 1 谷歌包 2华为包
+ isGooglePlay : 2,
//是否上报异常日志
isUploadLog : true,
//是否打包成插件包模式
diff --git a/gradle.properties b/gradle.properties
index e850a38e3..6772d3528 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -16,11 +16,13 @@ org.gradle.daemon=true
org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
org.gradle.parallel=true
org.gradle.configureondemand=true
+
+
android.useAndroidX=true
android.enableJetifier=true
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
-systemProp.https.proxyPort=10809
-systemProp.http.proxyPort=10809
+systemProp.https.proxyPort=49528
+systemProp.http.proxyPort=49528
#android.enableR8.fullMode=true
\ No newline at end of file
diff --git a/lib_country_code/build.gradle b/lib_country_code/build.gradle
index a2637c6dc..03733b197 100644
--- a/lib_country_code/build.gradle
+++ b/lib_country_code/build.gradle
@@ -25,10 +25,10 @@ android {
}
defaultConfig {
- minSdkVersion rootProject.ext.android.minSdkVersion
- targetSdkVersion rootProject.ext.android.targetSdkVersion
- versionCode rootProject.ext.android.versionCode
- versionName rootProject.ext.android.versionName
+ minSdkVersion minSdkVersion
+ targetSdkVersion targetSdkVersion
+ versionCode versionCode
+ versionName versionName
manifestPlaceholders = rootProject.ext.manifestPlaceholders
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/lib_google/.gitignore b/lib_google/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/lib_google/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/lib_google/build.gradle b/lib_google/build.gradle
new file mode 100644
index 000000000..9ce7ee81e
--- /dev/null
+++ b/lib_google/build.gradle
@@ -0,0 +1,37 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion rootProject.ext.android.compileSdkVersion
+ buildToolsVersion rootProject.ext.android.buildToolsVersion
+ defaultConfig {
+ minSdkVersion minSdkVersion
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ versionCode versionCode
+ versionName versionName
+ targetSdkVersion targetSdkVersion
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation rootProject.ext.dependencies["appcompat-androidx"]
+
+ //谷歌内购
+ api 'com.android.billingclient:billing:5.0.0'
+ //谷歌登录
+ api 'com.google.android.gms:play-services-auth:15.0.0'
+ api 'com.google.android.gms:play-services-ads-identifier:15.0.1'
+ api 'com.google.firebase:firebase-messaging:23.0.6'
+}
\ No newline at end of file
diff --git a/lib_google/consumer-rules.pro b/lib_google/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib_google/proguard-rules.pro b/lib_google/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/lib_google/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/lib_google/src/main/AndroidManifest.xml b/lib_google/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..deeb96ae2
--- /dev/null
+++ b/lib_google/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java b/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java
new file mode 100644
index 000000000..69cc5253e
--- /dev/null
+++ b/lib_google/src/main/java/com/shayu/lib_google/utils/FirebaseManage.java
@@ -0,0 +1,51 @@
+package com.shayu.lib_google.utils;
+
+import android.app.Activity;
+import android.content.Context;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+
+import com.google.android.gms.tasks.OnCompleteListener;
+import com.google.android.gms.tasks.Task;
+import com.google.firebase.FirebaseApp;
+import com.google.firebase.messaging.FirebaseMessaging;
+
+public class FirebaseManage {
+ private Activity mActivity;
+ private Context mContext;
+
+ public FirebaseManage(Activity activity) {
+ this.mActivity = activity;
+ }
+
+ public FirebaseManage(Context mContext) {
+ this.mContext = mContext;
+ }
+
+ String token = "";
+
+ public String getToken() {
+ return token;
+ }
+
+ public void initToken() {
+ FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener() {
+ @Override
+ public void onComplete(@NonNull Task task) {
+ if (!task.isSuccessful()) {
+ Log.w("TAG", "Fetching FCM registration token failed", task.getException());
+ return;
+ }
+ // Get new FCM registration token
+ token = task.getResult();
+ // Log and toast
+ Log.d("TAG", token);
+ }
+ });
+ }
+
+ public void initializeApp() {
+ FirebaseApp.initializeApp(mContext);
+ }
+}
diff --git a/lib_google/src/main/java/com/shayu/lib_google/utils/GoogleBillingManage.java b/lib_google/src/main/java/com/shayu/lib_google/utils/GoogleBillingManage.java
new file mode 100644
index 000000000..3c99b233a
--- /dev/null
+++ b/lib_google/src/main/java/com/shayu/lib_google/utils/GoogleBillingManage.java
@@ -0,0 +1,214 @@
+package com.shayu.lib_google.utils;
+
+import android.app.Activity;
+import android.os.Handler;
+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.ConsumeResponseListener;
+import com.android.billingclient.api.Purchase;
+import com.android.billingclient.api.PurchasesResponseListener;
+import com.android.billingclient.api.PurchasesUpdatedListener;
+import com.android.billingclient.api.QueryPurchasesParams;
+import com.android.billingclient.api.SkuDetails;
+import com.android.billingclient.api.SkuDetailsParams;
+import com.android.billingclient.api.SkuDetailsResponseListener;
+import com.google.android.gms.ads.identifier.AdvertisingIdClient;
+import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
+import com.google.android.gms.common.GooglePlayServicesRepairableException;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 新写Google内付工具类做简单的封装
+ * 支付流程:初始化Google支付服务-->查询商品-->购买-->支付成功回调-->消耗商品
+ */
+public class GoogleBillingManage implements PurchasesUpdatedListener {
+ private BillingClient billingClient;
+ private Activity mContext;
+ private String TAG = "GoogleBillingManage";
+
+ public GoogleBillingManage(Activity activity) {
+ this.mContext = activity;
+ }
+
+ public void initGooglePay() {
+ billingClient = BillingClient.newBuilder(mContext).setListener(this).enablePendingPurchases().build();
+ //请求连接到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 checkSku(String id) {
+ List skuList = new ArrayList<>();
+ skuList.add(id);
+ SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder().setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
+ billingClient.querySkuDetailsAsync(params.build(), new SkuDetailsResponseListener() {
+ @Override
+ public void onSkuDetailsResponse(@NonNull BillingResult billingResult, @Nullable List 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(list.get(0));
+ }
+ });
+ }
+
+ //购买
+ private void buyIt(SkuDetails skuDetails) {
+ BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder().setSkuDetails(skuDetails).build();
+ BillingResult billingResult = billingClient.launchBillingFlow(mContext, billingFlowParams);
+ int code = billingResult.getResponseCode();
+ if (code != BillingClient.BillingResponseCode.OK) {
+ String msg = billingResult.getDebugMessage();
+ Log.e(TAG, "购买商品失败 code = " + code + " msg = " + msg);
+ return;
+ }
+ Log.e(TAG, "购买商品" + skuDetails.toString());
+ }
+
+ //消耗商品
+ public void consume(List list) {
+ if (list == null || list.isEmpty() || billingClient == null) {
+ return;
+ }
+ for (Purchase purchase : list) {
+ billingClient.consumeAsync(ConsumeParams.newBuilder().setPurchaseToken(purchase.getPurchaseToken()).build(), new ConsumeResponseListener() {
+ @Override
+ public void onConsumeResponse(BillingResult billingResult, String purchaseToken) {
+ Log.e(TAG, "onConsumeResponse code = " + billingResult.getResponseCode() + " , msg = " + billingResult.getDebugMessage() + " , purchaseToken = " + purchaseToken);
+ }
+ });
+ }
+ }
+
+ /**
+ * 查询商品订单
+ */
+ public void queryPurchasesAsync(PurchasesResponseListener responseListener) {
+ if (billingClient == null) return;
+ //内购商品交易查询
+ //内购商品交易查询
+ QueryPurchasesParams inAppPurchasesQurey = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.INAPP).build();
+ billingClient.queryPurchasesAsync(inAppPurchasesQurey, responseListener);
+ }
+
+ public String getAdid() {
+ try {
+ return AdvertisingIdClient.getAdvertisingIdInfo(mContext).getId();
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ } catch (GooglePlayServicesNotAvailableException e) {
+ throw new RuntimeException(e);
+ } catch (GooglePlayServicesRepairableException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ int resultCode = -1;
+ String resultToken = "";
+ String resultOrderId = "";
+
+ public JSONObject getPayResult() {
+ JSONObject object = new JSONObject();
+ try {
+ object.put("resultCode", resultCode);
+ object.put("resultToken", resultToken);
+ object.put("resultOrderId", resultOrderId);
+ } catch (JSONException e) {
+ throw new RuntimeException(e);
+ }
+ return object;
+ }
+
+ @Override
+ public void onPurchasesUpdated(@NonNull BillingResult billingResult, @Nullable List list) {
+ int code = billingResult.getResponseCode();
+ String msg = billingResult.getDebugMessage();
+
+ Log.e(TAG, "onPurchasesUpdated:code = " + code + " msg = " + msg);
+
+ if (list != null) {
+ for (Purchase purchase : list) {
+ Log.e(TAG, "onPurchasesUpdated:" + purchase.toString());
+ }
+ if (list.get(0) != null) {
+ resultToken = list.get(0).getPurchaseToken();
+ resultOrderId = list.get(0).getOrderId();
+ }
+ }
+ if (code == BillingClient.BillingResponseCode.OK && list != null) {
+ consume(list);
+ resultCode = 0;
+ Log.e(TAG, "支付成功");
+ if (billingListener != null) {
+ billingListener.onPaySuccess(list);
+ }
+ } else if (code == BillingClient.BillingResponseCode.USER_CANCELED) {
+ Log.e(TAG, "支付取消");
+ resultCode = 1;
+ if (billingListener != null) {
+ billingListener.onPayFailed(code, msg);
+ }
+ } else {
+ resultCode = 2;
+ if (billingListener != null) {
+ billingListener.onPayFailed(code, msg);
+ }
+ Log.e(TAG, "支付失败:code = " + code + " msg = " + msg);
+ }
+ }
+
+ /**
+ * 定义接口返回支付结果
+ */
+ public interface GoogleBillingListener {
+ void onPaySuccess(List list);
+
+ void onPayFailed(int code, String msg);
+ }
+
+ private GoogleBillingListener billingListener;
+
+ public GoogleBillingManage setBillingListener(GoogleBillingListener billingListener) {
+ this.billingListener = billingListener;
+ return this;
+ }
+}
diff --git a/lib_google/src/main/java/com/shayu/lib_google/utils/GoogleManage.java b/lib_google/src/main/java/com/shayu/lib_google/utils/GoogleManage.java
new file mode 100644
index 000000000..60c660eb9
--- /dev/null
+++ b/lib_google/src/main/java/com/shayu/lib_google/utils/GoogleManage.java
@@ -0,0 +1,59 @@
+package com.shayu.lib_google.utils;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.util.Log;
+
+import com.google.android.gms.auth.api.signin.GoogleSignIn;
+import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
+import com.google.android.gms.auth.api.signin.GoogleSignInClient;
+import com.google.android.gms.auth.api.signin.GoogleSignInOptions;
+import com.google.android.gms.common.api.ApiException;
+import com.google.android.gms.tasks.Task;
+
+import org.json.JSONObject;
+
+public class GoogleManage {
+
+ Activity mActivity;
+
+ public GoogleManage(Activity mContext) {
+ this.mActivity = mContext;
+ }
+
+ /**
+ * 谷歌登录
+ *
+ * @return
+ */
+ public Intent googleLogin() {
+ GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN).requestEmail().build();
+ GoogleSignInClient mGoogleSignInClient = GoogleSignIn.getClient(mActivity, gso);
+ return mGoogleSignInClient.getSignInIntent();
+ }
+
+
+ /**
+ * 获取登录回调
+ *
+ * @return
+ */
+ public JSONObject getLoginResult(Intent data) {
+ JSONObject object = new JSONObject();
+ Task task = GoogleSignIn.getSignedInAccountFromIntent(data);
+ try {
+ GoogleSignInAccount account = task.getResult(ApiException.class);
+ //account里可以直接获取到ID,name,和头像
+ String idToken = account.getIdToken();
+ account.getFamilyName();
+ account.getGivenName();
+
+ object.put("displayName", account.getDisplayName());
+ object.put("openId", account.getId());
+
+ } catch (Exception e) {
+ Log.i("Log", "ApiException = " + e);
+ }
+ return object;
+ }
+}
diff --git a/lib_google/src/test/java/com/shayu/lib_huawei/ExampleUnitTest.java b/lib_google/src/test/java/com/shayu/lib_huawei/ExampleUnitTest.java
new file mode 100644
index 000000000..7e3402cf9
--- /dev/null
+++ b/lib_google/src/test/java/com/shayu/lib_huawei/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.shayu.lib_huawei;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/lib_huawei/.gitignore b/lib_huawei/.gitignore
new file mode 100644
index 000000000..42afabfd2
--- /dev/null
+++ b/lib_huawei/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/lib_huawei/build.gradle b/lib_huawei/build.gradle
new file mode 100644
index 000000000..5e8964d43
--- /dev/null
+++ b/lib_huawei/build.gradle
@@ -0,0 +1,32 @@
+apply plugin: 'com.android.library'
+
+android {
+ compileSdkVersion rootProject.ext.android.compileSdkVersion
+ buildToolsVersion rootProject.ext.android.buildToolsVersion
+ defaultConfig {
+ minSdkVersion minSdkVersion
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ consumerProguardFiles "consumer-rules.pro"
+ versionCode versionCode
+ versionName versionName
+ targetSdkVersion targetSdkVersion
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+}
+
+dependencies {
+ implementation rootProject.ext.dependencies["appcompat-androidx"]
+
+ api 'com.huawei.hms:iap:4.0.4.301'
+}
\ No newline at end of file
diff --git a/lib_huawei/consumer-rules.pro b/lib_huawei/consumer-rules.pro
new file mode 100644
index 000000000..e69de29bb
diff --git a/lib_huawei/proguard-rules.pro b/lib_huawei/proguard-rules.pro
new file mode 100644
index 000000000..481bb4348
--- /dev/null
+++ b/lib_huawei/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/lib_huawei/src/androidTest/java/com/shayu/lib_huawei/ExampleInstrumentedTest.java b/lib_huawei/src/androidTest/java/com/shayu/lib_huawei/ExampleInstrumentedTest.java
new file mode 100644
index 000000000..3a5daeb99
--- /dev/null
+++ b/lib_huawei/src/androidTest/java/com/shayu/lib_huawei/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package com.shayu.lib_huawei;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+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 Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("com.shayu.lib_huawei.test", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/lib_huawei/src/main/AndroidManifest.xml b/lib_huawei/src/main/AndroidManifest.xml
new file mode 100644
index 000000000..b9b2617ac
--- /dev/null
+++ b/lib_huawei/src/main/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/lib_huawei/src/main/java/com/shayu/lib_huawei/utils/HuaWeiPayManage.java b/lib_huawei/src/main/java/com/shayu/lib_huawei/utils/HuaWeiPayManage.java
new file mode 100644
index 000000000..4ea0d17ec
--- /dev/null
+++ b/lib_huawei/src/main/java/com/shayu/lib_huawei/utils/HuaWeiPayManage.java
@@ -0,0 +1,164 @@
+package com.shayu.lib_huawei.utils;
+
+import android.app.Activity;
+import android.content.Intent;
+import android.content.IntentSender;
+import android.os.Build;
+import android.util.Log;
+import android.widget.Toast;
+
+import androidx.annotation.RequiresApi;
+
+import com.huawei.hmf.tasks.OnCanceledListener;
+import com.huawei.hmf.tasks.OnFailureListener;
+import com.huawei.hmf.tasks.OnSuccessListener;
+import com.huawei.hmf.tasks.Task;
+import com.huawei.hms.iap.Iap;
+import com.huawei.hms.iap.IapApiException;
+import com.huawei.hms.iap.IapClient;
+import com.huawei.hms.iap.entity.ConsumeOwnedPurchaseReq;
+import com.huawei.hms.iap.entity.ConsumeOwnedPurchaseResult;
+import com.huawei.hms.iap.entity.InAppPurchaseData;
+import com.huawei.hms.iap.entity.OwnedPurchasesReq;
+import com.huawei.hms.iap.entity.OwnedPurchasesResult;
+import com.huawei.hms.iap.entity.PurchaseIntentReq;
+import com.huawei.hms.iap.entity.PurchaseIntentResult;
+import com.huawei.hms.iap.entity.PurchaseResultInfo;
+import com.huawei.hms.support.api.client.Status;
+
+import org.json.JSONException;
+import org.json.JSONObject;
+
+public class HuaWeiPayManage {
+
+ IapClient mClient;
+
+ Activity mContext;
+
+ public HuaWeiPayManage(Activity mContext) {
+ this.mContext = mContext;
+ mClient = Iap.getIapClient(mContext);
+ }
+
+ @RequiresApi(api = Build.VERSION_CODES.DONUT)
+ public void pay(String changeid) {
+ Task task = mClient.createPurchaseIntent(createPurchaseIntentReq(0, changeid, "35ee54225cc803bb233d9ec2aa8ae65618f131de77c2a37761dda822f4debeee"));
+ task.addOnSuccessListener(new OnSuccessListener() {
+ @Override
+ public void onSuccess(PurchaseIntentResult result) {
+ result.getReturnCode();
+ if (result == null) {
+ Log.e("TAG", "result is null");
+ return;
+ }
+ Status status = result.getStatus();
+ if (status == null) {
+ Log.e("TAG", "status is null");
+ return;
+ }
+ if (status.hasResolution()) {
+ try {
+ status.startResolutionForResult(mContext, 6666);
+ } catch (IntentSender.SendIntentException exp) {
+ Log.e("TAG", exp.getMessage());
+ }
+ } else {
+ Log.e("TAG", "intent is null");
+ }
+ }
+ }).addOnFailureListener(new OnFailureListener() {
+ @Override
+ public void onFailure(Exception e) {
+ Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show();
+ }
+ }).addOnCanceledListener(new OnCanceledListener() {
+ @Override
+ public void onCanceled() {
+ Toast.makeText(mContext, "", Toast.LENGTH_SHORT).show();
+ }
+ });
+ }
+
+ private PurchaseIntentReq createPurchaseIntentReq(int type, String productId, String token) {
+ PurchaseIntentReq req = new PurchaseIntentReq();
+ req.setProductId(productId);
+ req.setPriceType(type);
+ req.setDeveloperPayload(token);
+ return req;
+ }
+
+ public JSONObject getPayResult(Intent data) {
+ JSONObject object = new JSONObject();
+ PurchaseResultInfo purchaseResultInfo = Iap.getIapClient(mContext).parsePurchaseResultInfoFromIntent(data);
+ try {
+ object.put("code", purchaseResultInfo.getReturnCode());
+ object.put("inAppPurchaseData", purchaseResultInfo.getInAppPurchaseData());
+ object.put("inAppPurchaseDataSignature", purchaseResultInfo.getInAppDataSignature());
+ } catch (JSONException e) {
+ throw new RuntimeException(e);
+ }
+ return object;
+ }
+
+
+ /**
+ * 消耗所有商品
+ */
+ public void consume() {
+ OwnedPurchasesReq ownedPurchasesReq = new OwnedPurchasesReq();
+ // priceType: 0:消耗型商品; 1:非消耗型商品; 2:订阅型商品
+ ownedPurchasesReq.setPriceType(0);
+ // 获取调用接口的Activity对象
+ // 调用obtainOwnedPurchases接口获取所有已购但未发货的消耗型商品的购买信息
+ Task task = Iap.getIapClient(mContext).obtainOwnedPurchases(ownedPurchasesReq);
+ task.addOnSuccessListener(new OnSuccessListener() {
+ @Override
+ public void onSuccess(OwnedPurchasesResult result) {
+ // 获取接口请求成功的结果
+ Log.e("TAG", "获取接口请求成功的结果");
+ if (result != null && result.getInAppPurchaseDataList() != null) {
+ for (int i = 0; i < result.getInAppPurchaseDataList().size(); i++) {
+ String inAppPurchaseData = result.getInAppPurchaseDataList().get(i);
+
+ Log.e("TAG", "未消耗订单:" + i + "___" + inAppPurchaseData);
+
+ ConsumeOwnedPurchaseReq req = new ConsumeOwnedPurchaseReq();
+ String purchaseToken = "";
+ try {
+ InAppPurchaseData inAppPurchaseDataBean = new InAppPurchaseData(inAppPurchaseData);
+ purchaseToken = inAppPurchaseDataBean.getPurchaseToken();
+ } catch (JSONException e) {
+ }
+ req.setPurchaseToken(purchaseToken);
+ Task task = mClient.consumeOwnedPurchase(req);
+ task.addOnSuccessListener(new OnSuccessListener() {
+ @Override
+ public void onSuccess(ConsumeOwnedPurchaseResult consumeOwnedPurchaseResult) {
+ }
+ }).addOnFailureListener(new OnFailureListener() {
+ @Override
+ public void onFailure(Exception e) {
+ if (e instanceof IapApiException) {
+ IapApiException apiException = (IapApiException) e;
+ Status status = apiException.getStatus();
+ int returnCode = apiException.getStatusCode();
+ }
+ }
+ });
+ }
+ }
+ }
+ }).addOnFailureListener(new OnFailureListener() {
+ @Override
+ public void onFailure(Exception e) {
+ if (e instanceof IapApiException) {
+ IapApiException apiException = (IapApiException) e;
+ Status status = apiException.getStatus();
+ int returnCode = apiException.getStatusCode();
+ } else {
+ // 其他外部错误
+ }
+ }
+ });
+ }
+}
diff --git a/lib_huawei/src/test/java/com/shayu/lib_huawei/ExampleUnitTest.java b/lib_huawei/src/test/java/com/shayu/lib_huawei/ExampleUnitTest.java
new file mode 100644
index 000000000..7e3402cf9
--- /dev/null
+++ b/lib_huawei/src/test/java/com/shayu/lib_huawei/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package com.shayu.lib_huawei;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/live/src/main/AndroidManifest.xml b/live/src/main/AndroidManifest.xml
index 71ec8f14e..dd65fbe2a 100644
--- a/live/src/main/AndroidManifest.xml
+++ b/live/src/main/AndroidManifest.xml
@@ -4,8 +4,11 @@
package="com.yunbao.live">
+
+
+
() {
- @Override
- public void onSuccess(FaceBookUpModel data) {
- if (data.getType().equals("0")) {
- LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile"));
- } else {
- WebViewActivity.forward(EntryActivity.this, data.getLink() + "?",false);
- }
+ MainNetManager.get(EntryActivity.this).FaceBookUp(new com.yunbao.common.http.base.HttpCallback() {
+ @Override
+ public void onSuccess(FaceBookUpModel data) {
+ if (data.getType().equals("0")) {
+ LoginManager.getInstance().logInWithReadPermissions(EntryActivity.this, Arrays.asList("public_profile"));
+ } else {
+ WebViewActivity.forward(EntryActivity.this, data.getLink() + "?", false);
+ }
- }
+ }
- @Override
- public void onError(String error) {
- ToastUtil.show(WordUtil.isNewZh()?"抱歉!出錯了!":"i \\'m sorry! An error occurred");
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(WordUtil.isNewZh() ? "抱歉!出錯了!" : "i \\'m sorry! An error occurred");
- }
- });
+ }
+ });
}
});
@@ -300,7 +299,6 @@ public class EntryActivity extends AppCompatActivity {
}
});
- googleLoginSet();
twitterLoginSet();
btn_google.setOnClickListener(new View.OnClickListener() {
@@ -310,8 +308,7 @@ public class EntryActivity extends AppCompatActivity {
return;
}
timerOutBtn(v);
- Intent signInIntent = mGoogleSignInClient.getSignInIntent();
- startActivityForResult(signInIntent, 1002);
+ startActivityForResult(googleUtils.getIntent(), 1002);
}
});
@@ -365,13 +362,9 @@ public class EntryActivity extends AppCompatActivity {
timerOutBtn(view);
try {
// App-to-app login
- Intent loginIntent = LineLoginApi.getLoginIntent(
- view.getContext(),
- "1656399535",
- new LineAuthenticationParams.Builder()
- .scopes(Arrays.asList(Scope.PROFILE))
- // .nonce("") // nonce can be used to improve security
- .build());
+ Intent loginIntent = LineLoginApi.getLoginIntent(view.getContext(), "1656399535", new LineAuthenticationParams.Builder().scopes(Arrays.asList(Scope.PROFILE))
+ // .nonce("") // nonce can be used to improve security
+ .build());
startActivityForResult(loginIntent, 1001);
} catch (Exception e) {
Log.e("ERROR", e.toString());
@@ -388,7 +381,7 @@ public class EntryActivity extends AppCompatActivity {
public void onClick(View v) {
if (!"".equals(kefuUrl)) {
Constants.LoginKefu = true;
- WebViewActivity.forward(EntryActivity.this, kefuUrl,false);
+ WebViewActivity.forward(EntryActivity.this, kefuUrl, false);
}
}
});
@@ -408,26 +401,10 @@ public class EntryActivity extends AppCompatActivity {
}
private void twitterLoginSet() {
- TwitterConfig config = new TwitterConfig.Builder(this)
- .logger(new DefaultLogger(Log.DEBUG))
- .twitterAuthConfig(new TwitterAuthConfig(getResources().getString(R.string.twitter_key), getResources().getString(R.string.twitter_secret)))
- .debug(true)
- .build();
+ TwitterConfig config = new TwitterConfig.Builder(this).logger(new DefaultLogger(Log.DEBUG)).twitterAuthConfig(new TwitterAuthConfig(getResources().getString(R.string.twitter_key), getResources().getString(R.string.twitter_secret))).debug(true).build();
Twitter.initialize(config);
}
- private void googleLoginSet() {
- //TODO Google登录
- //配置登录以请求用户的ID,电子邮件地址和基本配置文件.ID和基本配置文件包含在DEFAULT_SIGN_IN中.
- GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
- .requestEmail()
-// .requestIdToken("AIzaSyDVnuGnQzjI_vDrxh20Hv_S1OMUD7Vp3zU")
- .build();
- //使用gso指定的选项构建一个GoogleSignInClient.
- mGoogleSignInClient = GoogleSignIn.getClient(this, gso);
-
- }
-
private void requestPermission() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {//30
// 先判断有没有权限
@@ -481,8 +458,7 @@ public class EntryActivity extends AppCompatActivity {
}
} else if (requestCode == 1002) {//google登录
- Task task = GoogleSignIn.getSignedInAccountFromIntent(data);
- handleSignInResult(task);
+ handleSignInResult(data);
} else {
tt_login_button.onActivityResult(requestCode, resultCode, data);//twitter登录回调
callbackManager.onActivityResult(requestCode, resultCode, data);//facebook登录回调
@@ -491,22 +467,16 @@ public class EntryActivity extends AppCompatActivity {
}
- private void handleSignInResult(Task completedTask) {
+ private void handleSignInResult(Intent intent) {
+ org.json.JSONObject jsonObject = googleUtils.getLoginResult(intent);
try {
- GoogleSignInAccount account = completedTask.getResult(ApiException.class);
- //account里可以直接获取到ID,name,和头像
- String idToken = account.getIdToken();
- account.getFamilyName();
- account.getGivenName();
-
LoginData data = new LoginData();
data.setAvatar("");
- data.setNickName(account.getDisplayName());
- data.setOpenID(account.getId());
+ data.setNickName(jsonObject.getString("displayName"));
+ data.setOpenID(jsonObject.getString("openId"));
data.setType("google");
-
loginBuyThird(data);
- } catch (ApiException e) {
+ } catch (JSONException e) {
e.printStackTrace();
Log.i("Log", "ApiException = " + e);
ToastUtil.show(getResources().getString(R.string.user_login_outtime));
@@ -562,7 +532,7 @@ public class EntryActivity extends AppCompatActivity {
Log.d("OpenInstall", "appData.getData()= " + appData.getData());
//获取自定义数据
if (appData.getData() != null && !appData.getData().equals("")) {
- if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2) {
} else {
JSONObject data = JSON.parseObject(appData.getData());
@@ -598,7 +568,7 @@ public class EntryActivity extends AppCompatActivity {
*/
private void loginBuyThird(LoginData data) {
mLoginType = data.getType();
- if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2) {
mPromoCode = "";
}
MainHttpUtil.loginByThird(UserID, data.getOpenID(), mPromoCode, mUuidDevice, data.getNickName(), data.getAvatar(), data.getType(), new HttpCallback() {
@@ -646,33 +616,31 @@ public class EntryActivity extends AppCompatActivity {
public void callback(UserBean bean) {
if (mFirstLogin) {
- if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2) {
EntryActivity.this.startActivity(new Intent(EntryActivity.this, OneLoginActivity.class));
} else {
- HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor")
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (info[0] != null) {
- JSONObject obj = JSON.parseObject(info[0]);
- IMLoginManager.get(EntryActivity.this).setNewUserGif(true);
- IMLoginManager.get(EntryActivity.this).setisNewUserOne(true);
- MainActivity.forward(EntryActivity.this, false);
- gotoLive(obj.getString("anchor_id"));
- if (obj.containsKey("home_zdy_img_us")) {
- home_zdy_img_us = obj.getString("home_zdy_img_us");
- home_zdy_img_cn = obj.getString("home_zdy_img_cn");
- }
- if (obj.containsKey("home_zdy_pop")) {
- NoviceInstructorManager.get(activity).setHomeZdyPop(obj.getString(
- "home_zdy_pop"));
- }
-
- } else {
- MainActivity.forward(EntryActivity.this, false);
- }
+ HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor").execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (info[0] != null) {
+ JSONObject obj = JSON.parseObject(info[0]);
+ IMLoginManager.get(EntryActivity.this).setNewUserGif(true);
+ IMLoginManager.get(EntryActivity.this).setisNewUserOne(true);
+ MainActivity.forward(EntryActivity.this, false);
+ gotoLive(obj.getString("anchor_id"));
+ if (obj.containsKey("home_zdy_img_us")) {
+ home_zdy_img_us = obj.getString("home_zdy_img_us");
+ home_zdy_img_cn = obj.getString("home_zdy_img_cn");
}
- });
+ if (obj.containsKey("home_zdy_pop")) {
+ NoviceInstructorManager.get(activity).setHomeZdyPop(obj.getString("home_zdy_pop"));
+ }
+
+ } else {
+ MainActivity.forward(EntryActivity.this, false);
+ }
+ }
+ });
}
} else {
MainActivity.forward(EntryActivity.this, false);
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 67c8aee39..c26a864c5 100644
--- a/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java
+++ b/main/src/main/java/com/yunbao/main/activity/GoogleFragment.java
@@ -15,27 +15,19 @@ import android.webkit.WebSettings;
import android.webkit.WebView;
import androidx.fragment.app.Fragment;
-import com.android.billingclient.api.Purchase;
+
import com.facebook.appevents.AppEventsConstants;
-import com.google.android.gms.ads.identifier.AdvertisingIdClient;
-import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
-import com.google.android.gms.common.GooglePlayServicesRepairableException;
-import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.http.CommonHttpUtil;
import com.yunbao.common.http.HttpCallback;
-import com.yunbao.common.utils.GoogleBillingUtilNew;
+import com.yunbao.common.utils.GoogleUtils;
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.io.IOException;
-import java.util.List;
-
@SuppressLint("ValidFragment")
public class GoogleFragment extends Fragment {
-
private View view;
public static String mOrderid, mProductId, MoneyUsds;
@@ -43,6 +35,8 @@ public class GoogleFragment extends Fragment {
private String url;
String adid = null;
+ GoogleUtils googleUtils;
+
public GoogleFragment() {
}
@@ -55,33 +49,20 @@ public class GoogleFragment extends Fragment {
assert getArguments() != null;
url = getArguments().getString("url");
-
- if(StringUtil.isEmpty(url)){
- Log.e(TAG, "URL为空" );
+ if (StringUtil.isEmpty(url)) {
+ Log.e(TAG, "URL为空");
return view;
}
rlWebview = (WebView) view.findViewById(R.id.rlWebview);
Log.e("ttt", url);
rlWebview.loadUrl(url);
initGooglePay();
- new Thread(new Runnable() {
+ new Thread() {
+ @Override
public void run() {
- try {
- try {
- adid = AdvertisingIdClient.getAdvertisingIdInfo(getActivity()).getId();
- Log.e("vssss", adid);
- } catch (IOException e) {
- e.printStackTrace();
- } catch (GooglePlayServicesNotAvailableException e) {
- e.printStackTrace();
- } catch (GooglePlayServicesRepairableException e) {
- e.printStackTrace();
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
+ adid = googleUtils.getAdid();
}
- }).start();
+ }.start();
WebSettings webSettings = rlWebview.getSettings();
webSettings.setDomStorageEnabled(true);
@@ -95,7 +76,6 @@ public class GoogleFragment extends Fragment {
webSettings.setSupportZoom(true); // 是否支持缩放
webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
-
rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
@@ -105,71 +85,64 @@ public class GoogleFragment extends Fragment {
return view;
}
-
String TAG = "GooglePay";
private void initGooglePay() {
- GoogleBillingUtilNew.getInstance().initGooglePay(getActivity());
+ googleUtils = new GoogleUtils(getActivity());
+ googleUtils.initGooglePay();
}
-
private Handler payHandler = new Handler();
//js调用原生
public class JsInteration {
-
@JavascriptInterface
public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
Log.e(TAG, "ProductId" + ProductId + "OrderNumber" + OrderNumber + "MoneyUsd" + MoneyUsd);
mProductId = ProductId;
mOrderid = OrderNumber;
MoneyUsds = MoneyUsd;
-// googleBillingUtil.purchaseInApp(getActivity(), mProductId);
- GoogleBillingUtilNew.getInstance().setBillingListener(new GoogleBillingUtilNew.GoogleBillingListener() {
+
+ googleUtils.setBillingListener(new GoogleUtils.GoogleBillingListener() {
@Override
- public void onPaySuccess(List list) {
- for (Purchase purchase : list) {
- for (int i = 0; i < list.size(); i++) {
- int finalI = i;
- payHandler.post(new Runnable() {
+ public void onPaySuccess(String token, String orderId) {
+ payHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ CommonHttpUtil.notifyGoogle(token, orderId, mProductId, mOrderid, adid, new HttpCallback() {
@Override
- public void run() {
- CommonHttpUtil.notifyGoogle(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), mProductId, mOrderid, adid, 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();
- ToastUtil.show("支付成功");
- }
- }
- });
+ 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();
+ ToastUtil.show("支付成功");
+ }
}
});
}
- Log.e("谷歌支付", purchase.toString());
- }
+ });
}
@Override
- public void onPayFailed(int code, String msg) {
-
+ public void onPayFailed(String msg) {
+ ToastUtil.show(msg);
}
- }).checkSku(ProductId);
+ });
+ googleUtils.purchase(mProductId);
}
@JavascriptInterface
diff --git a/main/src/main/java/com/yunbao/main/activity/HuaWeiFragment.java b/main/src/main/java/com/yunbao/main/activity/HuaWeiFragment.java
new file mode 100644
index 000000000..2389daf56
--- /dev/null
+++ b/main/src/main/java/com/yunbao/main/activity/HuaWeiFragment.java
@@ -0,0 +1,111 @@
+package com.yunbao.main.activity;
+
+
+import static com.yunbao.main.activity.MyWalletActivity.orderId;
+
+import android.annotation.SuppressLint;
+import android.os.Bundle;
+import android.util.Log;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.webkit.JavascriptInterface;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+
+import androidx.fragment.app.Fragment;
+
+import com.yunbao.common.pay.hw.HwBuilder;
+import com.yunbao.common.utils.StringUtil;
+import com.yunbao.main.R;
+import com.yunbao.main.views.TestWebViewClient;
+
+
+@SuppressLint("ValidFragment")
+public class HuaWeiFragment extends Fragment {
+
+ private View view;
+ public static String mOrderid, mProductId, MoneyUsds;
+
+ private WebView rlWebview;
+ private String url;
+ String adid = null;
+
+ public HuaWeiFragment() {
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
+ //通过参数中的布局填充获取对应布局
+ view = inflater.inflate(R.layout.activity_recharge, container, false);
+
+ assert getArguments() != null;
+ url = getArguments().getString("url");
+
+ if (StringUtil.isEmpty(url)) {
+ Log.e(TAG, "URL为空");
+ return view;
+ }
+ rlWebview = (WebView) view.findViewById(R.id.rlWebview);
+ Log.e("ttt", url);
+ rlWebview.loadUrl(url);
+ WebSettings webSettings = rlWebview.getSettings();
+
+ webSettings.setDomStorageEnabled(true);
+ webSettings.setTextZoom(100);
+ webSettings.setUseWideViewPort(true);
+
+ webSettings.setJavaScriptEnabled(true); // 是否开启JS支持
+ webSettings.setJavaScriptCanOpenWindowsAutomatically(true); // 是否允许JS打开新窗口
+
+ webSettings.setLoadWithOverviewMode(true); // 缩放至屏幕大小
+ webSettings.setSupportZoom(true); // 是否支持缩放
+ webSettings.setBuiltInZoomControls(true); // 是否支持缩放变焦,前提是支持缩放
+
+ rlWebview.addJavascriptInterface(new JsInteration(), "androidObject");
+
+ TestWebViewClient testWebViewClient = new TestWebViewClient(getActivity(), rlWebview);
+
+ rlWebview.setWebViewClient(testWebViewClient);
+
+ return view;
+ }
+
+ String TAG = "HuaWeiPay";
+
+ //js调用原生
+ public class JsInteration {
+
+ @JavascriptInterface
+ public void androidNewGoToGooglePay(String ProductId, String OrderNumber, String MoneyUsd) {
+ Log.e(TAG, "ProductId:" + ProductId + " OrderNumber:" + OrderNumber + " MoneyUsd:" + MoneyUsd);
+
+ if (ProductId.equals("zs640")) {
+ ProductId = "zs0640";
+ }
+
+ mProductId = ProductId;
+ mOrderid = OrderNumber;
+ MoneyUsds = MoneyUsd;
+ orderId = OrderNumber;
+
+ HwBuilder hwBuilder = new HwBuilder(getActivity());
+ hwBuilder.pay(mProductId);
+ }
+
+ @JavascriptInterface
+ public void androidMethodBack() {
+ getActivity().onBackPressed();
+ }
+
+ @JavascriptInterface
+ public void androidGoBack() {
+ getActivity().onBackPressed();
+ }
+ }
+
+ public void release() {
+
+ }
+}
+
diff --git a/main/src/main/java/com/yunbao/main/activity/MainActivity.java b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
index e8ad1b9e5..fcb9d866d 100644
--- a/main/src/main/java/com/yunbao/main/activity/MainActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/MainActivity.java
@@ -93,6 +93,8 @@ import com.yunbao.common.manager.imrongcloud.RongcloudIMManager;
import com.yunbao.common.utils.DialogUitl;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.GiftCacheUtil;
+import com.yunbao.common.utils.GoogleUtils;
+import com.yunbao.common.utils.L;
import com.yunbao.common.utils.LiveRoomCheckLivePresenter;
import com.yunbao.common.utils.LocationUtil;
import com.yunbao.common.utils.ProcessResultUtil;
@@ -291,25 +293,17 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
} else if (getIntent().getStringExtra("type") != null && getIntent().getStringExtra("type").equals("8")) {
WebViewActivity.forward(mContext, getIntent().getStringExtra("activityUrl"), true, false);
}
- FirebaseMessaging.getInstance().getToken()
- .addOnCompleteListener(new OnCompleteListener() {
- @Override
- public void onComplete(@NonNull Task task) {
- if (!task.isSuccessful()) {
- Log.w(TAG, "Fetching FCM registration token failed", task.getException());
- return;
- }
- // Get new FCM registration token
- String token = task.getResult();
-
- // Log and toast
- Log.d(TAG, token);
- PushManager.getInstance()
- .onReceiveToken(MainActivity.this, PushType.GOOGLE_FCM, token);
-// Toast.makeText(MainActivity.this, token, Toast.LENGTH_SHORT).show();
- }
- });
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ GoogleUtils.newInstance(MainActivity.this).setFirebaseTokenListener(MainActivity.this, new GoogleUtils.FirebaseTokenListener() {
+ @Override
+ public void onResultToken(String token) {
+ L.e("GoogleUtils.newInstance:onResultToken:" + token);
+ PushManager.getInstance().onReceiveToken(MainActivity.this, PushType.GOOGLE_FCM, token);
+ }
+ });
+ GoogleUtils.newInstance(MainActivity.this).initFireToken(MainActivity.this);
+ }
//华为推送
// getToken();
@@ -460,51 +454,49 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
return null;
}
});
- RxView.clicks(findViewById(R.id.banner_click))
- .throttleFirst(2, TimeUnit.SECONDS)
- .subscribe(new Observer() {
+ RxView.clicks(findViewById(R.id.banner_click)).throttleFirst(2, TimeUnit.SECONDS).subscribe(new Observer() {
+ @Override
+ public void onSubscribe(Disposable d) {
+
+ }
+
+ @Override
+ public void onNext(Unit unit) {
+ MobclickAgent.onEvent(mContext, "home_page_to_recommend", "首页点击右下角去推荐直播间按钮");
+ String Uid = floatBanner.getUid();
+ LiveHttpUtil.getLiveInfo(Uid + "", new HttpCallback() {
@Override
- public void onSubscribe(Disposable d) {
-
- }
-
- @Override
- public void onNext(Unit unit) {
- MobclickAgent.onEvent(mContext, "home_page_to_recommend", "首页点击右下角去推荐直播间按钮");
- String Uid = floatBanner.getUid();
- LiveHttpUtil.getLiveInfo(Uid + "", new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (code == 0 && info.length > 0) {
- LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
- new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
- @Override
- public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
- RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
- }
-
- @Override
- public void onCheckError(String contextError) {
-
- }
- });
- } else {
- RouteUtil.forwardUserHome(mContext, Uid, 0);
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0 && info.length > 0) {
+ LiveBean liveBean = JSON.parseObject(info[0], LiveBean.class);
+ new LiveRoomCheckLivePresenter(mContext, liveBean.getUid(), liveBean.getStream(), new LiveRoomCheckLivePresenter.NewActionListener() {
+ @Override
+ public void onLiveRoomChanged(String liveUid, String stream, int liveType, String liveTypeVal, String liveSdk) {
+ RouteUtil.forwardLiveAudienceActivity(liveBean, liveType, Integer.parseInt(liveSdk), Integer.parseInt(liveTypeVal));
}
- }
- });
- }
- @Override
- public void onError(Throwable e) {
-
- }
-
- @Override
- public void onComplete() {
+ @Override
+ public void onCheckError(String contextError) {
+ }
+ });
+ } else {
+ RouteUtil.forwardUserHome(mContext, Uid, 0);
+ }
}
});
+ }
+
+ @Override
+ public void onError(Throwable e) {
+
+ }
+
+ @Override
+ public void onComplete() {
+
+ }
+ });
//选中监听
mTabButtonGroup.addTabButtonGroupChangeListener((view, index) -> {
@@ -517,8 +509,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
floatRedPacket.setVisibility(View.GONE);
findViewById(R.id.banner_click).setVisibility(View.GONE);
isfloatBannernet = false;
- if (mainMessageViewHolder != null)
- mainMessageViewHolder.onResume();
+ if (mainMessageViewHolder != null) mainMessageViewHolder.onResume();
} else {
floatBanner.setVisibility(View.GONE);
floatRedPacket.setVisibility(View.GONE);
@@ -592,37 +583,36 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
Map map = new HashMap<>();
map.put("num", "10");
map.put("live_recommend", "quick_look");
- MainNetManager.get(mContext)
- .anchorRecommend(map, new com.yunbao.common.http.base.HttpCallback() {
- @SuppressLint("SetTextI18n")
- @Override
- public void onSuccess(AnchorRecommendModel data) {
- if (isFinishing()) return;
- if (data.getListShow() == 1 && data.getList().size() > 2) {
- floatBanner.setVisibility(View.VISIBLE);
- findViewById(R.id.banner_click).setVisibility(View.VISIBLE);
- floatBanner.showBanner(data.getList());
- } else {
- floatBanner.setVisibility(View.GONE);
- findViewById(R.id.banner_click).setVisibility(View.GONE);
- }
- if (data.getShowRedPacket() == 0) {
- floatRedPacket.setVisibility(View.GONE);
- } else {
- floatRedPacket.setVisibility(View.VISIBLE);
- ((ProgressBar) floatRedPacket.findViewById(R.id.progress)).setMax(data.getRedPacketTotal());
- ((ProgressBar) floatRedPacket.findViewById(R.id.progress)).setProgress(data.getRedPacketNum());
- ((TextView) floatRedPacket.findViewById(R.id.progressText)).setText(data.getRedPacketNum() + "/" + data.getRedPacketTotal());
- }
+ MainNetManager.get(mContext).anchorRecommend(map, new com.yunbao.common.http.base.HttpCallback() {
+ @SuppressLint("SetTextI18n")
+ @Override
+ public void onSuccess(AnchorRecommendModel data) {
+ if (isFinishing()) return;
+ if (data.getListShow() == 1 && data.getList().size() > 2) {
+ floatBanner.setVisibility(View.VISIBLE);
+ findViewById(R.id.banner_click).setVisibility(View.VISIBLE);
+ floatBanner.showBanner(data.getList());
+ } else {
+ floatBanner.setVisibility(View.GONE);
+ findViewById(R.id.banner_click).setVisibility(View.GONE);
+ }
+ if (data.getShowRedPacket() == 0) {
+ floatRedPacket.setVisibility(View.GONE);
+ } else {
+ floatRedPacket.setVisibility(View.VISIBLE);
+ ((ProgressBar) floatRedPacket.findViewById(R.id.progress)).setMax(data.getRedPacketTotal());
+ ((ProgressBar) floatRedPacket.findViewById(R.id.progress)).setProgress(data.getRedPacketNum());
+ ((TextView) floatRedPacket.findViewById(R.id.progressText)).setText(data.getRedPacketNum() + "/" + data.getRedPacketTotal());
+ }
- }
+ }
- @Override
- public void onError(String error) {
- ToastUtil.show(mContext.getString(R.string.net_error));
- }
- });
+ @Override
+ public void onError(String error) {
+ ToastUtil.show(mContext.getString(R.string.net_error));
+ }
+ });
}
@@ -778,12 +768,9 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
}
if (!VersionUtil.isLatest(configBean.getVersion())) {
if (!APKManager.get().getApkVerNew()) {
- new XPopup.Builder(mContext)
- .isDestroyOnDismiss(true)
- .dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true
+ new XPopup.Builder(mContext).isDestroyOnDismiss(true).dismissOnBackPressed(false) // 按返回键是否关闭弹窗,默认为true
.dismissOnTouchOutside(false) // 点击外部是否关闭弹窗,默认为true
- .asCustom(new APKUpdateCustomPopup(mContext, false))
- .show();
+ .asCustom(new APKUpdateCustomPopup(mContext, false)).show();
}
} else {
requestBonus();
@@ -1087,14 +1074,12 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
private void notifyLiveFlot() {
if (startListNotifyList.iterator().hasNext()) {
AnchorStartLiveBean bean = startListNotifyList.iterator().next();
- new AnchorStartLiveNotifyDialog(mContext, bean)
- .setOnDismissListener(dialog -> {
- startListNotifyList.remove(bean);
- if (startListNotifyList.iterator().hasNext()) {
- notifyLiveFlot();
- }
- })
- .showDialog();
+ new AnchorStartLiveNotifyDialog(mContext, bean).setOnDismissListener(dialog -> {
+ startListNotifyList.remove(bean);
+ if (startListNotifyList.iterator().hasNext()) {
+ notifyLiveFlot();
+ }
+ }).showDialog();
}
}
@@ -1448,9 +1433,7 @@ public class MainActivity extends AbsActivity implements MainAppBarLayoutListene
@Subscribe(threadMode = ThreadMode.MAIN)
public void onLiveFloatEvent(LiveFloatEvent event) {
if (event != null && event.getmLiveBean() != null && !TextUtils.isEmpty(event.getmLiveBean().getPull())) {
- new Handler().post(() -> LiveFloatView.getInstance()
- .cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal())
- .builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
+ new Handler().post(() -> LiveFloatView.getInstance().cacheLiveData(event.getmLiveBean(), event.getmLiveType(), event.getmLiveSDK(), event.getmLiveTypeVal()).builderFloat(mContext, event.getmLiveBean().getPull(), LiveAudienceActivity.class));
}
}
diff --git a/main/src/main/java/com/yunbao/main/activity/MyCoinActivity.java b/main/src/main/java/com/yunbao/main/activity/MyCoinActivity.java
index d9b791298..3038d2970 100644
--- a/main/src/main/java/com/yunbao/main/activity/MyCoinActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/MyCoinActivity.java
@@ -2,9 +2,11 @@ package com.yunbao.main.activity;
import android.content.Intent;
import android.net.Uri;
+
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
+
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;
@@ -62,6 +64,7 @@ public class MyCoinActivity extends AbsActivity implements OnItemClickListener listPro;//商品列表
+
@Override
protected int getLayoutId() {
return R.layout.activity_coin;
@@ -105,10 +108,10 @@ public class MyCoinActivity extends AbsActivity implements OnItemClickListener payList = JSON.parseArray(obj.getString("paylist"), CoinPayBean.class);
if (mPayAdapter != null) {
mPayAdapter.setList(payList);
}
//商品列表
- listPro = JSON.parseArray(obj.getString("rules"), CoinBean.class);
+ listPro = JSON.parseArray(obj.getString("rules"), CoinBean.class);
if (mAdapter != null) {
mAdapter.setList(listPro);
}
- if (payList != null && payList.size()>0){
- if ("google".equals(payList.get(0).getId()) && payList.get(0).isChecked()){
+ if (payList != null && payList.size() > 0) {
+ if ("google".equals(payList.get(0).getId()) && payList.get(0).isChecked()) {
EventBus.getDefault().post(payList.get(0));
}
}
- if (mPayPresenter != null){
+ if (mPayPresenter != null) {
mPayPresenter.setBalanceValue(mBalanceValue);
mPayPresenter.setAliPartner(obj.getString("aliapp_partner"));
mPayPresenter.setAliSellerId(obj.getString("aliapp_seller_id"));
@@ -223,10 +229,7 @@ public class MyCoinActivity extends AbsActivity implements OnItemClickListener listTmp=listPro.subList(0,indexTmp);
- mAdapter.setList(listTmp);
- }
- }
+ if ("google".equals(bean.getId())) {
+ String numS = bean.getPriceNum();
+ int num = 7;
+ if (numS != null && !numS.isEmpty()) {
+ try {
+ num = Integer.parseInt(bean.getPriceNum());
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ indexTmp = num;
+ } else {
+ indexTmp = size;
+ }
+ if (indexTmp <= size) {
+ List listTmp = listPro.subList(0, indexTmp);
+ mAdapter.setList(listTmp);
+ }
+ }
}
@@ -297,16 +302,14 @@ public class MyCoinActivity extends AbsActivity implements OnItemClickListener list) {
- if (list.size() == 0) {
- loadingDialog.setShowText(getString(R.string.order_query_success));
- payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000);
- } else {
- loadingDialog.setShowText(getString(R.string.order_query));
- //消费订单
- GoogleBillingUtilNew.getInstance().consume(list);
- for (int i = 0; i < list.size(); i++) {
- int finalI = i;
- payHandler.post(new Runnable() {
- @Override
- public void run() {
- //谷歌掉单处理
- CommonHttpUtil
- .Google_sec_pay(list.get(finalI).getPurchaseToken(),
- list.get(finalI).getOrderId(),
- list.get(finalI).getProducts().get(0),
- new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (finalI == list.size() - 1) {
- loadingDialog.setShowText(getString(R.string.order_query_success));
- loadingDialog.dismiss();
- }
- ToastUtil.show("充值已到账");
- finish();
- }
- });
- }
- });
- }
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ GoogleBillingUtilNew.getInstance().queryPurchasesAsync(new PurchasesResponseListener() {
+ @Override
+ public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List list) {
+ if (list.size() == 0) {
+ loadingDialog.setShowText(getString(R.string.order_query_success));
+ payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000);
+ } else {
+ loadingDialog.setShowText(getString(R.string.order_query));
+ //消费订单
+ GoogleBillingUtilNew.getInstance().consume(list);
+ for (int i = 0; i < list.size(); i++) {
+ int finalI = i;
+ payHandler.post(new Runnable() {
+ @Override
+ public void run() {
+ //谷歌掉单处理
+ CommonHttpUtil.Google_sec_pay(list.get(finalI).getPurchaseToken(), list.get(finalI).getOrderId(), list.get(finalI).getProducts().get(0), new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (finalI == list.size() - 1) {
+ loadingDialog.setShowText(getString(R.string.order_query_success));
+ loadingDialog.dismiss();
+ }
+ ToastUtil.show("充值已到账");
+ finish();
+ }
+ });
+ }
+ });
+ }
+
+ }
}
- }
- });
+ });
+ } else {
+ hwBuilder.consume();
+ loadingDialog.setShowText(getString(R.string.order_query_success));
+ payHandler.postDelayed(() -> loadingDialog.dismiss(), 2000);
+ }
});
- WalletFragment walletFragment;
- GoogleFragment googleFragment1;
- GoogleFragment googleFragment2;
+ WalletFragment walletFragment = null;
+
+ GoogleFragment googleFragment1 = null;
+ GoogleFragment googleFragment2 = null;
+
+ HuaWeiFragment huaWeiFragment1 = null;
+ HuaWeiFragment huaWeiFragment2 = null;
final String[] titles = {mContext.getString(R.string.diamond), mContext.getString(R.string.coins), mContext.getString(R.string.golden_beans)};
if (getIntent().getStringExtra("tag") != null) {
Log.i("tss", "首充");
- if (CommonAppConfig.IS_GOOGLE_PLAY == false) {
- 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) {
+ //google
rView.setVisibility(View.VISIBLE);
walletFragment = new WalletFragment();
Bundle bundle = new Bundle();
@@ -153,9 +161,75 @@ public class MyWalletActivity extends AbsActivity {
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 {
+ 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 == false) {
+ 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 {
Log.i("tss", "不是首充");
//链接版本
@@ -173,30 +247,16 @@ public class MyWalletActivity extends AbsActivity {
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);
-
- } else {
- 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);
}
}
- fragments = new Fragment[]{googleFragment1,
- googleFragment2,
- 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 {
+ fragments = new Fragment[]{googleFragment1, googleFragment2, walletFragment};
+ }
MagicIndicator magicIndicator = (MagicIndicator) findViewById(R.id.magic_indicator);
CommonNavigator commonNavigator = new CommonNavigator(this);
@@ -266,10 +326,69 @@ public class MyWalletActivity extends AbsActivity {
magicIndicator.onPageSelected(getIntent().getIntExtra("p", 0));
vp_content.setCurrentItem(getIntent().getIntExtra("p", 0));
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ if (hwBuilder != null) {
+ hwBuilder.consume();
+ }
+ }
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == 6666) {
+ if (data == null) {
+ Log.e("TAG", "onActivityResult__data is null");
+ return;
+ }
+
+ JSONObject object = hwBuilder.getPayResult(data);
+
+ int code;
+ String inAppPurchaseData;
+ String inAppPurchaseDataSignature;
+ try {
+ code = object.getInt("code");
+ Log.e("TAG", "code:" + code);
+
+ if (hwBuilder != null) {
+ hwBuilder.consume();
+ }
+
+ switch (code) {
+ case 60000:
+ ToastUtil.show("支付取消");
+ break;
+ case -1:
+ case 60051:
+ ToastUtil.show("支付失败");
+ break;
+ case 0:
+ ToastUtil.show("支付成功");
+ inAppPurchaseData = object.getString("inAppPurchaseData");
+ inAppPurchaseDataSignature = object.getString("inAppPurchaseDataSignature");
+ MainHttpUtil.hwNotify(inAppPurchaseData, inAppPurchaseDataSignature, orderId, new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (code == 0) {
+ finish();
+ }
+ }
+ });
+ break;
+ default:
+ break;
+ }
+
+
+ } catch (JSONException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
}
public static void dis() {
mw.finish();
}
-
}
diff --git a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java
index 134c67bd4..a3ab023d3 100644
--- a/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/PDLiveConversationListActivity.java
@@ -25,7 +25,6 @@ import com.alibaba.fastjson.JSON;
import com.binioter.guideview.Guide;
import com.binioter.guideview.GuideBuilder;
import com.facebook.appevents.AppEventsLogger;
-import com.google.firebase.analytics.FirebaseAnalytics;
import com.lzf.easyfloat.EasyFloat;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
@@ -322,7 +321,6 @@ public class PDLiveConversationListActivity extends AbsActivity implements View.
ViewClicksAntiShake.clicksAntiShake(imgNewsOnline, () -> {
type = userBean.getType();
netHandler.post(systemNumberRunnable);
- FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null);
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
if (userBean.getLink() != null && !"".equals(userBean.getLink())) {
WebViewActivity.forward(mContext, userBean.getLink(),false);
diff --git a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java
index d87682a44..3794d8206 100644
--- a/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java
+++ b/main/src/main/java/com/yunbao/main/activity/RegisterActivity.java
@@ -123,8 +123,8 @@ public class RegisterActivity extends AbsActivity {
getUuidDevice();
getPromoCode();
- mGetCode =mContext.getString(R.string.reg_get_code);
- mGetCodeAgain =mContext.getString(R.string.reg_get_code_again);
+ mGetCode = mContext.getString(R.string.reg_get_code);
+ mGetCodeAgain = mContext.getString(R.string.reg_get_code_again);
mTvCountryCodeClick();
mEditPhone.addTextChangedListener(new TextWatcher() {
@Override
@@ -240,7 +240,7 @@ public class RegisterActivity extends AbsActivity {
webSettings.setJavaScriptEnabled(true);
webview.addJavascriptInterface(new JsBridge(), "jsBridge");
// 也可以加载本地html(webView.loadUrl("file:///android_asset/xxx.html"))
- webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html"+ "?isZh=" + (WordUtil.isNewZh() ? "1" : 0));
+ webview.loadUrl(CommonAppConfig.HOST + "/h5/live/TCaptcha.html" + "?isZh=" + (WordUtil.isNewZh() ? "1" : 0));
}
@@ -282,9 +282,9 @@ public class RegisterActivity extends AbsActivity {
} else if (i == R.id.btn_register) {
register();
} else if (i == R.id.btn_tip2) {
- WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
+ WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY1 + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"), false);
} else if (i == R.id.btn_tip3) {
- WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2+ "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"),false);
+ WebViewActivity.forward(mContext, HtmlConfig.REG_PRIVCAY2 + "&isZh=" + (WordUtil.isNewZh() ? "1" : "0"), false);
}
}
@@ -364,12 +364,12 @@ public class RegisterActivity extends AbsActivity {
mDialog.show();
}
String ti = "";
- if (edit_invitecode_2.getText().toString().trim().equals("此設備已註冊")){
+ if (edit_invitecode_2.getText().toString().trim().equals("此設備已註冊")) {
ti = "";
- }else{
+ } else {
ti = edit_invitecode_2.getText().toString().trim();
}
- MainHttpUtil.register(UserID,ti, phoneNum, mPromoCode, mUuidDevice, mCountryCode, pwd, pwd2, code, new HttpCallback() {
+ MainHttpUtil.register(UserID, ti, phoneNum, mPromoCode, mUuidDevice, mCountryCode, pwd, pwd2, code, new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
if (code == 0) {
@@ -404,25 +404,25 @@ public class RegisterActivity extends AbsActivity {
//获取自定义数据
if (appData.getData() != null && !appData.getData().equals("")) {
JSONObject data = JSON.parseObject(appData.getData());
- if (CommonAppConfig.IS_GOOGLE_PLAY == true) {
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1 || CommonAppConfig.IS_GOOGLE_PLAY == 2) {
yqm_view.setVisibility(View.VISIBLE);
MainHttpUtil.getDeviceLoginType(new HttpCallback() {
@Override
public void onSuccess(int code, String msg, String[] info) {
- if(code == 201){
+ if (code == 201) {
edit_invitecode_2.setText("此設備已註冊");
edit_invitecode_2.setEnabled(false);
}
}
});
- }else{
- yqm_view.setVisibility(View.GONE);
- //推广的码
+ } else {
+ yqm_view.setVisibility(View.GONE);
+ //推广的码
mPromoCode = data.getString("admin_id") + "";
//用户的码
UserID = data.getString("user_id") + "";
}
- Log.d("OpenInstall", UserID+"appData.getData()1111= " + mPromoCode);
+ Log.d("OpenInstall", UserID + "appData.getData()1111= " + mPromoCode);
}
}
});
@@ -485,31 +485,28 @@ public class RegisterActivity extends AbsActivity {
@Override
public void run() {
IMLoginModel userInfo = IMLoginManager.get(activity).getUserInfo();
- HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor")
- .params("uid", userInfo.getId())
- .params("token", userInfo.getToken())
- .execute(new HttpCallback() {
- @Override
- public void onSuccess(int code, String msg, String[] info) {
- if (info[0] != null) {
- JSONObject obj = JSON.parseObject(info[0]);
- IMLoginManager.get(activity).setisNewUserOne(true);
- IMLoginManager.get(activity).setNewUserGif(true);
- if (obj.containsKey("home_zdy_img_us")) {
- home_zdy_img_us = obj.getString("home_zdy_img_us");
- home_zdy_img_cn = obj.getString("home_zdy_img_cn");
- }
- gotoLive(obj.getString("anchor_id"));
- if (obj.containsKey("home_zdy_pop")) {
- NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop"));
- }
- jumpMain(false);
- } else {
- jumpMain(false);
- }
- EventBus.getDefault().post(new RegSuccessEvent());
+ HttpClient.getInstance().post("Home.getRandJoinAnchor", "Home.getRandJoinAnchor").params("uid", userInfo.getId()).params("token", userInfo.getToken()).execute(new HttpCallback() {
+ @Override
+ public void onSuccess(int code, String msg, String[] info) {
+ if (info[0] != null) {
+ JSONObject obj = JSON.parseObject(info[0]);
+ IMLoginManager.get(activity).setisNewUserOne(true);
+ IMLoginManager.get(activity).setNewUserGif(true);
+ if (obj.containsKey("home_zdy_img_us")) {
+ home_zdy_img_us = obj.getString("home_zdy_img_us");
+ home_zdy_img_cn = obj.getString("home_zdy_img_cn");
}
- });
+ gotoLive(obj.getString("anchor_id"));
+ if (obj.containsKey("home_zdy_pop")) {
+ NoviceInstructorManager.get(mContext).setHomeZdyPop(obj.getString("home_zdy_pop"));
+ }
+ jumpMain(false);
+ } else {
+ jumpMain(false);
+ }
+ EventBus.getDefault().post(new RegSuccessEvent());
+ }
+ });
}
};
diff --git a/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java b/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java
index 0d9d9d046..6138bf337 100644
--- a/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java
+++ b/main/src/main/java/com/yunbao/main/adapter/SystemMessageAdapter.java
@@ -13,7 +13,6 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.fastjson.JSON;
import com.facebook.appevents.AppEventsLogger;
-import com.google.firebase.analytics.FirebaseAnalytics;
import com.yunbao.common.activity.WebViewActivity;
import com.yunbao.common.bean.ImUserInfoModel;
import com.yunbao.common.glide.ImgLoader;
@@ -86,7 +85,6 @@ public class SystemMessageAdapter extends RecyclerView.Adapter {
type = model1.getType();
netHandler.post(updataRunable);
if (model1.getTitle().equals("在線客服")) {
- FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null);
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
}
if (!TextUtils.isEmpty(model1.getLink())) {
diff --git a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java
index 3ef8191cf..4850c1eb1 100644
--- a/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java
+++ b/main/src/main/java/com/yunbao/main/http/MainHttpUtil.java
@@ -60,10 +60,16 @@ public class MainHttpUtil {
*/
public static void loginByThird(String openid, String nicename, String avatar, String type, HttpCallback callback) {
String sign = MD5Util.getMD5("openid=" + openid + "&" + SALT);
+ String appSource = "3";
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ appSource = "1";
+ } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ appSource = "2";
+ }
HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
.params("openid", openid)
.params("nicename", nicename)
- .params("app_source", CommonAppConfig.IS_GOOGLE_PLAY == true ? "1" : "3")
+ .params("app_source", appSource)
.params("avatar", avatar)
.params("type", type)
.params("source", DEVICE)
@@ -80,9 +86,15 @@ public class MainHttpUtil {
public static void loginByThird(String UserID, String openid, String promoCode, String uuidDevice, String nicename, String avatar, String type, HttpCallback callback) {
String sign = MD5Util.getMD5("openid=" + openid + "&" + SALT);
+ String appSource = "3";
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ appSource = "1";
+ } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ appSource = "2";
+ }
HttpClient.getInstance().get("Login.userLoginByThird", MainHttpConsts.LOGIN_BY_THIRD)
.params("openid", openid)
- .params("app_source", CommonAppConfig.IS_GOOGLE_PLAY == true ? "1" : "3")
+ .params("app_source", appSource)
.params("admin_id", promoCode)
.params("uuid_Device", uuidDevice)
.params("nicename", nicename)
@@ -93,7 +105,7 @@ public class MainHttpUtil {
.params("sign", sign)
.params("lastlogindevice", "Android")
.params("pushid", "")
- .params("langue", WordUtil.isNewZh()?"chinese":"english")
+ .params("langue", WordUtil.isNewZh() ? "chinese" : "english")
.execute(callback);
}
@@ -574,9 +586,15 @@ public class MainHttpUtil {
* 手机注册接口---增加参数:推广码,手机唯一标识,国家代码
*/
public static void register(String UserID, String invitecode, String user_login, String promo_code, String uuidDevice, int countryCode, String pass, String pass2, String code, HttpCallback callback) {
+ String appSource = "3";
+ if (CommonAppConfig.IS_GOOGLE_PLAY == 1) {
+ appSource = "1";
+ } else if (CommonAppConfig.IS_GOOGLE_PLAY == 2) {
+ appSource = "2";
+ }
HttpClient.getInstance().get("Login.userReg", MainHttpConsts.REGISTER)
.params("user_login", user_login)
- .params("app_source", CommonAppConfig.IS_GOOGLE_PLAY == true ? "1" : "3")
+ .params("app_source", appSource)
//增加参数:推广码
.params("user_activation_key", promo_code)
.params("admin_id", promo_code)
@@ -590,7 +608,7 @@ public class MainHttpUtil {
.params("code", code)
.params("source", DEVICE)
.params("invitation_code", invitecode)
- .params("langue", WordUtil.isNewZh()?"chinese":"english")
+ .params("langue", WordUtil.isNewZh() ? "chinese" : "english")
.execute(callback);
}
@@ -740,6 +758,18 @@ public class MainHttpUtil {
.execute(callback);
}
+
+ /**
+ * 订单通知
+ */
+ public static void hwNotify(String InAppPurchaseData, String Signature, String orderId, HttpCallback callback) {
+ HttpClient.getInstance().get("Charge.HuaweiNotify", "Charge.HuaweiNotify")
+ .params("InAppPurchaseData", InAppPurchaseData)
+ .params("InAppDataSignature", Signature)
+ .params("SelfOrderId", orderId)
+ .params("PackageName", "pd")
+ .execute(callback);
+ }
}
diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java
index ee21d8e91..2dbebab5f 100644
--- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java
+++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java
@@ -20,7 +20,6 @@ import com.alibaba.fastjson.JSON;
import com.binioter.guideview.Guide;
import com.binioter.guideview.GuideBuilder;
import com.facebook.appevents.AppEventsLogger;
-import com.google.firebase.analytics.FirebaseAnalytics;
import com.opensource.svgaplayer.SVGADrawable;
import com.opensource.svgaplayer.SVGAImageView;
import com.opensource.svgaplayer.SVGAParser;
@@ -277,7 +276,6 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
MobclickAgent.onEvent(mContext, "information_system_service", "在線客服");
type = userBean.getType();
netHandler.post(systemNumberRunnable);
- FirebaseAnalytics.getInstance(mContext).logEvent("FS_customer_service", null);
AppEventsLogger.newLogger(mContext).logEvent("FB_customer_service");
if (userBean.getLink() != null && !"".equals(userBean.getLink())) {
// WebViewActivity.forward(mContext, userBean.getLink());
diff --git a/settings.gradle b/settings.gradle
index aec525cd0..e5940e07f 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1,6 +1,8 @@
-include ':app', ':video', ':common', ':main', ':live', ':lib_country_code'
+include ':app', ':video', ':common', ':main', ':live', ':lib_country_code'
include ':FaceUnity'
//include ':baidu'
//include ':recognizer'//融云语音转文字模块
include ':Share'
include ':pluginsForAnchor'
+include ':lib_huawei'
+include ':lib_google'