Commit 3a08adeb authored by jyx's avatar jyx

代码优化

parent 91df8be0
/build
mapping.txt
seeds.txt
unused.txt
priguardMapping.txt
plugins {
id 'com.android.library'
id 'kotlin-android'
}
android {
compileSdk 31
defaultConfig {
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
// implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
implementation fileTree(dir: 'libs', include: ['*.jar'])
api 'com.alipay.sdk:alipaysdk-android:+@aar'
implementation 'androidx.core:core-ktx:1.3.2'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.3.0'
compileOnly project(":rxpay")
}
\ No newline at end of file
# 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
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.jobo.alipay">
</manifest>
\ No newline at end of file
/*
******************************* Copyright (c)*********************************\
**
** (c) Copyright 2017, King, china
** All Rights Reserved
**
** By(King)
**
**------------------------------------------------------------------------------
*/
package com.jobo.alipay;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import com.alipay.sdk.app.PayTask;
import com.jobo.rxpay.base.IPayStrategy;
import com.jobo.rxpay.callback.IPayCallback;
import java.util.Map;
/**
* @Desc:
* @author: admin wsj
* @Date: 2021/12/28 2:34 下午
* @see <a href="https://docs.open.alipay.com/204/">Des</a>
*/
public class AliPay implements IPayStrategy<AlipayInfoImpl> {
private static final int SDK_PAY_FLAG = 6406;
private Activity mActivity;
private AlipayInfoImpl alipayInfoImpli;
private static IPayCallback sPayCallback;
@Override
public void pay(Activity activity, AlipayInfoImpl payInfo, IPayCallback payCallback) {
this.mActivity = activity;
this.alipayInfoImpli = payInfo;
sPayCallback = payCallback;
Runnable payRunnable = new Runnable() {
@Override
public void run() {
// 构造PayTask 对象
PayTask alipay = new PayTask(mActivity);
// 调用支付接口,获取支付结果
Map<String,String> result = alipay.payV2(alipayInfoImpli.getOrderInfo(),true);
Message msg = new Message();
msg.what = SDK_PAY_FLAG;
msg.obj = result;
mHandler.sendMessage(msg);
}
};
// 必须异步调用
Thread payThread = new Thread(payRunnable);
payThread.start();
}
@SuppressLint("HandlerLeak")
private static Handler mHandler = new Handler() {
@SuppressWarnings("unused")
@Override
public void handleMessage(Message msg) {
switch (msg.what) {
case SDK_PAY_FLAG: {
AliPayResult payResult = new AliPayResult((Map<String, String>) msg.obj);
/**
* 同步返回的结果必须放置到服务端进行验证(验证的规则请看https://doc.open.alipay.com/doc2/
* detail.htm?spm=0.0.0.0.xdvAU6&treeId=59&articleId=103665&
* docType=1) 建议商户依赖异步通知
*/
String resultInfo = payResult.getResult();// 同步返回需要验证的信息
String resultStatus = payResult.getResultStatus();
// 判断resultStatus 为“9000”则代表支付成功,具体状态码代表含义可参考接口文档:
//https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.IXE2Zj&treeId=59&articleId=103671&docType=1
if (TextUtils.equals(resultStatus, ResultCode.CODE_SUCCESS)) {
if (sPayCallback != null) {
sPayCallback.success();
}
} else if(TextUtils.equals(resultStatus, ResultCode.CODE_CANCEL)){
if(sPayCallback != null){
sPayCallback.cancel();
}
} else {
// 其他值就可以判断为支付失败,包括用户主动取消支付,或者系统返回的错误
if (sPayCallback != null) {
sPayCallback.failed(ResultCode.getIntCodeByString(resultStatus), ResultCode.getTextByCode(resultStatus));
}
}
break;
}
default:
break;
}
}
};
}
package com.jobo.alipay; import android.text.TextUtils; import java.util.Map; /** * @Desc: 支付宝支付结果 * @author: admin wsj * @Date: 2021/12/28 2:33 下午 */public class AliPayResult { private String resultStatus; private String result; private String memo; public AliPayResult(Map<String, String> rawResult) { if (rawResult == null) { return; } for (String key : rawResult.keySet()) { if (TextUtils.equals(key, "resultStatus")) { resultStatus = rawResult.get(key); } else if (TextUtils.equals(key, "result")) { result = rawResult.get(key); } else if (TextUtils.equals(key, "memo")) { memo = rawResult.get(key); } } } @Override public String toString() { return "resultStatus={" + resultStatus + "};memo={" + memo + "};result={" + result + "}"; } /** * @return the resultStatus */ public String getResultStatus() { return resultStatus; } /** * @return the memo */ public String getMemo() { return memo; } /** * @return the result */ public String getResult() { return result; }}
\ No newline at end of file
package com.jobo.alipay;
import com.jobo.rxpay.base.IPayInfo;
/**
* @Desc: 包含支付宝支付类型和支付信息
* @author: admin wsj
* @Date: 2021/12/28 2:33 下午
*/
public class AlipayInfoImpl implements IPayInfo {
private String orderInfo;
public String getOrderInfo() {
return orderInfo;
}
public void setOrderInfo(String orderInfo) {
this.orderInfo = orderInfo;
}
}
package com.jobo.alipay;
import java.util.HashMap;
/**
* @Desc: 支付宝code
* @author: admin wsj
* @Date: 2021/12/28 2:33 下午
*/
public class ResultCode {
private static final HashMap<String, String> sErrorMap = new HashMap<>();
public static final String CODE_SUCCESS = "9000";
public static final String CODE_HANDLING = "8000";
public static final String CODE_FAIL = "4000";
public static final String CODE_REPEAT = "5000";
public static final String CODE_CANCEL = "6001";
public static final String CODE_NETWORK = "6002";
public static final String CODE_UNKNOWN = "6004";
private static final String TEXT_SUCCESS = "订单支付成功";
private static final String TEXT_HANDLING = "正在处理中";
private static final String TEXT_FAIL = "订单支付失败";
private static final String TEXT_REPEAT = "重复请求";
private static final String TEXT_CANCEL = "用户中途取消";
private static final String TEXT_NETWORK = "网络连接出错";
private static final String TEXT_UNKNOWN = "支付结果未知";
private static final String TEXT_ERROR = "未知错误";
static {
sErrorMap.put(CODE_SUCCESS, TEXT_SUCCESS);
sErrorMap.put(CODE_HANDLING, TEXT_HANDLING);
sErrorMap.put(CODE_FAIL, TEXT_FAIL);
sErrorMap.put(CODE_REPEAT, TEXT_REPEAT);
sErrorMap.put(CODE_CANCEL, TEXT_CANCEL);
sErrorMap.put(CODE_NETWORK, TEXT_NETWORK);
sErrorMap.put(CODE_UNKNOWN, TEXT_UNKNOWN);
}
private ResultCode() {
}
public static String getTextByCode(String code) {
String text = sErrorMap.get(code);
if (text == null) {
return TEXT_ERROR;
}
return text;
}
public static int getIntCodeByString(String errorCode) {
return Integer.parseInt(errorCode);
}
}
......@@ -12,8 +12,8 @@ android {
applicationId "com.duben.xixifree"
minSdkVersion rootProject.ext.androidMinSdkVersion
targetSdkVersion rootProject.ext.androidTargetSdkVersion
versionCode 14
versionName "1.1.3"
versionCode 15
versionName "1.1.4"
flavorDimensions "default"
// dex突破65535的限制
......@@ -26,9 +26,8 @@ android {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a"
}
manifestPlaceholders = [CHANNEL_NAME_VALUE: "smartclean",
manifestPlaceholders = [CHANNEL_NAME_VALUE: "xixifree",
WEIXIN_ID : WEIXIN_APP_ID,
UMENG_KEY : RELEASE_UMENG_KEY,
SHARE_KEY : RELEASE_SHARESDK_KEY,
SHARE_SECRET : RELEASE_SHARESDK_SECRET]
}
......@@ -66,7 +65,6 @@ android {
buildConfigField "String", "GROMORE_VIDEO_CODE", GROMORE_VIDEO_CODE
buildConfigField "String", "GROMORE_DRAW_CODE", GROMORE_DRAW_CODE
buildConfigField "String", "GROMORE_EXPRESS_CODE", GROMORE_EXPRESS_CODE
buildConfigField "String", "GROMORE_MY_EXPRESS_CODE", GROMORE_MY_EXPRESS_CODE
buildConfigField "String", "GROMORE_BANNER_CODE", GROMORE_BANNER_CODE
buildConfigField "String", "RELEASE_TALKING_DATA_KEY", RELEASE_TALKING_DATA_KEY
buildConfigField "String", "WEIXIN_APP_PAY_ID", WEIXIN_APP_PAY_ID
......@@ -90,7 +88,6 @@ android {
buildConfigField "String", "GROMORE_VIDEO_CODE", GROMORE_VIDEO_CODE
buildConfigField "String", "GROMORE_DRAW_CODE", GROMORE_DRAW_CODE
buildConfigField "String", "GROMORE_EXPRESS_CODE", GROMORE_EXPRESS_CODE
buildConfigField "String", "GROMORE_MY_EXPRESS_CODE", GROMORE_MY_EXPRESS_CODE
buildConfigField "String", "GROMORE_BANNER_CODE", GROMORE_BANNER_CODE
buildConfigField "String", "RELEASE_TALKING_DATA_KEY", RELEASE_TALKING_DATA_KEY
buildConfigField "String", "WEIXIN_APP_PAY_ID", WEIXIN_APP_PAY_ID
......@@ -228,7 +225,6 @@ dependencies {
// 支付
api project(':rxpay')
api project(':wxpay')
api project(':alipay')
api project(':oaid')
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
// bugly
......
......@@ -64,11 +64,6 @@
android:name="Mob-AppSecret"
android:value="${SHARE_SECRET}" />
<!-- 友盟 -->
<meta-data
android:name="UMENG_KEY"
android:value="${UMENG_KEY}" />
<!-- 渠道名称 -->
<meta-data
android:name="CHANNEL_NAME"
......
......@@ -79,7 +79,7 @@ class MyExpressManager {
val adNativeLoader = TTAdSdk.getAdManager().createAdNative(activity)
val adslot = AdSlot.Builder()
.setCodeId(BuildConfig.GROMORE_MY_EXPRESS_CODE)
.setCodeId(BuildConfig.GROMORE_EXPRESS_CODE)
/**
* 注:
* 1:单位为px
......
......@@ -46,7 +46,7 @@ object Constant {
const val FRAGMENT_CLICK_THREE = 2
// 协议地址
var REGISTER_URL = "http://mints-web.mints-id.com/agreements/helivideo/yhxy.html"//注册协议
var PRIVACY_URL = "http://mints-web.mints-id.com/agreements/helivideo/syzc.html"//隐私协议
var MEMBERS_URL = "https://mints-web.mints-id.com/agreements/helivideo/gmxy.html"//会员付费服务协议
var REGISTER_URL = "http://mints-web.mints-id.com/agreements/xixiplaylet/yhxy.html"//注册协议
var PRIVACY_URL = "http://mints-web.mints-id.com/agreements/xixiplaylet/syzc.html"//隐私协议
var MEMBERS_URL = "https://mints-web.mints-id.com/agreements/xixiplaylet/gmxy.html"//会员付费服务协议
}
\ No newline at end of file
......@@ -8,8 +8,6 @@ import android.os.Looper
import android.text.TextUtils
import android.view.KeyEvent
import android.view.View
import com.jobo.alipay.AliPay
import com.jobo.alipay.AlipayInfoImpl
import com.jobo.rxpay.RxPay
import com.jobo.rxpay.callback.IPayCallback
import com.duben.xixifree.R
......@@ -122,30 +120,6 @@ class NinePayActivity : BaseActivity(), View.OnClickListener, NinePayView {
e.printStackTrace()
}
//实例化支付宝支付策略
val aliPay = AliPay()
//构造支付宝订单实体。一般都是由服务端直接返回。
val alipayInfoImpl = AlipayInfoImpl()
alipayInfoImpl.setOrderInfo(wxParanBean.params.params)
//策略场景类调起支付方法开始支付,以及接收回调。
RxPay.pay(aliPay, this, alipayInfoImpl, object : IPayCallback {
override fun success() {
UserManager.getInstance().vipFlag = true
ninePayPresenter?.queryVipOrder(wxParanBean.tid.toString(), true)
}
override fun failed(code: Int, message: String?) {
ninePayPresenter?.payError(code)
if (!TextUtils.isEmpty(message)) {
showToast(message)
}
}
override fun cancel() {
ninePayPresenter?.queryVipOrder(wxParanBean.tid.toString(), false)
}
})
}
/**
......
......@@ -14,8 +14,6 @@ import com.airbnb.lottie.LottieCompositionFactory
import com.airbnb.lottie.LottieDrawable
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.jobo.alipay.AliPay
import com.jobo.alipay.AlipayInfoImpl
import com.jobo.rxpay.RxPay
import com.jobo.rxpay.callback.IPayCallback
import com.jobo.wxpay.WXPay
......@@ -33,7 +31,6 @@ import com.duben.xixifree.ui.activitys.base.BaseActivity
import com.duben.xixifree.ui.adapter.VipAdapter
import com.duben.xixifree.ui.widgets.*
import com.duben.library.utils.nodoubleclick.AntiShake
import com.duben.xixifree.utils.AppPreferencesManager
import kotlinx.android.synthetic.main.activity_vip.*
import kotlinx.android.synthetic.main.header_layout.*
......@@ -412,32 +409,6 @@ class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.On
} catch (e: Exception) {
e.printStackTrace()
}
//实例化支付宝支付策略
val aliPay = AliPay()
//构造支付宝订单实体。一般都是由服务端直接返回。
val alipayInfoImpl = AlipayInfoImpl()
alipayInfoImpl.setOrderInfo(wxParanBean.params.params)
//策略场景类调起支付方法开始支付,以及接收回调。
RxPay.pay(aliPay, this, alipayInfoImpl, object : IPayCallback {
override fun success() {
UserManager.getInstance().vipFlag = true
vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), true)
}
override fun failed(code: Int, message: String?) {
vipPresenter?.payError(code)
if (!TextUtils.isEmpty(message)) {
showToast(message)
}
}
override fun cancel() {
vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), false)
}
})
}
/**
......
......@@ -18,7 +18,7 @@ object DPHolderManager {
//1. 初始化,最好放到application.onCreate()执行
val configBuilder = DPSdkConfig.Builder().debug(true)
DPSdk.init(context, "SDK_Setting_5412556.json", configBuilder.build())
DPSdk.init(context, "SDK_Setting_5427620.json", configBuilder.build())
startDpSdk()
}
......
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:background="@color/white"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/white">
<ImageView
android:id="@+id/app_logo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="80dp"
android:layout_height="80dp"
android:layout_centerHorizontal="true"
android:layout_marginTop="140dp"
android:src="@mipmap/ic_splash_pic" />
android:src="@mipmap/ic_launcher_main" />
<TextView
android:layout_width="wrap_content"
......
include ':app'
include ':oaid'
include ':rxpay'
include ':alipay'
include ':wxpay'
......@@ -16,8 +16,8 @@
<Tumblr Enable="false" />
<Email Enable="false" />
<ShortMessage Enable="false" />
<Wechat AppId="wx7e946f66585ca00a" AppSecret="6fe41783e736bea36504b271cea484f1" userName="gh_afb25ac019c9" path="pages/index/index.html?id=1" WithShareTicket="true" MiniprogramType="0" />
<WechatMoments AppId="wx7e946f66585ca00a" AppSecret="6fe41783e736bea36504b271cea484f1" />
<Wechat AppId="wx4fe06dc52b1fed8e" AppSecret="d07a6b2194ef2fb125abe325aa174dcf" userName="gh_afb25ac019c9" path="pages/index/index.html?id=1" WithShareTicket="true" MiniprogramType="0" />
<WechatMoments AppId="wx4fe06dc52b1fed8e" AppSecret="d07a6b2194ef2fb125abe325aa174dcf" />
<QQ Enable="false" />
<Instapaper Enable="false" />
<Pocket Enable="false" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment