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 {
implementation 'androidx.work:work-runtime-ktx:2.7.1'
// 三方接入
// 支付
api project(':rxpay')
api project(':wxpay')
api project(':alipay')
api project(':oaid')
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'
// bugly
......
......@@ -125,10 +125,6 @@
android:name=".ui.activitys.FeedbackActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.VipActivity"
android:exported="false"
android:screenOrientation="portrait" />
<activity
android:name=".ui.activitys.SettingsActivity"
android:exported="false"
......@@ -137,40 +133,12 @@
android:name=".ui.activitys.AboutusActivity"
android:exported="false"
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
android:name=".ui.activitys.RecommendActivity"
android:exported="false"
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
android:name=".video.csj.DramaApiDetailActivity"
android:exported="false"
......
......@@ -209,18 +209,10 @@ class DeviceInfo private constructor() {
imei =
(MintsApplication.getContext()
.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager).deviceId
} catch (e: Exception) {
try {
imei = Settings.Secure.getString(
MintsApplication.getContext().contentResolver,
Settings.Secure.ANDROID_ID
)
} catch (e: Exception) {
imei = ""
e.printStackTrace()
}
e.printStackTrace()
}
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() {
if (TextUtils.isEmpty(UserManager.getInstance().userID)) {
readyGoThenKill(MainActivity::class.java)
} 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)
......
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.app.Dialog
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.text.TextUtils
import android.view.View
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.mints.helivideo.R
import com.mints.helivideo.ad.AdManager
import com.mints.helivideo.ad.AdStatusListener
import com.mints.helivideo.ad.NoPreAdManager
import com.mints.helivideo.common.Constant
import com.mints.helivideo.mvp.model.NineListBean
import com.mints.helivideo.mvp.model.NineShowBean
import com.mints.helivideo.mvp.presenters.NinePresenter
import com.mints.helivideo.mvp.views.NineView
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.widgets.DialogListener
import com.mints.helivideo.ui.widgets.NineContinueDialog
import com.mints.helivideo.utils.AppPreferencesManager
import com.mints.helivideo.utils.SplitArrayUtils
import com.mints.helivideo.utils.rxutil.CommonRxTask
import com.mints.helivideo.utils.rxutil.RxjavaUtil
import com.mints.library.utils.nodoubleclick.AntiShake
import kotlinx.android.synthetic.main.activity_nine.*
/**
* 描述:9宫格手机
* 作者:孟崔广
*/
class NineActivity : BaseActivity(), View.OnClickListener, NineView {
companion object {
val IS_AD_SHOW = "IS_AD_SHOW"
}
private val ninePresenter by lazy { NinePresenter() }
private var yoyo: YoYo.YoYoString? = null
val luckyIndexMap: MutableMap<Int, String> = HashMap()
private var nineShowBean: NineShowBean? = null
var carrierType = Constant.CARRIERTYPE_NINE
var isAdShow = false
override fun getContentViewLayoutID() = R.layout.activity_nine
override fun isApplyKitKatTranslucency() = false
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.SCALE
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
isAdShow = it.getBoolean(IS_AD_SHOW, false)
}
}
override fun initViewsAndEvents() {
ninePresenter.attachView(this)
ninePresenter.getTurnIphoneMsg()
initData()
initListener()
btn_action?.postDelayed({
yoyo = YoYo.with(Techniques.Pulse).duration(1000).repeat(-1).playOn(btn_action)
}, 200)
}
override fun onResume() {
super.onResume()
ninePresenter.showTurn()
}
override fun onDestroy() {
super.onDestroy()
marqueeView?.startFlipping()
ninePresenter.detachView()
yoyo?.stop()
yoyo = null
}
private fun initListener() {
btn_action.setOnClickListener(this)
rl_lucky.setOnClickListener(this)
iv_nine_back.setOnClickListener(this)
}
override fun finish() {
super.finish()
overridePendingTransition(0, R.anim.scale_out)
}
override fun onClick(v: View) {
if (AntiShake.check(v.id)) return
when (v.id) {
R.id.iv_nine_back -> {
finish()
}
R.id.btn_action, R.id.rl_lucky -> {
if (luckyIndexMap.size == 0) {
showToast("界面初始异常,请重新进入")
return
}
if (isAdShow) {
luckyAward()
} else {
if (nineShowBean != null) {
if (nineShowBean!!.complete >= nineShowBean!!.need) {
luckyAward()
} else {
val bundle = Bundle()
bundle.putInt(NineKnowActivity.COMPLETE, nineShowBean!!.complete)
bundle.putInt(NineKnowActivity.NEED, nineShowBean!!.need)
readyGoThenKill(NineKnowActivity::class.java, bundle)
}
}
}
}
}
}
override fun unlockSuc() {
ninePresenter.showTurn()
if (isAdShow) {
if (nineShowBean != null) {
if (nineShowBean!!.need - nineShowBean!!.complete-1>0) {
showContinueDialog()
}
}
}
}
override fun getTurnIphoneMsgSuc(data: NineListBean) {
lucky_panel2.setImgArray(data.list)
initLuckyIndexForPid(data.list)
if (TextUtils.isEmpty(data.rule)) {
ll_nine_rule.visibility = View.GONE
} else {
ll_nine_rule.visibility = View.VISIBLE
tv_nine_rule.text = data.rule
}
}
private fun initLuckyIndexForPid(list: List<NineListBean.NineBean>) {
if (list != null && list.size > 0) {
for (i in 0 until list.size) {
luckyIndexMap.put(i, list.get(i).pid ?: i.toString())
}
}
}
override fun toTurnSuc(data: NineListBean.NineBean) {
Handler(Looper.getMainLooper()).postDelayed({
startNine(data)
}, 500)
}
override fun showTurnSuc(data: NineShowBean) {
nineShowBean = data
if (TextUtils.equals(
carrierType,
Constant.CARRIERTYPE_NINE3
) && data.complete >= data.need
) {
carrierType = Constant.CARRIERTYPE_NINE
ninePresenter.toTurn()
}
// 展示 5/20
if (isAdShow) {
tv_nine_count.visibility = View.VISIBLE
tv_nine_count.text = "${data.complete}/${data.need}次"
btn_action.setBackgroundResource(R.mipmap.ic_luckly_btn)
} else {
btn_action.setBackgroundResource(R.mipmap.ic_lucky_vedio)
tv_nine_count.visibility = View.GONE
}
}
private fun luckyAward() {
if (nineShowBean != null) {
if (nineShowBean!!.complete >= nineShowBean!!.need) {
carrierType = Constant.CARRIERTYPE_NINE3
}
}
AdManager.instance.showAd(this, carrierType,
object : AdStatusListener {
var canFail = false
override fun adSuccess() {
canFail = true
}
override fun adFail() {
if (canFail) return
NoPreAdManager.loadVideoAd(
this@NineActivity,
carrierType, object : AdStatusListener {
override fun adFail() {
carrierType = Constant.CARRIERTYPE_NINE
showToast("广告太火爆了,请稍候再试")
}
override fun adSuccess() {
}
override fun adClose(vo: HashMap<String, Any>?) {
vo?.let {
ninePresenter.unlock(vo)
}
}
})
}
override fun adClose(vo: HashMap<String, Any>?) {
vo?.let {
ninePresenter.unlock(vo)
}
}
})
}
fun startNine(data: NineListBean.NineBean) {
if (data.pid == null) {
showToast("产品未配置")
return
}
if (!lucky_panel2.isGameRunning) {
lucky_panel2.startGame()
RxjavaUtil.executeRxTask(object : CommonRxTask<String>("") {
override fun doInIOThread() {
Thread.sleep(3000)
}
override fun doInUIThread() {
if (this@NineActivity.isFinishing) {
return
}
val index = getLuckyIndex(data.pid)
lucky_panel2.tryToStop(index)
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)
readyGoThenKill(NinePayActivity::class.java, bundle)
}, 1500)
}
})
}
}
private fun getLuckyIndex(pid: String): Int {
if (luckyIndexMap.size > 0) {
for ((key, value) in luckyIndexMap) {
if (TextUtils.equals(pid, value)) {
return key
}
}
}
return 0
}
private fun initData() {
val messages = ArrayList<String>()
messages.add("恭喜用户183******66抽中 终身会员")
messages.add("恭喜用户177******34抽中 +1年会员")
messages.add("恭喜用户134******49抽中 +14天会员")
messages.add("恭喜用户159******51抽中 +3天会员")
messages.add("恭喜用户150******87抽中 +7天会员")
messages.add("恭喜用户134******65抽中 +5天会员")
messages.add("恭喜用户183******40抽中 +30天会员")
messages.add("恭喜用户131******08抽中 +7天会员")
messages.add("恭喜用户177******65抽中 +1年会员")
messages.add("恭喜用户180******39抽中 +3天会员")
messages.add("恭喜用户150******43抽中 +14天会员")
messages.add("恭喜用户152******05抽中 终身会员")
messages.add("恭喜用户133******87抽中 +7天会员")
messages.add("恭喜用户151******64抽中 +14天会员")
marqueeView.startWithList(SplitArrayUtils.getRandomList(messages) as List<Nothing>?)
}
// 继续观看逻辑
private fun showContinueDialog() {
nineShowBean?.let {
NineContinueDialog(
this@NineActivity,
it.need - it.complete - 1,
object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
super.onClick(dialog, v)
dialog?.dismiss()
luckyAward()
}
}).show()
}
}
}
\ 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 {
}
}
R.id.item_back -> {
readyGo(Backcash2Activity::class.java)
}
}
}
......
package com.mints.helivideo.ui.activitys
import android.app.Dialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.text.TextUtils
import android.view.KeyEvent
import android.view.View
import android.widget.CompoundButton
import androidx.recyclerview.widget.GridLayoutManager
import com.airbnb.lottie.LottieComposition
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
import com.jobo.wxpay.WXPayInfoImpl
import com.mints.helivideo.BuildConfig
import com.mints.helivideo.R
import com.mints.helivideo.common.AppConfig
import com.mints.helivideo.common.Constant
import com.mints.helivideo.manager.UserManager
import com.mints.helivideo.mvp.model.VipBean
import com.mints.helivideo.mvp.model.WxPayParamBean
import com.mints.helivideo.mvp.presenters.VipPresenter
import com.mints.helivideo.mvp.views.VipView
import com.mints.helivideo.ui.activitys.base.BaseActivity
import com.mints.helivideo.ui.adapter.VipAdapter
import com.mints.helivideo.ui.widgets.*
import com.mints.library.utils.nodoubleclick.AntiShake
import com.mints.helivideo.utils.AppPreferencesManager
import kotlinx.android.synthetic.main.activity_vip.*
import kotlinx.android.synthetic.main.header_layout.*
/**
* 描述:支付
* 作者:孟崔广
* 时间:2022/12/22 14:48
*/
class VipActivity : BaseActivity(), VipView, View.OnClickListener, VipAdapter.OnItemClickListener,
CompoundButton.OnCheckedChangeListener {
companion object {
const val IS_GUIDE = "IS_GUIDE"//是否从引导页进入
const val IS_MAIN = "IS_MAIN"//是否从首页进入
const val IS_RECOMMEND = "IS_RECOMMEND"//是否从推荐页进入
const val wxAppId = BuildConfig.WEIXIN_APP_PAY_ID
const val WEIXIN_PAY = "WEIXIN_PAY"
const val ALIPAY = "ALIPAY"
const val THIRD_ID = "THIRD_ID"
const val VEDIO_ID = "VEDIO_ID"
}
private var breathAnim: YoYo.YoYoString? = null
private var payAgreementDialog: PayAgreementDialog? = null
private var payYesDialog: PayYesDialog? = null
private var ruleAgreementDialog: RuleAgreementDialog? = null
private val vipPresenter by lazy { VipPresenter() }
private lateinit var vipAdapter: VipAdapter
private var vipList: MutableList<VipBean.ListBean>? = null
private var isCheckAgreeFlag: Boolean = true
private var isGuide: Boolean = false// 从启动页进入vip界面,返回时要回到首页
private var isMain: Boolean = false
private var isRecommend: Boolean = false
private var payType = ALIPAY// 支付类型
private var vedioId = ""
private var thirdId = ""
override fun getContentViewLayoutID() = R.layout.activity_vip
override fun toggleOverridePendingTransition() = true
override fun getOverridePendingTransitionMode() = TransitionMode.BOTTOM
override fun isApplyKitKatTranslucency() = false
override fun getBundleExtras(extras: Bundle?) {
super.getBundleExtras(extras)
extras?.let {
isGuide = it.getBoolean(IS_GUIDE, false)
isMain = it.getBoolean(IS_MAIN, false)
isRecommend = it.getBoolean(IS_RECOMMEND, false)
thirdId = it.getString(THIRD_ID, "")
vedioId = it.getString(VEDIO_ID, "")
}
}
override fun initViewsAndEvents() {
vipPresenter.attachView(this)
if (!TextUtils.isEmpty(UserManager.getInstance().userID)) {
vipPresenter.getVipProducts(isAliPayInstalled())
} else {
vipPresenter.userLogin(isAliPayInstalled())
}
AppConfig.enterVipAct = true
initListener()
}
override fun finish() {
super.finish()
//关闭窗体动画显示
overridePendingTransition(0, R.anim.push_bottom_out)
}
override fun onDestroy() {
super.onDestroy()
if (!isMain) {
AppConfig.enterVipAct = false
}
breathAnim?.stop()
vipPresenter.detachView()
}
override fun getVipProductSuc(data: VipBean) {
if (!isFinishing) {
if (data.list != null && data.list.size > 0) {
vipList = data.list
//设置content样式
if (vipList != null && vipList!!.size > 0) {
setVipContent(vipList!![0])
if (data.isNeedClick) {
cbVipAgreement.isChecked = true
} else {
cbVipAgreement.isChecked = false
}
}
initRvView()
}
}
}
/**
* 设置content样式
*/
private fun setVipContent(bean: VipBean.ListBean) {
if (bean.isAlipay && bean.isWeixin) {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.VISIBLE
} else if (bean.isAlipay && !bean.isWeixin) {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
} else if (!bean.isAlipay && bean.isWeixin) {
ll_vip_alipay.visibility = View.GONE
ll_vip_wx.visibility = View.VISIBLE
payType = WEIXIN_PAY
iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
}
if (!TextUtils.isEmpty(bean.remarks)) {
tv_vip_hint.text = bean.remarks
tv_vip_hint.visibility = View.VISIBLE
} else {
tv_vip_hint.visibility = View.INVISIBLE
}
if (!TextUtils.isEmpty(bean.buttonText)) {
tvVipPay.text = bean.buttonText
tvVipAgreement.text = "点击购买即表示您同意《自动续费协议》"
} else {
tvVipPay.text = "立即开通"
tvVipAgreement.text = "点击购买即表示您同意《会员付费协议》"
}
}
override fun getVipPayParamsSuc(payChannel: String, paramsBean: WxPayParamBean) {
if (!isFinishing) {
if (TextUtils.equals(payChannel, "WEIXIN")) {
if (paramsBean.params == null) {
showToast("微信支付维护中")
return
}
wxPay(paramsBean)
} else {
if (paramsBean.params == null) {
showToast("支付宝支付维护中")
return
}
alipay(paramsBean)
}
}
}
override fun queryVipOrderSuc(isPay: Boolean) {
if (isFinishing) return
if (isPay) {
showToast("支付成功")
if (isRecommend) {
finish()
} else {
if (!UserManager.getInstance().userIsLogin()) {
val b = Bundle()
b.putString(MobileLoginActivity.TYPE, "vip")
readyGoThenKill(MobileLoginActivity::class.java, b)
} else {
readyGoThenKill(MainActivity::class.java)
}
}
}
}
override fun onKeyDown(keyCode: Int, event: KeyEvent?): Boolean {
when (keyCode) {
KeyEvent.KEYCODE_BACK -> {
if (UserManager.getInstance().newFlag
&& vipList != null && vipList!!.size > 0
) {
vipAdapter.setPosition(0)
vipAdapter.notifyDataSetChanged()
val vipBean = vipList!![0]
if (vipBean.trial == 1) {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
}
backPayYesDialog(vipBean)
return true
}
if (isGuide) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
}
return true
}
override fun onClick(v: View?) {
if (AntiShake.check(v?.id)) return
when (v?.id) {
R.id.ic_vip_quit -> {
if (UserManager.getInstance().newFlag &&
vipList != null && vipList!!.size > 0
) {
vipAdapter.setPosition(0)
vipAdapter.notifyDataSetChanged()
val vipBean = vipList!![0]
if (vipBean.trial == 1) {
ll_vip_alipay.visibility = View.VISIBLE
ll_vip_wx.visibility = View.GONE
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
}
backPayYesDialog(vipBean)
} else {
if (isGuide) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
}
R.id.tvVipPay -> {
if (vipList != null && vipList!!.size > 0) {
val vipBean = vipList!![vipAdapter.getPosition()]
if (!isCheckAgreeFlag) {
vipAgreementDialog(vipBean)
return
}
if (vipBean.isShowCycTips) {
agreementPayDialog()
} else {
if (TextUtils.equals(payType, WEIXIN_PAY)) {
vipPresenter.getVipPayParams(
"WEIXIN",
vipBean.pid, isAliPayInstalled()
)
} else if (TextUtils.equals(payType, ALIPAY)) {
vipPresenter.getVipPayParams(
"ALIPAY",
vipBean.pid, isAliPayInstalled()
)
}
}
} else {
showToast("产品未配置")
}
}
R.id.tvVipAgreement -> {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.members_name))
bundle.putString(WebActivity.WEB_URL, Constant.MEMBERS_URL)
readyGo(WebActivity::class.java, bundle)
}
R.id.ll_vip_alipay -> {
payType = ALIPAY
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_wx.setImageResource(R.mipmap.ic_vip_none)
}
R.id.ll_vip_wx -> {
payType = WEIXIN_PAY
iv_vip_wx.setImageResource(R.mipmap.ic_vip_enable_blue)
iv_vip_alipay.setImageResource(R.mipmap.ic_vip_none)
}
}
}
private fun initRvView() {
if (vipList != null && vipList!!.size > 0) {
val gridLayoutManager = GridLayoutManager(this, 3)
rvVip.layoutManager = gridLayoutManager
vipAdapter = VipAdapter(vipList!!)
rvVip.adapter = vipAdapter
vipAdapter.setOnItemClickListener(this)
}
}
private fun initListener() {
val lottieDrawable = LottieDrawable()
LottieCompositionFactory.fromAsset(context, "choose_pay.json")
.addListener { result: LottieComposition? ->
lottieDrawable.setImagesAssetsFolder("images/")
lottieDrawable.composition = result
lottieDrawable.loop(true)
lottieDrawable.playAnimation()
}
ic_vip_top.setImageDrawable(lottieDrawable)
shimmer_text?.postDelayed({
shimmer_text?.startShimmerAnimation()
breathAnim =
YoYo.with(Techniques.Pulse).duration(700).repeat(-1).playOn(shimmer_text)
}, 200)
ic_vip_quit.setOnClickListener(this)
tvVipPay.setOnClickListener(this)
tvVipAgreement.setOnClickListener(this)
ll_vip_alipay.setOnClickListener(this)
ll_vip_wx.setOnClickListener(this)
cbVipAgreement.setOnCheckedChangeListener(this)
}
override fun onItemClick(position: Int) {
vipAdapter.setPosition(position)
vipAdapter.notifyDataSetChanged()
//设置content样式
if (vipList != null && vipList!!.size > 0) {
setVipContent(vipList!![position])
}
}
fun wxPay(wxParanBean: WxPayParamBean) {
val data = wxParanBean.params
//实例化微信支付策略
val wxPay: WXPay = WXPay.getInstance()
//构造微信订单实体。一般都是由服务端直接返回。
val wxPayInfoImpl = WXPayInfoImpl()
wxPayInfoImpl.timestamp = data.timestamp
wxPayInfoImpl.sign = data.sign
wxPayInfoImpl.prepayId = data.prepayid
wxPayInfoImpl.partnerid = data.partnerid
wxPayInfoImpl.appid = wxAppId
wxPayInfoImpl.nonceStr = data.noncestr
wxPayInfoImpl.packageValue = data.packageX
//策略场景类调起支付方法开始支付,以及接收回调。
RxPay.pay(wxPay, this, wxPayInfoImpl, object : IPayCallback {
override fun success() {
UserManager.getInstance().vipFlag = true
vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), true)
}
override fun failed(code: Int, message: String?) {
vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), false)
}
override fun cancel() {
vipPresenter?.queryVipOrder(wxParanBean.tid.toString(), false)
}
})
}
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
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)
}
})
}
/**
* 检测是否安装支付宝
*
* true-安装支付宝
*/
fun isAliPayInstalled(): Boolean {
try {
val uri: Uri = Uri.parse("alipays://platformapi/startApp")
val intent = Intent(Intent.ACTION_VIEW, uri)
val componentName = intent.resolveActivity(context.getPackageManager())
return componentName != null
} catch (e: Exception) {
e.printStackTrace()
return false
}
}
/**
* 自动续费
*/
fun openAutoAlipay(url: String) {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
startActivity(intent)
}
override fun onCheckedChanged(buttonView: CompoundButton?, isChecked: Boolean) {
isCheckAgreeFlag = isChecked
}
/**
* 返回支付弹窗-签约
*/
private fun backPayYesDialog(vipBean: VipBean.ListBean) {
payYesDialog = PayYesDialog(context, vipBean, object : DialogListener() {
override fun onClick(v: View) {
if (!isFinishing() && payYesDialog != null && payYesDialog!!.isShowing()) {
payYesDialog!!.dismiss()
}
when (v.id) {
R.id.iv_dialog_vip_quit -> {
if (isGuide) {
readyGoThenKill(MainActivity::class.java)
} else {
finish()
}
}
R.id.tv_dialog_vip_next -> {
cbVipAgreement.isChecked = true
if (vipList != null && vipList!!.size > 0) {
val vipBean = vipList!![vipAdapter.getPosition()]
if (TextUtils.equals(payType, WEIXIN_PAY)) {
vipPresenter.getVipPayParams(
"WEIXIN",
vipBean.pid, isAliPayInstalled()
)
} else if (TextUtils.equals(payType, ALIPAY)) {
vipPresenter.getVipPayParams(
"ALIPAY",
vipBean.pid, isAliPayInstalled()
)
}
} else {
showToast("产品未配置")
}
}
}
}
})
payYesDialog!!.show()
}
/**
* 自动续费协议弹窗-支付宝
*/
private fun agreementPayDialog() {
payAgreementDialog = PayAgreementDialog(context, object : DialogListener() {
override fun onClick(v: View) {
if (!isFinishing() && payAgreementDialog != null && payAgreementDialog!!.isShowing()) {
payAgreementDialog!!.dismiss()
}
when (v.id) {
R.id.tv_agreement_next -> {
ruleAgreementPayDialog()
}
}
}
})
payAgreementDialog!!.show()
}
/**
* 试用订阅规则说明-仿支付宝
*/
private fun ruleAgreementPayDialog() {
if (vipList != null && vipList!!.size > 0) {
val vipBean = vipList!![vipAdapter.getPosition()]
ruleAgreementDialog = RuleAgreementDialog(context, object : DialogListener() {
override fun onClick(v: View) {
if (!isFinishing() && ruleAgreementDialog != null && ruleAgreementDialog!!.isShowing()) {
ruleAgreementDialog!!.dismiss()
}
when (v.id) {
R.id.tv_agreement_next -> {
if (TextUtils.equals(payType, WEIXIN_PAY)) {
vipPresenter.getVipPayParams(
"WEIXIN",
vipBean.pid, isAliPayInstalled()
)
} else if (TextUtils.equals(payType, ALIPAY)) {
vipPresenter.getVipPayParams(
"ALIPAY",
vipBean.pid, isAliPayInstalled()
)
}
}
}
}
})
ruleAgreementDialog!!.setText(
vipBean.remarks,
vipBean.trialFirstDay,
vipBean.price,
vipBean.title
)
ruleAgreementDialog!!.show()
} else {
showToast("产品未配置")
}
}
/**
* 未勾选协议弹窗
*/
private fun vipAgreementDialog(bean: VipBean.ListBean) {
var agreeStr = "会员付费协议"
if (bean.isShowCycTips) {
agreeStr = "自动续费协议"
}
val cdaa = CustomDialogAgreement(context, object : DialogListener() {
override fun onClick(dialog: Dialog?, v: View?) {
dialog?.dismiss()
when (v?.id) {
R.id.dialog_btn_right -> {
cbVipAgreement.isChecked = true
if (vipList != null && vipList!!.size > 0) {
val vipBean = vipList!![vipAdapter.getPosition()]
if (vipBean.isShowCycTips) {
agreementPayDialog()
} else {
if (TextUtils.equals(payType, WEIXIN_PAY)) {
vipPresenter.getVipPayParams(
"WEIXIN",
vipBean.pid, isAliPayInstalled()
)
} else if (TextUtils.equals(payType, ALIPAY)) {
vipPresenter.getVipPayParams(
"ALIPAY",
vipBean.pid, isAliPayInstalled()
)
}
}
} else {
showToast("产品未配置")
}
}
}
}
})
cdaa.setTitle(agreeStr)
cdaa.setContent(agreeStr)
cdaa.setLeft("不同意")
cdaa.setLeftColor(R.color.gray)
cdaa.setRight("同意")
cdaa.setRightColor(R.color.main_mints)
cdaa.show()
}
}
\ No newline at end of file
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
import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.presenters.HomePresenter
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.VipActivity
import com.mints.helivideo.ui.adapter.HomeVideoPageAdapter
import com.mints.helivideo.ui.adapter.ImageTitleAdapter
import com.mints.helivideo.ui.adapter.TopAdapter
......@@ -95,9 +92,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
homePresenter.getRecommendVedio()
val bundle = Bundle()
bundle.putBoolean(VipActivity.IS_MAIN, true)
readyGo(VipActivity::class.java, bundle)
}
} else {
homePresenter.getSoltVedio()
......@@ -163,7 +157,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
}
R.id.ll_lucky -> {
readyGo(NineActivity::class.java)
}
}
}
......@@ -304,10 +297,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
.setOnBannerListener { data2, position ->
val banner = data.list.get(position)
if (banner.createType == 4) {
// 九宫格
val bundle = Bundle()
bundle.putBoolean(NineActivity.IS_AD_SHOW, true)
readyGo(NineActivity::class.java, bundle)
} else {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
......@@ -335,9 +324,6 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
if (UserManager.getInstance().newFlag && !UserManager.getInstance().vipFlag) {
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 {
when (v?.id) {
R.id.tv_my_btn -> {
if (!userManager.vipFlag) {
readyGo(VipActivity::class.java)
}
}
R.id.ll_my_setting -> {
readyGo(SettingsActivity::class.java)
......@@ -135,7 +132,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
(requireActivity() as MainActivity).backPhoneDialog()
}
R.id.ll_my_payrecord -> {
readyGo(OrderRecordActivity::class.java)
}
R.id.btn_action,R.id.rl_lucky -> {
clickTurn()
......@@ -331,11 +327,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
lucky_panel.tryToStop(index)
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)
}
})
......@@ -368,10 +359,6 @@ class MyFragment : LazyLoadBaseFragment(), MyView, View.OnClickListener {
if (!luckyFirst) {
isTurnLuckyPage=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
}
}
......
......@@ -14,7 +14,6 @@ import com.mints.helivideo.R
import com.mints.helivideo.ad.express.ExpressAdCallback
import com.mints.helivideo.ad.express.ExpressManager
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.OnCountDownTimerListener
import com.mints.helivideo.utils.UIUtils
......@@ -70,10 +69,6 @@ class VipCountDialog(val activity: Activity, vedioBean: VedioBean, tipList: Arra
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()
}
......
......@@ -28,8 +28,6 @@ import com.mints.helivideo.mvp.model.NineShowBean
import com.mints.helivideo.mvp.model.VedioBean
import com.mints.helivideo.mvp.presenters.VideoPresenter
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.adapter.VideoEpisodeAdapter
import com.mints.helivideo.ui.widgets.DialogListener
......@@ -214,10 +212,6 @@ class DramaApiDetailActivity : BaseActivity(), VideoEpisodeAdapter.OnEpisodeClic
finish()
}
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
}
}
R.id.ll_lucky -> {
readyGo(NineActivity::class.java)
}
else -> {}
}
......
......@@ -17,8 +17,6 @@ import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.model.IndexList.VedioEpisodeBean
import com.mints.helivideo.mvp.presenters.VideoPresenter
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.adapter.VideoEpisodeAdapter
import com.mints.helivideo.ui.widgets.DialogListener
......@@ -155,7 +153,6 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
showEpisodeDialog()
}
R.id.ll_lucky -> {
readyGo(NineActivity::class.java)
}
else -> {}
}
......@@ -349,10 +346,6 @@ class TxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
R.id.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 -> {}
......
......@@ -16,8 +16,6 @@ import com.mints.helivideo.mvp.model.*
import com.mints.helivideo.mvp.model.IndexList.VedioEpisodeBean
import com.mints.helivideo.mvp.presenters.VideoPresenter
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.adapter.VideoEpisodeAdapter
import com.mints.helivideo.ui.widgets.NewVideoEpisodeDialog
......@@ -137,7 +135,6 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
when (v?.id) {
R.id.close_iv -> finish()
R.id.fm_bottom -> showEpisodeDialog()
R.id.ll_lucky -> readyGo(NineActivity::class.java)
else -> {}
}
}
......@@ -323,11 +320,6 @@ class NewTxVideoActivity : BaseActivity(), View.OnClickListener, VideoView,
}
R.id.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 -> {}
......
......@@ -24,7 +24,7 @@ public abstract class BaseSubscriber<T> extends Subscriber<T> {
onError(CashException.handleException(e));
} else {
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);
}
}
......
......@@ -9,7 +9,7 @@ package com.mints.library.net.neterror;
public class FormatException extends RuntimeException {
public int code = -200;
public String message = "Formato de dados anormal devolvido pelo servidor";
public String message = "error";
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 ':oaid'
\ No newline at end of file
include ':rxpay'
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