Commit cdf9e098 authored by mengcuiguang's avatar mengcuiguang

网赚版本

parent 93343a9f
/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);
}
}
...@@ -226,9 +226,6 @@ dependencies { ...@@ -226,9 +226,6 @@ dependencies {
implementation 'androidx.work:work-runtime-ktx:2.7.1' implementation 'androidx.work:work-runtime-ktx:2.7.1'
// 三方接入 // 三方接入
// 支付 // 支付
api project(':rxpay')
api project(':wxpay')
api project(':alipay')
api project(':oaid') api project(':oaid')
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4' implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
// bugly // bugly
......
...@@ -125,10 +125,6 @@ ...@@ -125,10 +125,6 @@
android:name=".ui.activitys.FeedbackActivity" android:name=".ui.activitys.FeedbackActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.VipActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity <activity
android:name=".ui.activitys.SettingsActivity" android:name=".ui.activitys.SettingsActivity"
android:exported="false" android:exported="false"
...@@ -137,40 +133,12 @@ ...@@ -137,40 +133,12 @@
android:name=".ui.activitys.AboutusActivity" android:name=".ui.activitys.AboutusActivity"
android:exported="false" android:exported="false"
android:screenOrientation="portrait" /> android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.OrderRecordActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.Backcash2Activity"
android:exported="false"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".ui.activitys.ManageOrderActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.NineActivity"
android:exported="false"
android:theme="@style/TransparentTheme" />
<activity <activity
android:name=".ui.activitys.RecommendActivity" android:name=".ui.activitys.RecommendActivity"
android:exported="false" android:exported="false"
android:theme="@style/TransparentTheme" /> android:theme="@style/TransparentTheme" />
<activity
android:name=".ui.activitys.NineKnowActivity"
android:exported="false"
android:theme="@style/TransparentTheme" />
<activity
android:name=".ui.activitys.NinePayActivity"
android:exported="false"
android:theme="@style/TransparentTheme" />
<activity <activity
android:name=".video.csj.DramaApiDetailActivity" android:name=".video.csj.DramaApiDetailActivity"
android:exported="false" android:exported="false"
......
...@@ -210,15 +210,7 @@ class DeviceInfo private constructor() { ...@@ -210,15 +210,7 @@ class DeviceInfo private constructor() {
(MintsApplication.getContext() (MintsApplication.getContext()
.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId .getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId
} catch (e: Exception) { } catch (e: Exception) {
try { imei = ""
imei = Settings.Secure.getString(
MintsApplication.getContext().contentResolver,
Settings.Secure.ANDROID_ID
)
} catch (e: Exception) {
imei = ""
e.printStackTrace()
}
e.printStackTrace() e.printStackTrace()
} }
return imei return imei
......
package com.mints.helivideo.mvp.presenters
import com.mints.helivideo.manager.AppHttpManager
import com.mints.helivideo.mvp.model.BaseResponse
import com.mints.helivideo.mvp.views.BackCashView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import java.util.HashMap
class BackCashPresenter : BasePresenter<BackCashView>() {
fun reqfundV1(
orderMobile: String,
orderCause: String,
orderSuggest: String,
orderNickname: String,
) {
val vo = HashMap<String, Any>()
vo["reason"] = orderCause
vo["mobile"] = orderMobile
vo["name"] = orderNickname
vo["remarks"] = orderSuggest
AppHttpManager.getInstance(loanApplication)
.call(loanService.reqfundV1(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
view.reqfundFail(e.message.toString())
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code: Int = baseResponse.status
when (code) {
200 -> {
view.reqfundSuc()
}
else -> {
view.reqfundFail(baseResponse.message)
}
}
}
})
}
}
\ No newline at end of file
package com.mints.helivideo.mvp.presenters
import com.mints.helivideo.manager.AppHttpManager
import com.mints.helivideo.mvp.model.BaseResponse
import com.mints.helivideo.mvp.model.WxPayParamBean
import com.mints.helivideo.mvp.views.NinePayView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import java.util.HashMap
class NinePayPresenter : BasePresenter<NinePayView>() {
fun getVipPayParams(pid: String) {
val vo = HashMap<String, Any>()
vo["payChannel"] = "ALIPAY"
vo["pid"] = pid
AppHttpManager.getInstance(loanApplication)
.call(loanService.getVipPayParams(vo),
object : BaseSubscriber<BaseResponse<WxPayParamBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
view.showToast(e.message)
}
override fun onNext(baseResponse: BaseResponse<WxPayParamBean>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
when (code) {
200 -> {
view.getVipPayParamsSuc("ALIPAY",baseResponse.data)
}
else -> {
view.showToast(baseResponse.getMessage())
}
}
}
})
}
fun payError(code: Int) {
val vo = HashMap<String, Any>()
vo["code"] = code
AppHttpManager.getInstance(loanApplication)
.call(loanService.payError(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
}
})
}
fun queryVipOrder(tid: String, isPay: Boolean) {
val vo = HashMap<String, Any>()
vo["tid"] = tid
AppHttpManager.getInstance(loanApplication)
.call(loanService.queryVipOrder(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
when (code) {
200 -> {
view.queryVipOrderSuc(isPay)
}
}
}
})
}
}
\ No newline at end of file
package com.mints.helivideo.mvp.presenters
import com.mints.helivideo.manager.AppHttpManager
import com.mints.helivideo.mvp.model.BaseResponse
import com.mints.helivideo.mvp.model.IndexList
import com.mints.helivideo.mvp.model.NineListBean
import com.mints.helivideo.mvp.model.NineShowBean
import com.mints.helivideo.mvp.views.NineView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import java.util.HashMap
class NinePresenter : BasePresenter<NineView>() {
fun getTurnIphoneMsg() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getTurnConfig(),
object : BaseSubscriber<BaseResponse<NineListBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<NineListBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.getTurnIphoneMsgSuc(baseResponse.data)
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun showTurn() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.showTurn(),
object : BaseSubscriber<BaseResponse<NineShowBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<NineShowBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.showTurnSuc(baseResponse.data)
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun toTurn() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.toTurn(),
object : BaseSubscriber<BaseResponse<NineListBean.NineBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<NineListBean.NineBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.toTurnSuc(baseResponse.data)
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun unlock(vo: HashMap<String, Any>) {
AppHttpManager.getInstance(loanApplication)
.call(
loanService.unlock(vo),
object : BaseSubscriber<BaseResponse<IndexList>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<IndexList>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.unlockSuc()
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
}
\ No newline at end of file
package com.mints.helivideo.mvp.presenters
import com.mints.helivideo.MintsApplication
import com.mints.helivideo.manager.AppHttpManager
import com.mints.helivideo.mvp.model.BaseResponse
import com.mints.helivideo.mvp.model.VipBean
import com.mints.helivideo.mvp.model.WxPayParamBean
import com.mints.helivideo.mvp.views.VipView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import com.mints.helivideo.common.DeviceInfo
import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.UserBean
import com.mints.helivideo.utils.DeviceUuidFactory
import java.util.*
class VipPresenter : BasePresenter<VipView>() {
/**
* 游客登录
*/
fun userLogin(isInstallAlipay:Boolean) {
val vo = HashMap<String, Any>()
vo["device"] = DeviceUuidFactory().deviceUuid.toString()
AppHttpManager.getInstance(loanApplication)
.call(loanService.visitorlogin(vo),
object : BaseSubscriber<BaseResponse<UserBean>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<UserBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.getStatus()
val message = baseResponse.getMessage()
val data: UserBean? = baseResponse.getData()
when (code) {
200 -> if (data != null) {
UserManager.getInstance().saveUserInfo(data)
saveTerminalInfo(isInstallAlipay)
}
else -> view.showToast(message)
}
}
})
}
/**
* 提交设备信息
*
* @param context
*/
fun saveTerminalInfo(isInstallAlipay:Boolean) {
val vo = HashMap<String, Any>()
val deviceInfo: DeviceInfo = DeviceInfo.instance
val macAddress: String = deviceInfo.getMacAddress()
val mac = macAddress.replace(":", "")
vo["mac"] = mac
vo["mac1"] = macAddress
vo["androidid"] = deviceInfo.getAndroidId(null)
vo["imei"] = deviceInfo.iMEI
vo["oaid"] = MintsApplication.OAID
vo["os"] = if (deviceInfo.isHarmonyOS()) "android-HarmonyOS" else "android"
vo["model"] = deviceInfo.newModel
vo["uuid"] = DeviceUuidFactory().deviceUuid
vo["osversion"] = deviceInfo.oSVersion
vo["appversion"] = deviceInfo.versionName
AppHttpManager.getInstance(loanApplication)
.call(loanService.saveTerminalInfo(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
}
override fun onError(e: Throwable) {
if (isLinkView) return
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code = baseResponse.status
when (code) {
200 -> getVipProducts(isInstallAlipay)
}
}
})
}
fun payError(code: Int) {
val vo = HashMap<String, Any>()
vo["code"] = code
AppHttpManager.getInstance(loanApplication)
.call(loanService.payError(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
}
})
}
fun getVipProducts(isInstallAlipay:Boolean) {
val vo = HashMap<String, Any>()
vo["isInstallAlipay"] = isInstallAlipay
view.showLoading("加载中...")
AppHttpManager.getInstance(loanApplication)
.call(loanService.getVipProducts(vo),
object : BaseSubscriber<BaseResponse<VipBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
view.showToast(e.message)
}
override fun onNext(baseResponse: BaseResponse<VipBean>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
when (code) {
200 -> {
view.getVipProductSuc(baseResponse.data)
}
else -> {
view.showToast(baseResponse.getMessage())
}
}
}
})
}
fun getVipPayParams(payChannel: String, pid: String,isInstallAlipay:Boolean) {
val vo = HashMap<String, Any>()
vo["payChannel"] = payChannel
vo["pid"] = pid
vo["isInstallAlipay"] = isInstallAlipay
AppHttpManager.getInstance(loanApplication)
.call(loanService.getVipPayParams(vo),
object : BaseSubscriber<BaseResponse<WxPayParamBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
view.showToast(e.message)
}
override fun onNext(baseResponse: BaseResponse<WxPayParamBean>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
when (code) {
200 -> {
view.getVipPayParamsSuc(payChannel, baseResponse.data)
}
else -> {
view.showToast(baseResponse.getMessage())
}
}
}
})
}
fun queryVipOrder(tid: String, isPay: Boolean) {
val vo = HashMap<String, Any>()
vo["tid"] = tid
AppHttpManager.getInstance(loanApplication)
.call(loanService.queryVipOrder(vo),
object : BaseSubscriber<BaseResponse<Any>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onError(e: Throwable) {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<Any>) {
if (isLinkView) return
val code: Int = baseResponse.getStatus()
when (code) {
200 -> {
view.queryVipOrderSuc(isPay)
}
}
}
})
}
}
\ No newline at end of file
package com.mints.helivideo.mvp.views
interface BackCashView : BaseView {
fun reqfundSuc()
fun reqfundFail(msg: String)
}
\ No newline at end of file
package com.mints.helivideo.mvp.views
import com.mints.helivideo.mvp.model.WxPayParamBean
interface NinePayView : BaseView{
fun getVipPayParamsSuc(payChannel:String,data: WxPayParamBean)
fun queryVipOrderSuc(isPay:Boolean)
}
package com.mints.helivideo.mvp.views
import com.mints.helivideo.mvp.model.NineListBean
import com.mints.helivideo.mvp.model.NineShowBean
interface NineView : BaseView {
fun getTurnIphoneMsgSuc(data: NineListBean)
fun toTurnSuc(data: NineListBean.NineBean)
fun showTurnSuc(data: NineShowBean)
fun unlockSuc()
}
\ No newline at end of file
package com.mints.helivideo.mvp.views
import com.mints.helivideo.mvp.model.IndexList
import com.mints.helivideo.mvp.model.NineShowBean
interface VideoView : BaseView {
fun getIndexListSuc(indexList: IndexList)
fun getIndexListFail()
fun collectSuc()
fun collectFail()
fun cancelCollectSuc()
fun cancelCollectFail()
fun unlockSuc(indexList: IndexList)
fun unlockFail()
fun showTurnSuc(data: NineShowBean)
}
\ No newline at end of file
package com.mints.helivideo.ui.activitys
import android.os.Looper
import android.text.TextUtils
import android.view.View
import androidx.core.content.ContextCompat
import com.mints.helivideo.MintsApplication
import com.mints.helivideo.R
import com.mints.helivideo.mvp.presenters.BackCashPresenter
import com.mints.helivideo.mvp.views.BackCashView
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.utils.SpanUtils
import com.mints.helivideo.utils.ToastUtil
import kotlinx.android.synthetic.main.activity_backcash2.*
import kotlinx.android.synthetic.main.header_layout.*
class Backcash2Activity : BaseActivity(), BackCashView, View.OnClickListener {
private var backCashReason = ""
private val backCashPresenter by lazy { BackCashPresenter() }
override fun getContentViewLayoutID() = R.layout.activity_backcash2
override fun initViewsAndEvents() {
backCashPresenter.attachView(this)
tv_title.text = "申请退款"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.setOnClickListener { finish() }
tv_order_nickname.text = SpanUtils()
.append("1.您的称呼")
.setForegroundColor(ContextCompat.getColor(this, R.color.black))
.create()
tv_order_mobile.text = SpanUtils()
.append("* ")
.setForegroundColor(ContextCompat.getColor(this, R.color.red))
.append("2.您的联系方式")
.setForegroundColor(ContextCompat.getColor(this, R.color.black))
.create()
tv_order_cause.text = SpanUtils()
.append("* ")
.setForegroundColor(ContextCompat.getColor(this, R.color.red))
.append("3.退款原因")
.setForegroundColor(ContextCompat.getColor(this, R.color.black))
.create()
tv_order_suggest.text = SpanUtils()
.append("4.建议")
.setForegroundColor(ContextCompat.getColor(this, R.color.black))
.create()
rb_1.setOnClickListener(this)
rb_2.setOnClickListener(this)
rb_3.setOnClickListener(this)
rb_4.setOnClickListener(this)
btn_submit.setOnClickListener(this)
}
override fun isApplyKitKatTranslucency() = false
override fun reqfundSuc() {
if (isFinishing) return
ToastUtil.showLong(MintsApplication.getContext(),"退款发起成功!")
android.os.Handler(Looper.getMainLooper()).postDelayed({
if (isFinishing) return@postDelayed
finish()
}, 400)
}
override fun reqfundFail(msg: String) {
if (isFinishing) return
ToastUtil.showLong(MintsApplication.getContext(),msg)
}
private fun changeChoice(type: Int) {
when (type) {
1 -> {
rb_1.isChecked = true
rb_2.isChecked = false
rb_3.isChecked = false
rb_4.isChecked = false
}
2 -> {
rb_1.isChecked = false
rb_2.isChecked = true
rb_3.isChecked = false
rb_4.isChecked = false
}
3 -> {
rb_1.isChecked = false
rb_2.isChecked = false
rb_3.isChecked = true
rb_4.isChecked = false
}
4 -> {
rb_1.isChecked = false
rb_2.isChecked = false
rb_3.isChecked = false
rb_4.isChecked = true
}
}
}
override fun onClick(p0: View?) {
when (p0?.id) {
R.id.rb_1 -> {
backCashReason = rb_1.text.toString()
changeChoice(1)
}
R.id.rb_2 -> {
backCashReason = rb_2.text.toString()
changeChoice(2)
}
R.id.rb_3 -> {
backCashReason = rb_3.text.toString()
changeChoice(3)
}
R.id.rb_4 -> {
backCashReason = rb_4.text.toString()
changeChoice(4)
}
R.id.btn_submit -> {
if (TextUtils.isEmpty(et_order_mobile.text)) {
showToast("联系方式不能为空")
return
}
if (TextUtils.isEmpty(backCashReason)) {
showToast("退款原因不能为空")
return
}
backCashPresenter.reqfundV1(
et_order_mobile.text.toString(),
backCashReason,
et_order_suggest.text.toString(),
et_order_nickname.text.toString()
)
}
else -> {}
}
}
}
\ No newline at end of file
...@@ -59,9 +59,6 @@ class GuideActivity : BaseActivity() { ...@@ -59,9 +59,6 @@ class GuideActivity : BaseActivity() {
if (TextUtils.isEmpty(UserManager.getInstance().userID)) { if (TextUtils.isEmpty(UserManager.getInstance().userID)) {
readyGoThenKill(MainActivity::class.java) readyGoThenKill(MainActivity::class.java)
} else { } else {
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_GUIDE, true)
readyGoThenKill(VipActivity::class.java, bundle)
} }
//带点渐变动画 //带点渐变动画
overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
......
package com.mints.helivideo.ui.activitys
import android.app.Dialog
import android.os.Bundle
import android.text.TextUtils
import android.view.View
import com.google.gson.JsonObject
import com.mints.helivideo.MintsApplication
import com.mints.helivideo.R
import com.mints.helivideo.manager.AppHttpManager
import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.BaseResponse
import com.mints.helivideo.mvp.model.OrderRecordBean.AgreementDTO
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.widgets.CancelOrderDialog
import com.mints.helivideo.ui.widgets.DialogListener
import com.mints.helivideo.utils.ToastUtil
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_manage_order.*
import kotlinx.android.synthetic.main.header_layout.*
/**
* 描述:管理自动续费
*/
class ManageOrderActivity : BaseActivity(), View.OnClickListener {
companion object {
const val AGREEMENT_DATA = "agreement"
}
private var mAgreementDTO: AgreementDTO? = null
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
mAgreementDTO = it.getSerializable(AGREEMENT_DATA) as AgreementDTO?
}
}
override fun getContentViewLayoutID() = R.layout.activity_manage_order
override fun initViewsAndEvents() {
tv_title.text = "管理自动续费"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.setOnClickListener(this)
tv_cancel.setOnClickListener(this)
if (TextUtils.isEmpty(UserManager.getInstance().mobile)) {
tv_my_account.text = "手机号:未授权"
} else {
tv_my_account.text = "手机号:" + UserManager.getInstance().mobile
}
tv_my_hint.text = "ID:" + UserManager.getInstance().codeId
mAgreementDTO?.let {
tv_date.text = it.nextDay
tv_coin.text = it.balance
tv_channel.text = it.payChannel
tv_1.text = it.topText
}
}
override fun isApplyKitKatTranslucency() = false
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.iv_left_icon -> finish()
R.id.tv_cancel -> {
showCancelListener()
}
}
}
private fun showCancelListener() {
CancelOrderDialog(this, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
dialog?.dismiss()
unSign()
}
}).show()
}
private fun unSign() {
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.unSign(),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onError(e: Throwable) {}
override fun onNext(t: BaseResponse<JsonObject>) {
if (t.status == 200) {
ToastUtil.show(MintsApplication.getContext(), "成功取消自动续费")
finish()
}
}
})
}
}
\ No newline at end of file
package com.mints.helivideo.ui.activitys
import android.os.Bundle
import android.view.KeyEvent
import android.view.View
import com.mints.helivideo.R
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.utils.SpanUtils
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_nine_know.*
/**
* 描述:9宫格手机
* 作者:孟崔广
*/
class NineKnowActivity : BaseActivity(), View.OnClickListener {
companion object {
const val COMPLETE = "COMPLETE"
const val NEED = "NEED"
}
private var complete = 0
private var need = 0
override fun getContentViewLayoutID() = R.layout.activity_nine_know
override fun isApplyKitKatTranslucency() = false
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
complete = it.getInt(COMPLETE, 0)
need = it.getInt(NEED, 0)
}
}
override fun initViewsAndEvents() {
tv_nine_know_text.text = SpanUtils()
.append("再看")
.append("${need - complete}")
.setForegroundColor(resources.getColor(R.color.red))
.append("次广告后抽")
.append("手机")
.setForegroundColor(resources.getColor(R.color.red))
.create()
initListener()
}
private fun initListener() {
tv_nine_know_next.setOnClickListener(this)
}
override fun finish() {
super.finish()
overridePendingTransition(0, R.anim.scale_out)
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(
keyCode,
event
)
}
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
when (v.id) {
R.id.tv_nine_know_next -> {
finish()
}
}
}
}
\ No newline at end of file
package com.mints.helivideo.ui.activitys
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.os.Handler
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.mints.helivideo.R
import com.mints.helivideo.manager.ActivityPageManager
import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.WxPayParamBean
import com.mints.helivideo.mvp.presenters.NinePayPresenter
import com.mints.helivideo.mvp.views.NinePayView
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_nine_pay.*
/**
* 抽奖弹窗
*/
class NinePayActivity : BaseActivity(), View.OnClickListener, NinePayView {
companion object {
const val PID = "PID"
const val TITLE = "TITLE"
const val TYPE = "TYPE"
}
private val ninePayPresenter by lazy { NinePayPresenter() }
private var pid = ""
private var title = ""
private var type = ""
override fun isApplyKitKatTranslucency() = false
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun getContentViewLayoutID() = R.layout.activity_nine_pay
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
pid = it.getString(PID, "")
title = it.getString(TITLE, "")
type = it.getString(TYPE, "")
}
}
override fun initViewsAndEvents() {
ninePayPresenter.attachView(this)
initListener()
tv_nine_pay_title.text = title
when (type) {
"o" ->// 一年
iv_nine_pay_type.setImageResource(R.mipmap.ic_nine_year)
"f" ->// 终身
iv_nine_pay_type.setImageResource(R.mipmap.ic_nine_all)
"m" -> // 手机
iv_nine_pay_type.setImageResource(R.mipmap.ic_nine_mobile)
else ->// 支付
iv_nine_pay_type.setImageResource(R.mipmap.ic_nine_vip)
}
}
override fun finish() {
super.finish()
overridePendingTransition(0, R.anim.scale_out)
}
override fun onDestroy() {
super.onDestroy()
ninePayPresenter.detachView()
}
override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean {
return if (keyCode == KeyEvent.KEYCODE_BACK) {
true
} else super.onKeyDown(
keyCode,
event
)
}
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.iv_nine_left_next -> finish()
R.id.iv_nine_right_next -> ninePayPresenter.getVipPayParams(pid)
}
}
override fun getVipPayParamsSuc(payChannel: String, paramsBean: WxPayParamBean) {
if (!isFinishing) {
if (paramsBean.params == null) {
showToast("支付宝支付维护中")
return
}
alipay(paramsBean)
}
}
fun alipay(wxParanBean: WxPayParamBean) {
try {
// 自动签约付费
if (wxParanBean.params.isSign) {
openAutoAlipay(wxParanBean.params.params)
return
}
} 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
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)
}
})
}
/**
* 自动续费
*/
fun openAutoAlipay(url: String) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}
override fun queryVipOrderSuc(isPay: Boolean) {
if (isFinishing) return
if (isPay) {
showToast("支付成功")
Handler(Looper.getMainLooper()).postDelayed({
readyGo(MainActivity::class.java)
val activity =
ActivityPageManager.getInstance().getActivity(MainActivity::class.java)
if (activity != null && activity is MainActivity) {
activity.clickTab3Layout()
}
}, 500)
} else {
finish()
}
}
private fun initListener() {
iv_nine_left_next.setOnClickListener(this)
iv_nine_right_next.setOnClickListener(this)
}
}
package com.mints.helivideo.ui.activitys
import android.os.Bundle
import android.view.View
import com.mints.helivideo.R
import com.mints.helivideo.manager.AppHttpManager
import com.mints.helivideo.mvp.model.BaseResponse
import com.mints.helivideo.mvp.model.OrderRecordBean
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.adapter.OrderRecordAdapter
import com.mints.helivideo.ui.adapter.base.OnItemClickListener
import com.mints.helivideo.utils.UcropUtils
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import com.scwang.smartrefresh.layout.api.RefreshLayout
import com.scwang.smartrefresh.layout.listener.OnRefreshListener
import kotlinx.android.synthetic.main.activity_order_record.*
import kotlinx.android.synthetic.main.header_layout.*
/**
* 描述:订单记录
* 作者:孟崔广
* 邮箱:mengcga@163.com
*/
class OrderRecordActivity : BaseActivity(), View.OnClickListener, OnRefreshListener {
private var orderRecordAdapter: OrderRecordAdapter? = null
private var mAgreementDTO: OrderRecordBean.AgreementDTO? = null
private var mOrderData: MutableList<OrderRecordBean.RecordsBean> = mutableListOf()
override fun getContentViewLayoutID() = R.layout.activity_order_record
override fun initViewsAndEvents() {
tv_title.text = "我的订单"
iv_left_icon.visibility = View.VISIBLE
iv_left_icon.setImageResource(R.mipmap.ic_arrow_back)
iv_left_icon.setOnClickListener(this)
tv_right.visibility = View.VISIBLE
tv_right.setOnClickListener(this)
tv_right.text = "续费管理"
srl_drawcash.setOnRefreshListener(this)
initRecy()
getData()
}
private fun getData() {
AppHttpManager.getInstance(baseApplication)
.call(baseApplication.loanService.cashOutRecords,
object : BaseSubscriber<BaseResponse<OrderRecordBean>>() {
override fun onError(e: Throwable) {
srl_drawcash.finishRefresh(false)
}
override fun onNext(t: BaseResponse<OrderRecordBean>) {
if (t.status == 200) {
srl_drawcash.finishRefresh(true)
mAgreementDTO = t.data.agreement
if (mAgreementDTO == null) {
tv_right.visibility = View.GONE
}
mOrderData.clear()
mOrderData.addAll(t.data.records)
orderRecordAdapter?.notifyDataSetChanged()
} else {
srl_drawcash.finishRefresh(false)
}
}
})
}
private fun initRecy() {
orderRecordAdapter = OrderRecordAdapter(this, mOrderData)
recy_drawcash.adapter = orderRecordAdapter
orderRecordAdapter!!.setOnItemClickListener(object : OnItemClickListener {
override fun onItemClick(view: View?, position: Int) {
if (mOrderData != null && mOrderData.size > 0) {
showToast("订单号已复制到剪切板!")
UcropUtils.clipData(mOrderData.get(position).orderid)
}
}
})
}
override fun isApplyKitKatTranslucency() = false
override fun onClick(v: View?) {
when (v?.id) {
R.id.iv_left_icon -> finish()
R.id.tv_right -> {
if (mAgreementDTO == null) {
showToast("暂未开通自动续费")
} else {
val bundle = Bundle()
bundle.putSerializable(ManageOrderActivity.AGREEMENT_DATA, mAgreementDTO)
readyGo(ManageOrderActivity::class.java, bundle)
}
}
}
}
override fun onRefresh(refreshLayout: RefreshLayout) {
getData()
}
}
\ No newline at end of file
...@@ -185,7 +185,6 @@ class SettingsActivity : BaseActivity(), View.OnClickListener { ...@@ -185,7 +185,6 @@ class SettingsActivity : BaseActivity(), View.OnClickListener {
} }
} }
R.id.item_back -> { R.id.item_back -> {
readyGo(Backcash2Activity::class.java)
} }
} }
} }
......
package com.mints.helivideo.ui.adapter
import android.content.Context
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.mints.helivideo.R
import com.mints.helivideo.mvp.model.OrderRecordBean
import com.mints.helivideo.ui.adapter.base.OnItemClickListener
import com.mints.helivideo.utils.TimeRender
import java.util.*
class OrderRecordAdapter(context: Context, invitedData: MutableList<OrderRecordBean.RecordsBean>) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
companion object {
const val HOLDER_TYPE_EMPTY = 0
const val HOLDER_TYPE_DRAWCASH = 1
}
private var mContext: Context = context
private var mOrderData: List<OrderRecordBean.RecordsBean> = invitedData
private var mOnItemClickListener: OnItemClickListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if (viewType == HOLDER_TYPE_EMPTY) {
val emptyView =
LayoutInflater.from(parent.context).inflate(R.layout.item_empty_cash, parent, false)
return EmptyHolder(emptyView)
}
val view = LayoutInflater.from(parent.context)
.inflate(R.layout.item_list_orderrecord, parent, false)
return ViewHolder(view)
}
override fun onBindViewHolder(viewHolder: RecyclerView.ViewHolder, position: Int) {
if (viewHolder is EmptyHolder) {
return
}
val holder = viewHolder as ViewHolder
val data: OrderRecordBean.RecordsBean = mOrderData[position]
holder.tv_orderrecord_copy.setOnClickListener {
mOnItemClickListener?.onItemClick(holder.tv_orderrecord_copy, position)
}
holder.tv_orderrecord_name.text = data.title
holder.tv_orderrecord_date.text = "付款时间:" + data.time
holder.tv_orderrecord_money.text = "¥" + data.balance
holder.tv_orderrecord_no.text = "订单编号:" + data.orderid
}
override fun getItemCount(): Int {
return if (mOrderData.isEmpty()) {
1
} else {
mOrderData.size
}
}
override fun getItemViewType(position: Int): Int {
if (mOrderData.isEmpty()) {
return HOLDER_TYPE_EMPTY
}
return HOLDER_TYPE_DRAWCASH
}
inner class EmptyHolder(itemView: View) : RecyclerView.ViewHolder(itemView)
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val tv_orderrecord_name: TextView = view.findViewById(R.id.tv_orderrecord_name)
val tv_orderrecord_date: TextView = view.findViewById(R.id.tv_orderrecord_date)
val tv_orderrecord_money: TextView = view.findViewById(R.id.tv_orderrecord_money)
val tv_orderrecord_no: TextView = view.findViewById(R.id.tv_orderrecord_no)
val tv_orderrecord_copy: TextView = view.findViewById(R.id.tv_orderrecord_copy)
}
fun setOnItemClickListener(listener: OnItemClickListener) {
mOnItemClickListener = listener
}
}
\ No newline at end of file
package com.mints.helivideo.ui.adapter
import android.content.Context
import android.graphics.Color
import android.graphics.Paint
import android.text.TextUtils
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.mints.helivideo.R
import com.mints.helivideo.mvp.model.VipBean
class VipAdapter(val vipList: MutableList<VipBean.ListBean>) :
RecyclerView.Adapter<VipAdapter.ViewHolder>() {
var myPos: Int = 0
lateinit var context: Context
lateinit var mOnItemClickListener: OnItemClickListener
init {
if (vipList != null && vipList.size > 0) {
for (i in 0..vipList.size - 1) {
if (vipList[i].activityType == 1) {
myPos = i
break
}
}
}
}
inner class ViewHolder(view: View) : RecyclerView.ViewHolder(view) {
val rlVipItemRoot: LinearLayout = view.findViewById(R.id.rlVipItemRoot)
val tvVipItemCurMoney: TextView = view.findViewById(R.id.tvVipItemCurMoney)
val tvVipItemMoney: TextView = view.findViewById(R.id.tvVipItemMoney)
val tvVipItemTitle: TextView = view.findViewById(R.id.tvVipItemTitle)
val tvVipItemLable: TextView = view.findViewById(R.id.tvVipItemLable)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
context = parent.context
val view = LayoutInflater.from(context).inflate(R.layout.item_rv_vip, parent, false)
val viewHolder = ViewHolder(view)
return viewHolder
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
val vipBean = vipList[position]
holder.tvVipItemTitle.text = vipBean.title
if (TextUtils.isEmpty(vipBean.topTitle)) {
holder.tvVipItemLable.visibility = View.INVISIBLE
} else {
holder.tvVipItemLable.text = vipBean.topTitle
holder.tvVipItemLable.visibility = View.VISIBLE
}
if (vipBean.price < 1) {
holder.tvVipItemCurMoney.text = "¥${vipBean.price}"
} else {
holder.tvVipItemCurMoney.text = "¥${String.format("%.0f", vipBean.price)}"
}
if (vipBean.oldPrice > 0) {
holder.tvVipItemMoney.visibility = View.VISIBLE
holder.tvVipItemMoney.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG) //中间横线(删除线)
if (vipBean.oldPrice < 1) {
holder.tvVipItemMoney.text = "原价:${vipBean.oldPrice}"
} else {
holder.tvVipItemMoney.text = "原价:${String.format("%.0f", vipBean.oldPrice)}"
}
} else {
holder.tvVipItemMoney.visibility = View.INVISIBLE
}
holder.rlVipItemRoot.setOnClickListener {
mOnItemClickListener.onItemClick(position)
notifyDataSetChanged()
}
if (getPosition() == position) {
//当前选中
holder.rlVipItemRoot.setBackgroundResource(R.drawable.shape_vip_adapter)
holder.tvVipItemCurMoney.setTextColor(
ContextCompat.getColor(
context,
R.color.color_FF7563
)
)
} else {
holder.rlVipItemRoot.setBackgroundResource(R.drawable.shape_vip_adapter_none)
holder.tvVipItemCurMoney.setTextColor(
ContextCompat.getColor(
context,
R.color.white
)
)
}
holder.itemView.setTag(position)
}
override fun getItemCount() = vipList?.size
interface OnItemClickListener {
fun onItemClick(position: Int)
}
fun setOnItemClickListener(listener: OnItemClickListener) {
mOnItemClickListener = listener
}
fun getPosition() = myPos
fun setPosition(myPos: Int) {
this.myPos = myPos
}
}
\ No newline at end of file
...@@ -26,10 +26,7 @@ import com.mints.helivideo.manager.UserManager ...@@ -26,10 +26,7 @@ import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.* import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.presenters.HomePresenter import com.mints.helivideo.mvp.presenters.HomePresenter
import com.mints.helivideo.mvp.views.HomeView import com.mints.helivideo.mvp.views.HomeView
import com.mints.helivideo.ui.activitys.NineActivity
import com.mints.helivideo.ui.activitys.NinePayActivity
import com.mints.helivideo.ui.activitys.RecommendActivity import com.mints.helivideo.ui.activitys.RecommendActivity
import com.mints.helivideo.ui.activitys.VipActivity
import com.mints.helivideo.ui.adapter.HomeVideoPageAdapter import com.mints.helivideo.ui.adapter.HomeVideoPageAdapter
import com.mints.helivideo.ui.adapter.ImageTitleAdapter import com.mints.helivideo.ui.adapter.ImageTitleAdapter
import com.mints.helivideo.ui.adapter.TopAdapter import com.mints.helivideo.ui.adapter.TopAdapter
...@@ -95,9 +92,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -95,9 +92,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) { if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
homePresenter.getRecommendVedio() homePresenter.getRecommendVedio()
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_MAIN, true)
readyGo(VipActivity::class.java, bundle)
} }
} else { } else {
homePresenter.getSoltVedio() homePresenter.getSoltVedio()
...@@ -163,7 +157,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -163,7 +157,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
} }
} }
R.id.ll_lucky -> { R.id.ll_lucky -> {
readyGo(NineActivity::class.java)
} }
} }
} }
...@@ -304,10 +297,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -304,10 +297,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
.setOnBannerListener { data2, position -> .setOnBannerListener { data2, position ->
val banner = data.list.get(position) val banner = data.list.get(position)
if (banner.createType == 4) { if (banner.createType == 4) {
// 九宫格
val bundle = Bundle()
bundle.putBoolean(NineActivity.IS_AD_SHOW, true)
readyGo(NineActivity::class.java, bundle)
} else { } else {
LocalVedioManager.startVedioDetailActivityForType( LocalVedioManager.startVedioDetailActivityForType(
requireActivity(), requireActivity(),
...@@ -335,9 +324,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR ...@@ -335,9 +324,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) { if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
homePresenter.getRecommendVedio() homePresenter.getRecommendVedio()
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_MAIN, true)
readyGo(VipActivity::class.java, bundle)
} }
} }
} }
......
...@@ -113,9 +113,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -113,9 +113,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
when (v?.id) { when (v?.id) {
R.id.tv_my_btn -> { R.id.tv_my_btn -> {
if (!userManager.vipFlag) {
readyGo(VipActivity::class.java)
}
} }
R.id.ll_my_setting -> { R.id.ll_my_setting -> {
readyGo(SettingsActivity::class.java) readyGo(SettingsActivity::class.java)
...@@ -135,7 +132,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -135,7 +132,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
(requireActivity() as MainActivity).backPhoneDialog() (requireActivity() as MainActivity).backPhoneDialog()
} }
R.id.ll_my_payrecord -> { R.id.ll_my_payrecord -> {
readyGo(OrderRecordActivity::class.java)
} }
R.id.btn_action,R.id.rl_lucky -> { R.id.btn_action,R.id.rl_lucky -> {
clickTurn() clickTurn()
...@@ -331,11 +327,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -331,11 +327,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
lucky_panel.tryToStop(index) lucky_panel.tryToStop(index)
Handler(Looper.getMainLooper()).postDelayed({ Handler(Looper.getMainLooper()).postDelayed({
val bundle = Bundle()
bundle.putString(NinePayActivity.PID, data.pid)
bundle.putString(NinePayActivity.TITLE, data.title)
bundle.putString(NinePayActivity.TYPE, data.type)
readyGo(NinePayActivity::class.java, bundle)
}, 1500) }, 1500)
} }
}) })
...@@ -368,10 +359,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener { ...@@ -368,10 +359,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
if (!luckyFirst) { if (!luckyFirst) {
isTurnLuckyPage=true isTurnLuckyPage=true
AppPreferencesManager.get().put(Constant.LUCKY_MY_FIRST, true) AppPreferencesManager.get().put(Constant.LUCKY_MY_FIRST, true)
val bundle = Bundle()
bundle.putInt(NineKnowActivity.COMPLETE, nineShowBean!!.complete)
bundle.putInt(NineKnowActivity.NEED, nineShowBean!!.need)
readyGo(NineKnowActivity::class.java, bundle)
return return
} }
} }
......
...@@ -14,7 +14,6 @@ import com.mints.helivideo.R ...@@ -14,7 +14,6 @@ import com.mints.helivideo.R
import com.mints.helivideo.ad.express.ExpressAdCallback import com.mints.helivideo.ad.express.ExpressAdCallback
import com.mints.helivideo.ad.express.ExpressManager import com.mints.helivideo.ad.express.ExpressManager
import com.mints.helivideo.mvp.model.VedioBean import com.mints.helivideo.mvp.model.VedioBean
import com.mints.helivideo.ui.activitys.VipActivity
import com.mints.helivideo.ui.widgets.countdowntimer.CountDownTimerSupport import com.mints.helivideo.ui.widgets.countdowntimer.CountDownTimerSupport
import com.mints.helivideo.ui.widgets.countdowntimer.OnCountDownTimerListener import com.mints.helivideo.ui.widgets.countdowntimer.OnCountDownTimerListener
import com.mints.helivideo.utils.UIUtils import com.mints.helivideo.utils.UIUtils
...@@ -70,10 +69,6 @@ class VipCountDialog(val activity: Activity, vedioBean: VedioBean, tipList: Arra ...@@ -70,10 +69,6 @@ class VipCountDialog(val activity: Activity, vedioBean: VedioBean, tipList: Arra
fm.setOnClickListener { fm.setOnClickListener {
val bundle = Bundle()
bundle.putString(VipActivity.VEDIO_ID, vedioBean.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, vedioBean.thirdId)
readyGo(activity, VipActivity::class.java, bundle)
dismiss() dismiss()
} }
......
...@@ -28,8 +28,6 @@ import com.mints.helivideo.mvp.model.NineShowBean ...@@ -28,8 +28,6 @@ import com.mints.helivideo.mvp.model.NineShowBean
import com.mints.helivideo.mvp.model.VedioBean import com.mints.helivideo.mvp.model.VedioBean
import com.mints.helivideo.mvp.presenters.VideoPresenter import com.mints.helivideo.mvp.presenters.VideoPresenter
import com.mints.helivideo.mvp.views.VideoView import com.mints.helivideo.mvp.views.VideoView
import com.mints.helivideo.ui.activitys.NineActivity
import com.mints.helivideo.ui.activitys.VipActivity
import com.mints.helivideo.ui.activitys.base.BaseActivity import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.adapter.VideoEpisodeAdapter import com.mints.helivideo.ui.adapter.VideoEpisodeAdapter
import com.mints.helivideo.ui.widgets.DialogListener import com.mints.helivideo.ui.widgets.DialogListener
...@@ -214,10 +212,6 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -214,10 +212,6 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
finish() finish()
} }
vipBtn?.setOnClickListener { vipBtn?.setOnClickListener {
val bundle = Bundle()
bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId)
readyGo(VipActivity::class.java, bundle)
} }
} }
...@@ -693,7 +687,6 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic ...@@ -693,7 +687,6 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
} }
} }
R.id.ll_lucky -> { R.id.ll_lucky -> {
readyGo(NineActivity::class.java)
} }
else -> {} else -> {}
} }
......
...@@ -17,8 +17,6 @@ import com.mints.helivideo.mvp.model.* ...@@ -17,8 +17,6 @@ import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.model.IndexList.VedioEpisodeBean import com.mints.helivideo.mvp.model.IndexList.VedioEpisodeBean
import com.mints.helivideo.mvp.presenters.VideoPresenter import com.mints.helivideo.mvp.presenters.VideoPresenter
import com.mints.helivideo.mvp.views.VideoView import com.mints.helivideo.mvp.views.VideoView
import com.mints.helivideo.ui.activitys.NineActivity
import com.mints.helivideo.ui.activitys.VipActivity
import com.mints.helivideo.ui.activitys.base.BaseActivity import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.adapter.VideoEpisodeAdapter import com.mints.helivideo.ui.adapter.VideoEpisodeAdapter
import com.mints.helivideo.ui.widgets.DialogListener import com.mints.helivideo.ui.widgets.DialogListener
...@@ -155,7 +153,6 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -155,7 +153,6 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
showEpisodeDialog() showEpisodeDialog()
} }
R.id.ll_lucky -> { R.id.ll_lucky -> {
readyGo(NineActivity::class.java)
} }
else -> {} else -> {}
} }
...@@ -349,10 +346,6 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -349,10 +346,6 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
R.id.vip -> { R.id.vip -> {
// 开通VIP // 开通VIP
val bundle = Bundle()
bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId)
readyGo(VipActivity::class.java, bundle)
} }
else -> {} else -> {}
......
...@@ -16,8 +16,6 @@ import com.mints.helivideo.mvp.model.* ...@@ -16,8 +16,6 @@ import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.model.IndexList.VedioEpisodeBean import com.mints.helivideo.mvp.model.IndexList.VedioEpisodeBean
import com.mints.helivideo.mvp.presenters.VideoPresenter import com.mints.helivideo.mvp.presenters.VideoPresenter
import com.mints.helivideo.mvp.views.VideoView import com.mints.helivideo.mvp.views.VideoView
import com.mints.helivideo.ui.activitys.NineActivity
import com.mints.helivideo.ui.activitys.VipActivity
import com.mints.helivideo.ui.activitys.base.BaseActivity import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.adapter.VideoEpisodeAdapter import com.mints.helivideo.ui.adapter.VideoEpisodeAdapter
import com.mints.helivideo.ui.widgets.NewVideoEpisodeDialog import com.mints.helivideo.ui.widgets.NewVideoEpisodeDialog
...@@ -137,7 +135,6 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -137,7 +135,6 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
when (v?.id) { when (v?.id) {
R.id.close_iv -> finish() R.id.close_iv -> finish()
R.id.fm_bottom -> showEpisodeDialog() R.id.fm_bottom -> showEpisodeDialog()
R.id.ll_lucky -> readyGo(NineActivity::class.java)
else -> {} else -> {}
} }
} }
...@@ -323,11 +320,6 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView, ...@@ -323,11 +320,6 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
} }
R.id.vip -> { R.id.vip -> {
// 开通VIP // 开通VIP
val bundle = Bundle()
bundle.putString(VipActivity.VEDIO_ID, mVedioBean!!.vedioId.toString())
bundle.putString(VipActivity.THIRD_ID, mVedioBean!!.thirdId)
bundle.putBoolean(VipActivity.IS_RECOMMEND, true)
readyGo(VipActivity::class.java, bundle)
} }
else -> {} else -> {}
......
...@@ -24,7 +24,7 @@ public abstract class BaseSubscriber<T> extends Subscriber<T> { ...@@ -24,7 +24,7 @@ public abstract class BaseSubscriber<T> extends Subscriber<T> {
onError(CashException.handleException(e)); onError(CashException.handleException(e));
} else { } else {
Throwable throwable = new Throwable(e, CashException.ERROR.UNKNOWN); Throwable throwable = new Throwable(e, CashException.ERROR.UNKNOWN);
throwable.setMessage("Exceção do sistema, por favor saia do aplicativo e abra-o novamente"); throwable.setMessage("系统异常");
onError(throwable); onError(throwable);
} }
} }
......
...@@ -9,7 +9,7 @@ package com.mints.library.net.neterror; ...@@ -9,7 +9,7 @@ package com.mints.library.net.neterror;
public class FormatException extends RuntimeException { public class FormatException extends RuntimeException {
public int code = -200; public int code = -200;
public String message = "Formato de dados anormal devolvido pelo servidor"; public String message = "error";
public FormatException() { public FormatException() {
} }
......
/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 'androidx.core:core-ktx:1.3.2'
api 'androidx.appcompat:appcompat:1.2.0'
// implementation 'com.google.android.material:material:1.3.0'
// testImplementation 'junit:junit:4.+'
// androidTestImplementation 'androidx.test.ext:junit:1.1.2'
// androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
\ 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.rxpay">
</manifest>
\ No newline at end of file
package com.jobo.rxpay;
import android.app.Activity;
import com.jobo.rxpay.base.IPayInfo;
import com.jobo.rxpay.base.IPayStrategy;
import com.jobo.rxpay.callback.IPayCallback;
/**
* @Desc: 策略模式场景类。
* @author: admin wsj
* @Date: 2021/12/28 2:12 下午
* example : 实例化支付策略payway,以及支付订单信息,作为参数直接传入。
* 使用方法1:调用RxPay.pay()方法即可。
* 使用方法2:实例化payStrategy,直接调用其pay方法。如:new Alipay().pay(...)
*/
public class RxPay {
public static <T extends IPayInfo> void pay(IPayStrategy<T> payStrategy, Activity activity,
T payInfo, IPayCallback callback) {
payStrategy.pay(activity, payInfo, callback);
}
}
package com.jobo.rxpay.base;
import android.app.Activity;
import com.jobo.rxpay.callback.IPayCallback;
/**
* @Desc: 支付信息
* @author: admin wsj
* @Date: 2021/12/28 2:10 下午
*/
public interface IPayInfo{
}
package com.jobo.rxpay.base;
import android.app.Activity;
import com.jobo.rxpay.callback.IPayCallback;
/**
* @Desc: 统一支付接口。策略模式中统一算法接口。
* @author: admin wsj
* @Date: 2021/12/28 2:11 下午
*/
public interface IPayStrategy<T extends IPayInfo> {
void pay(Activity activity, T payInfo, IPayCallback callback);
}
package com.jobo.rxpay.base;
public class PayException extends Exception {
private int mCode;
public PayException(String message, int code) {
super(message);
mCode = code;
}
public int getCode() {
return mCode;
}
public void setCode(int code) {
mCode = code;
}
}
package com.jobo.rxpay.callback;
import androidx.annotation.Nullable;
public interface IPayCallback {
void success();
void failed(int code, @Nullable String message);
void cancel();
}
include ':app' include ':app'
include ':oaid' include ':oaid'
include ':rxpay' \ No newline at end of file
include ':alipay'
include ':wxpay'
/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 'androidx.core:core-ktx:1.3.2'
// implementation 'androidx.appcompat:appcompat:1.2.0'
// implementation 'com.google.android.material:material:1.3.0'
api 'com.tencent.mm.opensdk:wechat-sdk-android-with-mta:+'
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.wxpay">
<!-- Android11 tr30配置应用可见性-->
<!-- <queries>-->
<!-- <package android:name="com.eg.android.AlipayGphone" />-->
<!-- <package android:name="hk.alipay.wallet" />-->
<!-- </queries>-->
<!-- 指定微信包名-->
<queries>
<package android:name="com.tencent.mm" />
</queries>
<application android:allowBackup="false"
android:label="@string/app_name"
android:supportsRtl="true"
>
<activity
android:name="com.jobo.wxpay.activity.WXPayActivity"
android:launchMode="singleTop"
android:configChanges="orientation|locale|screenSize|layoutDirection|fontScale|screenLayout|keyboardHidden"
android:exported="true"
android:hardwareAccelerated="true"
android:theme="@android:style/Theme.Translucent.NoTitleBar" />
<activity-alias
android:name="${applicationId}.wxapi.WXPayEntryActivity"
android:exported="true"
android:targetActivity="com.jobo.wxpay.activity.WXPayActivity" />
</application>
</manifest>
\ No newline at end of file
package com.jobo.wxpay;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import java.util.HashMap;
public class WXErrCodeEx implements BaseResp.ErrCode {
private static final HashMap<Integer, String> sErrorMap = new HashMap<>();
public static final int CODE_UNSUPPORT = 1000;
public static final int CODE_ILLEGAL_ARGURE = 1001;
public static final String MESSAGE_UNSUPPORT = "未安装微信或者微信版本太低";
public static final String MESSAGE_ILLEGAL_ARGURE = "订单参数不合法";
static {
sErrorMap.put(CODE_UNSUPPORT, MESSAGE_UNSUPPORT);
sErrorMap.put(CODE_ILLEGAL_ARGURE, MESSAGE_ILLEGAL_ARGURE);
}
public static String getMessageByCode(int code) {
return sErrorMap.get(code);
}
}
/*
******************************* Copyright (c)*********************************\
**
** (c) Copyright 2017, King, china
** All Rights Reserved
**
** By(King)
**
**------------------------------------------------------------------------------
*/
package com.jobo.wxpay;
import android.app.Activity;
import android.content.Context;
import android.text.TextUtils;
import com.jobo.rxpay.base.IPayStrategy;
import com.jobo.rxpay.callback.IPayCallback;
import com.tencent.mm.opensdk.constants.Build;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.modelpay.PayReq;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
/**
* @Desc:
* @author: admin wsj
* @Date: 2021/12/28 2:54 下午
* @see <a href="https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=1417751808&token=&lang=zh_CN">Des</a>
*/
public class WXPay implements IPayStrategy<WXPayInfoImpl> {
private static WXPay mWXPay;
private WXPayInfoImpl payInfoImpli;
private static IPayCallback sPayCallback;
private IWXAPI mWXApi;
private boolean initializated;
private WXPay() {
}
public static WXPay getInstance(){
if(mWXPay == null){
synchronized (WXPay.class){
if(mWXPay == null) {
mWXPay = new WXPay();
}
}
}
return mWXPay;
}
public IWXAPI getWXApi() {
return mWXApi;
}
private void initWXApi(Context context, String appId) {
mWXApi = WXAPIFactory.createWXAPI(context.getApplicationContext(), appId);
mWXApi.registerApp(appId);
initializated = true;
}
@Override
public void pay(Activity activity, WXPayInfoImpl payInfo, IPayCallback payCallback) {
this.payInfoImpli = payInfo;
sPayCallback = payCallback;
if(payInfoImpli == null || TextUtils.isEmpty(payInfoImpli.getAppid()) || TextUtils.isEmpty(payInfoImpli.getPartnerid())
|| TextUtils.isEmpty(payInfoImpli.getPrepayId()) || TextUtils.isEmpty(payInfoImpli.getPackageValue()) ||
TextUtils.isEmpty(payInfoImpli.getNonceStr()) || TextUtils.isEmpty(payInfoImpli.getTimestamp()) ||
TextUtils.isEmpty(payInfoImpli.getSign())) {
if(payCallback != null) {
payCallback.failed(WXErrCodeEx.CODE_ILLEGAL_ARGURE, WXErrCodeEx.getMessageByCode(WXErrCodeEx.CODE_ILLEGAL_ARGURE));
}
return;
}
if (!initializated) {
initWXApi(activity.getApplicationContext(), payInfoImpli.getAppid());
}
if(!check()) {
if(payCallback != null) {
payCallback.failed(WXErrCodeEx.CODE_UNSUPPORT, WXErrCodeEx.getMessageByCode(WXErrCodeEx.CODE_UNSUPPORT));
}
return;
}
PayReq req = new PayReq();
req.appId = payInfoImpli.getAppid();
req.partnerId = payInfoImpli.getPartnerid();
req.prepayId = payInfoImpli.getPrepayId();
req.packageValue = payInfoImpli.getPackageValue();
req.nonceStr = payInfoImpli.getNonceStr();
req.timeStamp = payInfoImpli.getTimestamp();
req.sign = payInfoImpli.getSign();
mWXApi.sendReq(req);
}
/**
* 支付回调响应
*/
public void onResp(int errorCode, String errorMsg) {
if(sPayCallback == null) {
return;
}
if(errorCode == BaseResp.ErrCode.ERR_OK) {
sPayCallback.success();
} else if(errorCode == BaseResp.ErrCode.ERR_COMM) {
sPayCallback.failed(errorCode, errorMsg);
} else if(errorCode == BaseResp.ErrCode.ERR_USER_CANCEL) {
sPayCallback.cancel();
} else {
sPayCallback.failed(errorCode, errorMsg);
}
sPayCallback = null;
}
/**
* 检测是否支持微信支付
*/
private boolean check() {
return mWXApi.isWXAppInstalled() && mWXApi.getWXAppSupportAPI() >= Build.PAY_SUPPORTED_SDK_INT;
}
}
/*
******************************* Copyright (c)*********************************\
**
** (c) Copyright 2017, King, china
** All Rights Reserved
**
** By(King)
**
**------------------------------------------------------------------------------
*/
package com.jobo.wxpay;
import com.jobo.rxpay.base.IPayInfo;
/**
* @Desc:
* @author: admin wsj
* @Date: 2021/12/28 2:54 下午
*/
public class WXPayInfoImpl implements IPayInfo {
/**
* sign : ECE311C3DF76E009E6F37F05C350625F
* timestamp : 1474886901
* partnerid : 1391669502
* package : Sign=WXPay
* appid : wx46a24ab145becbde
* nonceStr : 0531a4a42fa846fe8a7563847cd24c2a
* prepayId : wx20160926184820acbd9357100240402425
*/
private String sign;
private String timestamp;
private String partnerid;
private String packageValue;
private String appid;
private String nonceStr;
private String prepayId;
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getTimestamp() {
return timestamp;
}
public void setTimestamp(String timestamp) {
this.timestamp = timestamp;
}
public String getPartnerid() {
return partnerid;
}
public void setPartnerid(String partnerid) {
this.partnerid = partnerid;
}
public String getPackageValue() {
return packageValue;
}
public void setPackageValue(String packageValue) {
this.packageValue = packageValue;
}
public String getAppid() {
return appid;
}
public void setAppid(String appid) {
this.appid = appid;
}
public String getNonceStr() {
return nonceStr;
}
public void setNonceStr(String nonceStr) {
this.nonceStr = nonceStr;
}
public String getPrepayId() {
return prepayId;
}
public void setPrepayId(String prepayId) {
this.prepayId = prepayId;
}
}
package com.jobo.wxpay.activity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import com.jobo.wxpay.WXPay;
import com.tencent.mm.opensdk.constants.ConstantsAPI;
import com.tencent.mm.opensdk.modelbase.BaseReq;
import com.tencent.mm.opensdk.modelbase.BaseResp;
import com.tencent.mm.opensdk.openapi.IWXAPIEventHandler;
/**
* @Desc: 在调用方项目的 包名.wxapi.WXPayEntryActivity类直接继续本类,并在AndroidManifest.xml中声明即可。
* @author: admin wsj
* @Date: 2021/12/28 2:54 下午
*/
public class WXPayActivity extends Activity implements IWXAPIEventHandler {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WXPay.getInstance().getWXApi().handleIntent(getIntent(), this);
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
WXPay.getInstance().getWXApi().handleIntent(intent, this);
}
@Override
public void onReq(BaseReq baseReq) {
}
@Override
public void onResp(BaseResp baseResp) {
if (baseResp.getType() == ConstantsAPI.COMMAND_PAY_BY_WX) {
WXPay.getInstance().onResp(baseResp.errCode, baseResp.errStr);
finish();
}
}
}
\ No newline at end of file
<resources>
<string name="app_name">wxpay</string>
</resources>
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