parent
96961cadff
commit
dd2e226def
|
|
@ -11,6 +11,7 @@ import android.os.Build
|
|||
import android.os.Bundle
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.core.net.toUri
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
|
|
@ -56,6 +57,7 @@ import com.yingmao.clash.view.RxToast
|
|||
import com.yingmao.clash.view.dialog.DialogDoMainChoose
|
||||
import com.yingmao.clash.view.dialog.RxDialogShapeLoading
|
||||
import com.yingmao.clash.vm.MainAtyVM
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
|
|
@ -210,7 +212,41 @@ class MemberRechargeActivity : BaseActivity() {
|
|||
RxToast.error(if (rsp.message.isNullOrBlank()) resources.getString(R.string.OrderGenerationFailed) + "(${rsp.code})" else "${rsp.code}:${rsp.message}")
|
||||
} else {
|
||||
if (rsp.data != null) {
|
||||
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse(rsp.data.payUrl)))
|
||||
when (rsp.data.payModel) {
|
||||
1000 -> {
|
||||
val orderInfo = rsp.data.appFormat
|
||||
CoroutineScope(Dispatchers.IO).launch {
|
||||
val alipay = PayTask(this@MemberRechargeActivity)
|
||||
val result = alipay.payV2(orderInfo, true)
|
||||
android.util.Log.i("payResult", "result::$result")
|
||||
launch(Dispatchers.Main) {
|
||||
val resultStatus = result["resultStatus"]
|
||||
val memo = result["memo"]
|
||||
if (resultStatus == "9000") {
|
||||
MaterialDialog(this@MemberRechargeActivity).show {
|
||||
this.cancelable(true)
|
||||
cornerRadius(res = R.dimen.dp_15)
|
||||
customView(
|
||||
R.layout.pay_sure_dialog_layout,
|
||||
scrollable = false,
|
||||
noVerticalPadding = true,
|
||||
horizontalPadding = false
|
||||
)
|
||||
val tvSure = findViewById<TextView>(R.id.tvSure)
|
||||
tvSure.setOnClickListener {
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
} else {
|
||||
RxToast.info(resources.getString(R.string.PayError)+memo)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
0->{
|
||||
startActivity(Intent(Intent.ACTION_VIEW, rsp.data.payUrl?.toUri()))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,9 +42,7 @@ import com.yingmao.clash.listener.AsyncCallBackListener
|
|||
import com.yingmao.clash.net.http.HttpReqType
|
||||
import com.yingmao.clash.net.http.HttpStatus
|
||||
import com.yingmao.clash.net.http.entity.AppStartupStatus
|
||||
import com.yingmao.clash.service.ConnectionService
|
||||
import com.yingmao.clash.util.ActivityResultLifecycle
|
||||
import com.yingmao.clash.util.CommonUtils
|
||||
import com.yingmao.clash.util.Utils
|
||||
import com.yingmao.clash.util.startClashService
|
||||
import com.yingmao.clash.util.stopClashService
|
||||
|
|
@ -714,16 +712,6 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
|
|||
}
|
||||
}
|
||||
}
|
||||
private val resultReceiver: ResultReceiver = object : ResultReceiver(null) {
|
||||
override fun onReceiveResult(resultCode: Int, resultData: Bundle) {
|
||||
val data = resultData.getString("data")
|
||||
Log.d("ping to from Service: $data")
|
||||
if(connectId!=-1){
|
||||
Log.d("activity connectId: $connectId")
|
||||
accelerateViewModel.appUpStatus(connectId)
|
||||
}
|
||||
}
|
||||
}
|
||||
override fun httpLoading(httpStatus: HttpStatus.Loading) {
|
||||
|
||||
}
|
||||
|
|
@ -735,16 +723,11 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
|
|||
if(dataInfo.data!=null){
|
||||
if(dataInfo.data.id!=null){
|
||||
connectId= dataInfo.data.id
|
||||
val serviceIntent= Intent(requireContext(), ConnectionService::class.java)
|
||||
serviceIntent.putExtra("receiver",resultReceiver)
|
||||
requireContext().startService(serviceIntent)
|
||||
}
|
||||
}
|
||||
}
|
||||
HttpReqType.AppStopStatus ->{
|
||||
Log.d("AppStopStatus is Success ${httpStatus.rsp}")
|
||||
val serviceIntent= Intent(requireContext(), ConnectionService::class.java)
|
||||
requireContext().stopService(serviceIntent)
|
||||
}
|
||||
else->{
|
||||
|
||||
|
|
@ -781,15 +764,6 @@ class NewAccFragment : BaseFragment(), CoroutineScope by CoroutineScope(Dispatch
|
|||
}
|
||||
}
|
||||
}
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
val serviceRunning =
|
||||
Utils.isServiceRunning(requireContext(), ConnectionService::class.java)
|
||||
if(serviceRunning){
|
||||
val serviceIntent= Intent(requireContext(), ConnectionService::class.java)
|
||||
requireContext().stopService(serviceIntent)
|
||||
}
|
||||
}
|
||||
fun showLoading(str: String, context: Context) {
|
||||
val message = if (TextUtils.isEmpty(str)) "进行中..." else str
|
||||
if (baseLoading == null) {
|
||||
|
|
|
|||
|
|
@ -36,7 +36,11 @@ data class Trade(
|
|||
val rechargeDays: String? = null,
|
||||
|
||||
@field:SerializedName("userId")
|
||||
val userId: String? = null
|
||||
val userId: String? = null,
|
||||
@field:SerializedName("app_format")
|
||||
val appFormat: String? = null,
|
||||
@field:SerializedName("payModel")
|
||||
val payModel: Int=0
|
||||
){
|
||||
override fun toString(): String {
|
||||
return "Trade(totalFee=$totalFee, outTradeNo=$outTradeNo, rechargeDays=$rechargeDays, userId=$userId,payUrl=$payUrl)"
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
package com.yingmao.clash.service;
|
||||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.ResultReceiver;
|
||||
import android.util.Log;
|
||||
|
||||
import com.yingmao.clash.fragment.AccelerateViewModel;
|
||||
|
||||
public class ConnectionService extends Service {
|
||||
|
||||
private static final String TAG = "TimerService";
|
||||
private static final long INTERVAL_MILLIS = 60000; // 10 秒
|
||||
private Handler handler = new Handler();
|
||||
private Intent intent;
|
||||
private Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if(intent!=null){
|
||||
ResultReceiver receiver = intent.getParcelableExtra("receiver");
|
||||
if (receiver != null) {
|
||||
Bundle resultData = new Bundle();
|
||||
resultData.putString("ping", "ping to Service!");
|
||||
receiver.send(1, resultData); // 1 是结果码
|
||||
}
|
||||
}
|
||||
|
||||
handler.postDelayed(this, INTERVAL_MILLIS);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
Log.d(TAG, "Service onCreate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
Log.d(TAG, "Service onStartCommand");
|
||||
this.intent=intent;
|
||||
handler.post(runnable); // 启动定时器
|
||||
return START_STICKY; // 服务被杀死后会自动重启
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
handler.removeCallbacks(runnable); // 停止定时器
|
||||
Log.d(TAG, "Service onDestroy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinder onBind(Intent intent) {
|
||||
Log.d(TAG, "Service onBind");
|
||||
return null; // 如果不支持绑定服务,返回 null
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ripple xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:color="#BFD5D5D5">
|
||||
<item android:id="@android:id/mask"
|
||||
android:drawable="@color/white">
|
||||
<!-- mask 的 drawable 如果不设置 会报错哦!-->
|
||||
</item>
|
||||
|
||||
<item >
|
||||
<shape android:shape="rectangle">
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:color="@color/blue_4072FE" android:width="1dp"/>
|
||||
<corners android:radius="24dp"/>
|
||||
</shape>
|
||||
</item>
|
||||
|
||||
</ripple>
|
||||
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<gradient android:endColor="@color/black_141b21"
|
||||
android:startColor="@color/black_141b21"
|
||||
android:angle="270"
|
||||
/>
|
||||
<corners android:radius="22dp" />
|
||||
<!-- <stroke android:width="1dp" android:color="#000000" />-->
|
||||
|
||||
<solid android:color="#FFFFFF"/>
|
||||
<stroke android:color="@color/blue_4072FE" android:width="1dp"/>
|
||||
<corners android:radius="22dp"/>
|
||||
</shape>
|
||||
|
|
@ -5,6 +5,6 @@
|
|||
android:drawable="@color/translate"/>
|
||||
<item
|
||||
android:state_pressed="true"
|
||||
android:drawable="@color/black_262c46">
|
||||
android:drawable="@color/click_bg">
|
||||
</item>
|
||||
</selector>
|
||||
|
|
@ -12,11 +12,11 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="5dp"
|
||||
android:background="@drawable/press_effect_back"
|
||||
android:background="@drawable/press_effect"
|
||||
app:srcCompat="@drawable/ic_s_gray_back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:tint="@color/black"
|
||||
android:tint="@color/white"
|
||||
/>
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/rvPay"
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
android:background="@drawable/payment_options_bg"
|
||||
android:layout_marginStart="30dp"
|
||||
android:layout_marginEnd="30dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
|
@ -23,35 +23,42 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textSize="17sp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:paddingTop="10dp"
|
||||
android:textColor="@color/white"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginTop="10dp"
|
||||
android:gravity="center"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="bold"
|
||||
android:text="@string/quickPayment" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="horizontal"
|
||||
android:layout_marginTop="10dp"
|
||||
android:paddingBottom="20dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
android:layout_marginBottom="10dp"
|
||||
android:gravity="center"
|
||||
>
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/ivQuickPayment"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/press_effect"
|
||||
android:layout_marginStart="20dp"
|
||||
android:padding="5dp"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/alipay" />
|
||||
app:srcCompat="@drawable/alipay"
|
||||
/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/ivQPWechatPay"
|
||||
android:layout_width="60dp"
|
||||
android:layout_height="60dp"
|
||||
android:layout_weight="1"
|
||||
android:background="@drawable/press_effect"
|
||||
android:padding="5dp"
|
||||
android:visibility="gone"
|
||||
android:layout_marginStart="20dp"
|
||||
app:srcCompat="@drawable/wechat" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,55 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@color/translate"
|
||||
>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:background="@drawable/activity_bg"
|
||||
>
|
||||
<TextView
|
||||
android:id="@+id/tvShowContent"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/payDelayStr"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginStart="20dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:textSize="15sp"
|
||||
android:textColor="@color/black"
|
||||
android:textStyle="normal"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvSure"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@+id/tvShowContent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
android:layout_marginTop="20dp"
|
||||
android:layout_marginBottom="20dp"
|
||||
android:text="@string/AlreadyKnown"
|
||||
android:paddingStart="40dp"
|
||||
android:paddingEnd="40dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp"
|
||||
android:background="@drawable/pay_sure_click_effect"
|
||||
android:textColor="@color/blue_4072FE"
|
||||
android:textSize="16sp"
|
||||
/>
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
|
@ -386,4 +386,8 @@ Service Description\n
|
|||
<string name="LoginOut">It is detected that the current account is logged in on other devices. If it is not your own operation, please change the password immediately and log out of the unfamiliar device.</string>
|
||||
<string name="tooFast">The application is initializing. Please wait for 1~2 seconds and try again.</string>
|
||||
<string name="Starting">Starting</string>
|
||||
<string name="PaySuccessful">PaySuccessful</string>
|
||||
<string name="PayError">PayError:</string>
|
||||
<string name="payDelayStr">\u3000\u3000Your payment order has been successfully completed and is currently being processed by the platform. There is typically a delay of several seconds before your funds arrive, so please wait. If you returned to the app homepage, we recommend waiting a moment and then manually refreshing the page to update the status. If your funds still have not arrived after a few minutes, please contact customer service. Thank you for your support and trust!</string>
|
||||
<string name="AlreadyKnown">Already Known</string>
|
||||
</resources>
|
||||
|
|
@ -376,4 +376,8 @@
|
|||
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
|
||||
<string name="tooFast">應用初始化中,請等待1~2秒後重試</string>
|
||||
<string name="Starting">啟動中</string>
|
||||
<string name="PaySuccessful">支付成功</string>
|
||||
<string name="PayError">支付失敗:</string>
|
||||
<string name="payDelayStr">\u3000\u3000您的支付訂單已成功完成,目前平台正在處理中。通常情況下到帳會有幾秒鐘的延遲,請您稍作等待。如您已返回應用程式首頁,建議等待片刻後手動刷新頁面以便更新狀態。若幾分鐘後仍未到賬,請及時聯絡客服人員為您處理。感謝您的支持與信任!</string>
|
||||
<string name="AlreadyKnown">已知晓</string>
|
||||
</resources>
|
||||
|
|
@ -374,4 +374,8 @@
|
|||
<string name="LoginOut">檢測到當前賬號在其他設備登錄,如非本人操作,請立即修改密碼並退出陌生設備。</string>
|
||||
<string name="tooFast">應用初始化中,請等待1~2秒後重試</string>
|
||||
<string name="Starting">啟動中</string>
|
||||
<string name="PaySuccessful">支付成功</string>
|
||||
<string name="PayError">支付失敗:</string>
|
||||
<string name="payDelayStr">\u3000\u3000您的支付訂單已成功完成,目前平台正在處理中。通常情況下到帳會有幾秒鐘的延遲,請您稍作等待。如您已返回應用程式首頁,建議等待片刻後手動刷新頁面以便更新狀態。若幾分鐘後仍未到賬,請及時聯絡客服人員為您處理。感謝您的支持與信任!</string>
|
||||
<string name="AlreadyKnown">已知晓</string>
|
||||
</resources>
|
||||
|
|
@ -414,4 +414,8 @@
|
|||
<string name="Starting">启动中</string>
|
||||
<string name="WFApiPort">网飞666</string>
|
||||
<string name="zlApiPort">宇连366</string>
|
||||
<string name="PaySuccessful">支付成功</string>
|
||||
<string name="PayError">支付失败:</string>
|
||||
<string name="payDelayStr">\u3000\u3000您的支付订单已成功完成,目前平台正在处理中。通常情况下到账会有几秒钟的延迟,请您稍作等待。如您已返回应用首页,建议等待片刻后手动刷新页面以便更新状态。若几分钟后仍未到账,请及时联系客服人员为您处理。感谢您的支持与信任!</string>
|
||||
<string name="AlreadyKnown">已知晓</string>
|
||||
</resources>
|
||||
Loading…
Reference in New Issue