第一次提交
This commit is contained in:
362
app/src/main/java/com/hbl/lewan/pay/CollectionActivity.java
Normal file
362
app/src/main/java/com/hbl/lewan/pay/CollectionActivity.java
Normal file
@@ -0,0 +1,362 @@
|
||||
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.codersun.fingerprintcompat.AonFingerChangeCallback;
|
||||
import com.codersun.fingerprintcompat.FingerManager;
|
||||
import com.codersun.fingerprintcompat.SimpleFingerCheckCallback;
|
||||
import com.hbl.lewan.IMApplication;
|
||||
import com.hbl.lewan.IMUIKitConfig;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.databinding.ActivityCollectionBinding;
|
||||
import com.hbl.lewan.databinding.ActivityPaymentBinding;
|
||||
import com.hbl.lewan.dialog.ActionConfirmDialog;
|
||||
import com.hbl.lewan.dialog.PayCashDialog;
|
||||
import com.hbl.lewan.dialog.PayCashFingerDialog;
|
||||
import com.hbl.lewan.main.mine.ChangeAccoutActionActivity;
|
||||
import com.hbl.lewan.model.BindBean;
|
||||
import com.hbl.lewan.model.FukuanResultBean;
|
||||
import com.hbl.lewan.model.LoginBean;
|
||||
import com.hbl.lewan.model.WalletBean;
|
||||
import com.hbl.lewan.network.Api;
|
||||
import com.hbl.lewan.network.BaseObserver;
|
||||
import com.hbl.lewan.network.Result;
|
||||
import com.hbl.lewan.utils.DataUtils;
|
||||
import com.hbl.lewan.utils.KeyboardUtil;
|
||||
import com.hbl.lewan.utils.LogUtils;
|
||||
import com.hbl.lewan.wallet.WalletInfoActivity;
|
||||
import com.king.zxing.util.CodeUtils;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.uinfo.UserService;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.TransferBean;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class CollectionActivity extends BaseActivity {
|
||||
|
||||
WalletBean walletBean;
|
||||
BindBean bindBean;
|
||||
float number = 0;
|
||||
ActivityCollectionBinding viewBinding;
|
||||
String code;
|
||||
String uid;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_fcfcfc));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_white));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityCollectionBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
initView();
|
||||
}
|
||||
code = getIntent().getStringExtra("code");
|
||||
uid = getIntent().getStringExtra("uid");
|
||||
if(!TextUtils.isEmpty(uid)){
|
||||
getUserInfo(uid);
|
||||
}
|
||||
}
|
||||
private void getUserInfo(String user_uid) {
|
||||
Api.getInstance().userInfo(user_uid)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<LoginBean> feedbackResp) {
|
||||
viewBinding.userHeadIv.setVisibility(View.VISIBLE);
|
||||
viewBinding.userNameTv.setVisibility(View.VISIBLE);
|
||||
viewBinding.userNameTv.setText(feedbackResp.data.getNickNameWithRemark());
|
||||
viewBinding.userHeadIv.setData(feedbackResp.data.getUserAvatarFileName(),feedbackResp.data.getNickNameWithRemark());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void initView() {
|
||||
viewBinding.aboutTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
|
||||
viewBinding.tvLogin.setOnClickListener(v -> {
|
||||
if (bindBean != null) {
|
||||
if (!bindBean.getPhoneBind()) {
|
||||
showDialog();
|
||||
} else {
|
||||
if (TextUtils.isEmpty(viewBinding.numberHintEt.getText().toString().trim())) {
|
||||
ToastX.showShortToast(R.string.zzjebnwk_txt1);
|
||||
return;
|
||||
}
|
||||
float number1 = Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim()) * 100;
|
||||
if (number1 < 1) {
|
||||
ToastX.showShortToast(R.string.zzjebnsy_txt1);
|
||||
return;
|
||||
}
|
||||
|
||||
if (walletBean != null) {
|
||||
number = Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim());
|
||||
toChange(number);
|
||||
} else {
|
||||
ToastX.showShortToast(R.string.hqqbxxsb_tx);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastX.showShortToast(R.string.hqqbxxsb_tx);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
viewBinding.numberHintEt.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String input = s.toString();
|
||||
if(input.startsWith(".")){
|
||||
viewBinding.numberHintEt.setText("0"+viewBinding.numberHintEt.getText().toString());
|
||||
}
|
||||
if(input.contains(".")){
|
||||
int dotIndex = input.indexOf(".");
|
||||
if(input.length()-dotIndex-1>2){
|
||||
viewBinding.numberHintEt.setText(input.substring(0,dotIndex+3));
|
||||
}
|
||||
}
|
||||
viewBinding.numberHintEt.setSelection(viewBinding.numberHintEt.getText().length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
viewBinding.tvLogin1.setOnClickListener(v -> {
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void showDialog() {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(CollectionActivity.this,
|
||||
getString(R.string.bind_phone_des_txt), getString(R.string.nobind_txt), getString(R.string.tobind_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
Intent intent = new Intent(CollectionActivity.this, ChangeAccoutActionActivity.class);
|
||||
intent.putExtra("type", ChangeAccoutActionActivity.TYPE_BIND_PHONE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
long payId = 0;
|
||||
private void toChange(float number) {
|
||||
KeyboardUtil.hideSoftInput(this);
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("amount", (int) (number * 100));
|
||||
maps.put("codeMessage", code);
|
||||
maps.put("coinType",0);
|
||||
Api.getInstance().payOuterCodeScan(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<Long> feedbackResp) {
|
||||
// ToastX.showShortToast(R.string.shoukuanfasong_succ_txt);
|
||||
// finish();
|
||||
payId = feedbackResp.data;
|
||||
viewBinding.step1Ly.setVisibility(View.GONE);
|
||||
viewBinding.step2.setVisibility(View.VISIBLE);
|
||||
Glide.with(CollectionActivity.this)
|
||||
.load(R.mipmap.zhifuzhong_img)
|
||||
.into(viewBinding.waitingIv);
|
||||
|
||||
myCountDownTimer = new MyCountDownTimer(1000 * 2*60, 3000);
|
||||
myCountDownTimer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
MyCountDownTimer myCountDownTimer;
|
||||
//倒计时函数
|
||||
private class MyCountDownTimer extends CountDownTimer {
|
||||
|
||||
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
}
|
||||
|
||||
//计时过程
|
||||
@Override
|
||||
public void onTick(long l) {
|
||||
getPayInfo();
|
||||
}
|
||||
|
||||
//计时完毕的方法
|
||||
@Override
|
||||
public void onFinish() {
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(CollectionActivity.this,
|
||||
getString(R.string.shoukuanchaoshi_txt), "",getString(R.string.fanhuishouye_txt),false);
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void getPayInfo() {
|
||||
|
||||
Api.getInstance().getPayResult(payId+"")
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<FukuanResultBean> feedbackResp) {
|
||||
if(!feedbackResp.data.getStatus().equals(1)) {
|
||||
myCountDownTimer.cancel();
|
||||
myCountDownTimer = null;
|
||||
viewBinding.step2.setVisibility(View.GONE);
|
||||
viewBinding.step3.setVisibility(View.VISIBLE);
|
||||
changeStep3(feedbackResp.data);
|
||||
}
|
||||
//{"data":{"nickname":"鸡哔你","amount":100,"payTime":"","status":1},"code":1}
|
||||
//1 支付中 2 成功 0/3支付失败
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void changeStep3(FukuanResultBean data) {
|
||||
if(data.getStatus().equals(2)){
|
||||
viewBinding.numberTv.setText(viewBinding.numberHintEt.getText().toString().trim());
|
||||
viewBinding.fukuanfangTv.setText(data.getNickname());
|
||||
viewBinding.daozhangshijianTv.setText(DataUtils.getCurrentTimeType(System.currentTimeMillis()));
|
||||
}else{
|
||||
viewBinding.step3Iv.setImageResource(R.mipmap.fukuan_faild_img);
|
||||
viewBinding.step3SuccLy.setVisibility(View.GONE);
|
||||
viewBinding.tvLogin1.setText(R.string.fanhuishouye_txt);
|
||||
viewBinding.step3TitleTv.setText(R.string.sksb_qxfk_txt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getWallet();
|
||||
bindInfo();
|
||||
}
|
||||
|
||||
|
||||
private void bindInfo() {
|
||||
// if (u != null) {
|
||||
Api.getInstance().bindInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<BindBean>>() {
|
||||
@Override
|
||||
public void onSuccess(Result<BindBean> feedbackResp) {
|
||||
bindBean = feedbackResp.data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
private void getWallet() {
|
||||
Api.getInstance().walletInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<WalletBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<WalletBean> feedbackResp) {
|
||||
walletBean = feedbackResp.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
// WidgetUtils.showToast(getActivity(), msg, WidgetUtils.ToastType.ERROR);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(null != this.getCurrentFocus()){
|
||||
/**
|
||||
* 点击空白位置 隐藏软键盘
|
||||
*/
|
||||
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
|
||||
}
|
||||
return super .onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,594 @@
|
||||
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.hbl.lewan.IMUIKitConfig;
|
||||
import com.hbl.lewan.dialog.ActionConfirmDialog;
|
||||
import com.hbl.lewan.model.PayInfoBean;
|
||||
import com.hbl.lewan.model.WalletBean;
|
||||
import com.hbl.lewan.network.Api;
|
||||
import com.hbl.lewan.network.BaseObserver;
|
||||
import com.hbl.lewan.network.Result;
|
||||
import com.hbl.lewan.utils.ToolKits;
|
||||
import com.codersun.fingerprintcompat.AonFingerChangeCallback;
|
||||
import com.codersun.fingerprintcompat.FingerManager;
|
||||
import com.codersun.fingerprintcompat.SimpleFingerCheckCallback;
|
||||
import com.hbl.lewan.IMApplication;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.dialog.PayCashDialog;
|
||||
import com.hbl.lewan.dialog.PayCashFingerDialog;
|
||||
import com.hbl.lewan.dialog.SelectPayTypeDialog;
|
||||
import com.hbl.lewan.model.LoginBean;
|
||||
import com.hbl.lewan.utils.DataUtils;
|
||||
import com.hbl.lewan.utils.ImageCacheLoader;
|
||||
import com.hbl.lewan.utils.LogUtils;
|
||||
import com.hbl.lewan.wallet.PaySettingActivity;
|
||||
import com.king.zxing.util.CodeUtils;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
import com.hbl.lewan.databinding.ActivityCollectionAndPaymentBinding;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class CollectionAndPaymentActivity extends BaseActivity implements SelectPayTypeDialog.OnToTypeListener
|
||||
{
|
||||
|
||||
private int payType = 0;
|
||||
PayCashDialog payDialog;
|
||||
PayCashFingerDialog payCashFingerDialog;
|
||||
|
||||
ActivityCollectionAndPaymentBinding viewBinding;
|
||||
boolean isShoukuan = false;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_white));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_f7f7f7));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityCollectionAndPaymentBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
isShoukuan = getIntent().getBooleanExtra("isShoukuan",false);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
initView();
|
||||
}
|
||||
}
|
||||
/**
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void initView()
|
||||
{
|
||||
viewBinding.mainAboutTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
|
||||
payType = DataUtils.get(this,"pay_type",0);
|
||||
viewBinding.shoukuanmaLy.setOnClickListener(v -> changeType(0));
|
||||
|
||||
viewBinding.fukuanmaLy.setOnClickListener(v ->{
|
||||
getPayOuterCode();
|
||||
changeType(1);
|
||||
});
|
||||
// loginBean = lu1();
|
||||
// if(loginBean!=null){
|
||||
viewBinding.userNameTv.setText(IMKitClient.getUserInfo().getName());
|
||||
viewBinding.userHeadIv.setData(IMKitClient.getUserInfo().getAvatar(),IMKitClient.getUserInfo().getName());
|
||||
// }
|
||||
viewBinding.mainMoreSettingsSafa.setOnClickListener(v -> {
|
||||
// SelectPayTypeDialog selectPayTypeDialog = new SelectPayTypeDialog(CollectionAndPaymentActivity.this,payType,walletBean);
|
||||
// selectPayTypeDialog.setOnToVipListener(this);
|
||||
// selectPayTypeDialog.show();
|
||||
});
|
||||
viewBinding.baocunShoukuanmaLy.setOnClickListener(v ->{
|
||||
doSaveQrcode();
|
||||
|
||||
});
|
||||
changePayType();
|
||||
viewBinding.shuaxinIv.setOnClickListener(v -> {
|
||||
toShuaxin();
|
||||
});
|
||||
viewBinding.shuaxinIv1.setOnClickListener(v -> {
|
||||
toShuaxin();
|
||||
});
|
||||
|
||||
// viewBinding.fukuanQrcodeIv.setOnClickListener(v -> {
|
||||
// switch (FingerManager.checkSupport(CollectionAndPaymentActivity.this))
|
||||
// {
|
||||
// case DEVICE_UNSUPPORTED:
|
||||
// showPayDialog(0);
|
||||
// break;
|
||||
// case SUPPORT_WITHOUT_DATA:
|
||||
// showPayDialog(1);
|
||||
// break;
|
||||
// case SUPPORT:
|
||||
// showPayDialog(2);
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
Bitmap bitmap = CodeUtils.createQRCode(String.format(IMUIKitConfig.SHARE_USER_PAYMENT_CODE, IMKitClient.account()), DataUtils.dip2px(this, 175.0f), null);
|
||||
if (bitmap != null) {
|
||||
viewBinding.shoukuanmaQrcodeIv.setImageBitmap(bitmap);
|
||||
}
|
||||
if(isShoukuan){
|
||||
changeType(0);
|
||||
}else{
|
||||
getPayOuterCode();
|
||||
}
|
||||
initStartDaojishi();
|
||||
|
||||
}
|
||||
|
||||
private void initStartDaojishi() {
|
||||
if(myCountDownTimer!=null){
|
||||
myCountDownTimer.cancel();
|
||||
}
|
||||
myCountDownTimer = new MyCountDownTimer(1000 * 24*60*60, 3000);
|
||||
myCountDownTimer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if(myCountDownTimer!=null){
|
||||
myCountDownTimer.cancel();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
String payOuterCode;
|
||||
private void getPayOuterCode() {
|
||||
Api.getInstance().payOuterCode()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<String> feedbackResp) {
|
||||
payOuterCode = feedbackResp.data;
|
||||
Bitmap bitmap = CodeUtils.createQRCode(payOuterCode, DataUtils.dip2px(CollectionAndPaymentActivity.this, 175.0f), null);
|
||||
if (bitmap != null) {
|
||||
viewBinding.fukuanQrcodeIv.setImageBitmap(bitmap);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toShuaxin() {
|
||||
|
||||
RotateAnimation ra = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
// 设置动画时长
|
||||
ra.setDuration(1000);
|
||||
// 启动动画
|
||||
viewBinding.shuaxinIv1.startAnimation(ra);
|
||||
getPayOuterCode();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void changePayType() {
|
||||
viewBinding.yueTv.setVisibility(View.INVISIBLE);
|
||||
if(payType == 0){
|
||||
viewBinding.payTypeTv.setText(R.string.species_txt);
|
||||
viewBinding.yueTv.setVisibility(View.VISIBLE);
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.wallet_jinbi_img);
|
||||
}else if(payType == 1){
|
||||
viewBinding.payTypeTv.setText("line pay");
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.line_pay_img);
|
||||
}else{
|
||||
viewBinding.payTypeTv.setText(R.string.neweb_txt);
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.newebpay_img);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将2维码保存到系统相册。
|
||||
*/
|
||||
private void doSaveQrcode(){
|
||||
// 先生成bitmap对象
|
||||
Bitmap bmp = DataUtils.generateBitmap(viewBinding.shoukuanRy1);
|
||||
// bitmap对象生成成功
|
||||
if(bmp != null){
|
||||
// 保存到相册成功
|
||||
if (ToolKits.saveBmp2Gallery(CollectionAndPaymentActivity.this, bmp)) {
|
||||
ToastX.showShortToast(getString(R.string.qrcode_generate_activity_qr_save_sucess));
|
||||
} else {
|
||||
ToastX.showShortToast(getString(R.string.qrcode_generate_activity_qr_save_fail));
|
||||
|
||||
}
|
||||
}
|
||||
else{
|
||||
Log.w("TAG", "将2维码保存到相册时失败了,从view生成Bitmap对象失败,生成后的bmp=null!");
|
||||
ToastX.showShortToast(getString(R.string.qrcode_generate_activity_qr_generate_fail));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void changeType(int i) {
|
||||
|
||||
if(i ==0){
|
||||
viewBinding.shoukuanRy.setVisibility(View.VISIBLE);
|
||||
viewBinding.fukuanRy.setVisibility(View.GONE);
|
||||
viewBinding.shoukuanmaIv.setImageResource(R.mipmap.pay_shoukuan_true);
|
||||
viewBinding.fukuanmaIv.setImageResource(R.mipmap.pay_zhifu_false);
|
||||
viewBinding.shoukuanmaTv.setTextColor(getResources().getColor(R.color.color_themeblue));
|
||||
viewBinding.fukuanmaTv.setTextColor(getResources().getColor(R.color.color_333333));
|
||||
viewBinding.shoukuanmaLy.setBackgroundResource(R.mipmap.pay_button_true);
|
||||
viewBinding.fukuanmaLy.setBackgroundResource(R.mipmap.pay_button_false);
|
||||
viewBinding.mainAboutTitleBar.getTitleTextView().setText(getString(R.string.shoukuanma_txt));
|
||||
|
||||
}else{
|
||||
viewBinding.shoukuanRy.setVisibility(View.GONE);
|
||||
viewBinding.fukuanRy.setVisibility(View.VISIBLE);
|
||||
viewBinding.shoukuanmaIv.setImageResource(R.mipmap.pay_shoukuan_false);
|
||||
viewBinding.fukuanmaIv.setImageResource(R.mipmap.pay_zhifu_true);
|
||||
viewBinding.fukuanmaTv.setTextColor(getResources().getColor(R.color.color_themeblue));
|
||||
viewBinding.shoukuanmaTv.setTextColor(getResources().getColor(R.color.color_333333));
|
||||
viewBinding.shoukuanmaLy.setBackgroundResource(R.mipmap.pay_button_false);
|
||||
viewBinding.fukuanmaLy.setBackgroundResource(R.mipmap.pay_button_true);
|
||||
viewBinding.mainAboutTitleBar.getTitleTextView().setText(getString(R.string.fukuanma_txt));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getWallet();
|
||||
}
|
||||
|
||||
private WalletBean walletBean;
|
||||
private void getWallet() {
|
||||
Api.getInstance().walletInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<WalletBean> feedbackResp) {
|
||||
walletBean = feedbackResp.data;
|
||||
viewBinding.yueTv.setText(String.format(getResources().getString(R.string.yue_pay_txt), feedbackResp.data.getGoldCoin() / 100f));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void toType(int type) {
|
||||
DataUtils.set(CollectionAndPaymentActivity.this,"pay_type",type);
|
||||
payType = type;
|
||||
changePayType();
|
||||
}
|
||||
|
||||
MyCountDownTimer myCountDownTimer;
|
||||
int count =0;
|
||||
//倒计时函数
|
||||
private class MyCountDownTimer extends CountDownTimer {
|
||||
|
||||
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
}
|
||||
|
||||
//计时过程
|
||||
@Override
|
||||
public void onTick(long l) {
|
||||
count++;
|
||||
getPayInfo();
|
||||
if(count>59){
|
||||
count=0;
|
||||
if(!isShoukuan) {
|
||||
getPayOuterCode();
|
||||
}
|
||||
}
|
||||
if((payDialog!=null&&payDialog.isShowing())||(payCashFingerDialog!=null&&payCashFingerDialog.isShowing())) {
|
||||
if (System.currentTimeMillis() - passwordTime > 2 * 60 * 1000) {
|
||||
if(payDialog!=null){
|
||||
payDialog.dismiss();
|
||||
}
|
||||
if(payCashFingerDialog!=null){
|
||||
payCashFingerDialog.dismiss();
|
||||
}
|
||||
if(payInfoBeanTop!=null){
|
||||
cancelPay(payInfoBeanTop.getPayId());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//计时完毕的方法
|
||||
@Override
|
||||
public void onFinish() {
|
||||
finish();
|
||||
|
||||
}
|
||||
}
|
||||
PayInfoBean payInfoBeanTop = null;
|
||||
private void getPayInfo() {
|
||||
Api.getInstance().getPayInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<PayInfoBean> feedbackResp) {
|
||||
//{"data":{"headImage":"https://letschat.oss-cn-hongkong.aliyuncs.com/media/userAvatarFileName/dc873aed-2726-4b23-83af-0a8f3e1dbc17_1699842807436.jpg","nickname":"\uD83D\uDC36不乖","payId":2,"amount":2000},"code":1}
|
||||
if(payInfoBeanTop!=null){
|
||||
return;
|
||||
}
|
||||
|
||||
if(feedbackResp.data!=null){
|
||||
payInfoBeanTop = feedbackResp.data;
|
||||
getPayOuterCode();
|
||||
if(DataUtils.get(CollectionAndPaymentActivity.this, "hasMianMi", false)&&payInfoBeanTop.getAmount()<=1000*100){
|
||||
toChange(payInfoBeanTop,null,true);
|
||||
}else {
|
||||
passwordTime = System.currentTimeMillis();
|
||||
if (DataUtils.get(CollectionAndPaymentActivity.this, "hasFinger", false)) {
|
||||
showPayCashFingerDialog(feedbackResp.data);
|
||||
} else {
|
||||
showPayCashDialog(feedbackResp.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
long passwordTime = 0;
|
||||
|
||||
|
||||
|
||||
private void showPayCashDialog(PayInfoBean payInfoBean) {
|
||||
payDialog = new PayCashDialog(CollectionAndPaymentActivity.this,String.format("%.2f",payInfoBean.getAmount()/100f),true,0,walletBean,
|
||||
null,2,String.format(getString(R.string.fukuangei_txt),payInfoBean.getNickname()));
|
||||
//免密支付的 要告诉 为什么 没有免密
|
||||
if((payInfoBean.getAmount()>1000*100)&&DataUtils.get(CollectionAndPaymentActivity.this, "hasMianMi", false)){
|
||||
payDialog = new PayCashDialog(CollectionAndPaymentActivity.this,String.format("%.2f",payInfoBean.getAmount()/100f),true,0,walletBean,
|
||||
null,2,String.format(getString(R.string.fukuangei_txt),payInfoBean.getNickname()),getString(R.string.zfjecgxz_txt));
|
||||
}
|
||||
payDialog.setOntoAlbumListener(new PayCashDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onPayPass(String position) {
|
||||
|
||||
toChange(payInfoBean,position,false);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onChangeFinger() {
|
||||
showPayCashFingerDialog(payInfoBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(CollectionAndPaymentActivity.this,
|
||||
getString(R.string.quxiaozhifu_dialog_txt),true);
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
cancelPay(payInfoBean.getPayId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
actionDialog.dismiss();
|
||||
payDialog.show();
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
|
||||
}
|
||||
});
|
||||
payDialog.show();
|
||||
}
|
||||
|
||||
private void cancelPay(Long payId) {
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("payId", payId);
|
||||
Api.getInstance().payOuterCodeCancel(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result feedbackResp) {
|
||||
ToastX.showShortToast(R.string.zhifuchengong_txt1);
|
||||
payInfoBeanTop =null;
|
||||
if(payDialog!=null) {
|
||||
payDialog.dismiss();
|
||||
}
|
||||
if(payCashFingerDialog!=null) {
|
||||
payCashFingerDialog.dismiss();
|
||||
}
|
||||
getPayOuterCode();
|
||||
initStartDaojishi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toChange(PayInfoBean payInfoBean,String password,boolean isMianMi) {
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("payId", payInfoBean.getPayId());
|
||||
if(!TextUtils.isEmpty(password)){
|
||||
maps.put("payPassword", password);
|
||||
maps.put("payVerifyCode",1);
|
||||
}else{
|
||||
maps.put("payVerifyCode",3);
|
||||
|
||||
}
|
||||
|
||||
Api.getInstance().payOuterCodeConfirm(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result feedbackResp) {
|
||||
ToastX.showShortToast(R.string.zhifuchengong_txt);
|
||||
payInfoBeanTop = null;
|
||||
getPayOuterCode();
|
||||
getWallet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
if(isMianMi){//免密支付失败 校验支付密码 这些
|
||||
if (DataUtils.get(CollectionAndPaymentActivity.this, "hasFinger", false)) {
|
||||
showPayCashFingerDialog(payInfoBeanTop);
|
||||
} else {
|
||||
showPayCashDialog(payInfoBeanTop);
|
||||
}
|
||||
}else{
|
||||
payInfoBeanTop = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showPayCashFingerDialog(PayInfoBean payInfoBean) {
|
||||
//Context context, String data, boolean showNumber, int payType, WalletBean walletBean, SelectPayTypeDialog.OnToTypeListener onToTypeListener, int isShowFinger
|
||||
payCashFingerDialog = new PayCashFingerDialog(this,String.format("%.2f",payInfoBean.getAmount()/100f),true,
|
||||
0,walletBean,null,2,String.format(getString(R.string.fukuangei_txt),payInfoBean.getNickname()));
|
||||
if((payInfoBean.getAmount()>1000*100)&&DataUtils.get(CollectionAndPaymentActivity.this, "hasMianMi", false)){
|
||||
payCashFingerDialog = new PayCashFingerDialog(this,String.format("%.2f",payInfoBean.getAmount()/100f),true,
|
||||
0,walletBean,null,2,String.format(getString(R.string.fukuangei_txt),payInfoBean.getNickname()),getString(R.string.zfjecgxz_txt));
|
||||
}
|
||||
payCashFingerDialog.setOntoAlbumListener(new PayCashFingerDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onChangePassword() {
|
||||
showPayCashDialog(payInfoBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toFinger() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
checkPayFinger(payInfoBean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(CollectionAndPaymentActivity.this,
|
||||
getString(R.string.quxiaozhifu_dialog_txt),true);
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
cancelPay(payInfoBean.getPayId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
actionDialog.dismiss();
|
||||
payCashFingerDialog.show();
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
});
|
||||
payCashFingerDialog.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void checkPayFinger(PayInfoBean payInfoBean) {
|
||||
|
||||
FingerManager.build().setApplication(IMApplication.getInstance())
|
||||
.setTitle(" ")
|
||||
.setDes(" ")
|
||||
.setNegativeText(" ")
|
||||
.setFingerCheckCallback(new SimpleFingerCheckCallback()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void onSucceed()
|
||||
{
|
||||
ToastX.showShortToast("验证成功");
|
||||
payCashFingerDialog.dismiss();
|
||||
toChange(payInfoBean,null,false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error)
|
||||
{
|
||||
ToastX.showShortToast("验证失败");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel()
|
||||
{
|
||||
ToastX.showShortToast("您取消了识别");
|
||||
|
||||
}
|
||||
})
|
||||
.setFingerChangeCallback(new AonFingerChangeCallback()
|
||||
{
|
||||
|
||||
@Override
|
||||
protected void onFingerDataChange()
|
||||
{
|
||||
// ToastX.showShortToast("指纹数据发生了变化");
|
||||
FingerManager.updateFingerData(CollectionAndPaymentActivity.this);
|
||||
new Handler().postDelayed(() -> checkPayFinger(payInfoBean), 1000);
|
||||
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.startListener(CollectionAndPaymentActivity.this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
622
app/src/main/java/com/hbl/lewan/pay/LipinDuiHuanActivity.java
Normal file
622
app/src/main/java/com/hbl/lewan/pay/LipinDuiHuanActivity.java
Normal file
@@ -0,0 +1,622 @@
|
||||
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.codersun.fingerprintcompat.AonFingerChangeCallback;
|
||||
import com.codersun.fingerprintcompat.FingerManager;
|
||||
import com.codersun.fingerprintcompat.SimpleFingerCheckCallback;
|
||||
import com.hbl.lewan.IMApplication;
|
||||
import com.hbl.lewan.IMUIKitConfig;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.databinding.ActivityCollectionAndPaymentBinding;
|
||||
import com.hbl.lewan.databinding.ActivityLipinduihuanBinding;
|
||||
import com.hbl.lewan.dialog.ActionConfirmDialog;
|
||||
import com.hbl.lewan.dialog.PayCashDialog;
|
||||
import com.hbl.lewan.dialog.PayCashFingerDialog;
|
||||
import com.hbl.lewan.dialog.SelectPayTypeDialog;
|
||||
import com.hbl.lewan.model.PayInfoBean;
|
||||
import com.hbl.lewan.model.WalletBean;
|
||||
import com.hbl.lewan.network.Api;
|
||||
import com.hbl.lewan.network.BaseObserver;
|
||||
import com.hbl.lewan.network.Result;
|
||||
import com.hbl.lewan.utils.AppUtils;
|
||||
import com.hbl.lewan.utils.DataUtils;
|
||||
import com.hbl.lewan.utils.ToolKits;
|
||||
import com.king.zxing.util.CodeUtils;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class LipinDuiHuanActivity extends BaseActivity implements SelectPayTypeDialog.OnToTypeListener {
|
||||
|
||||
private int payType = 0;
|
||||
PayCashDialog payDialog;
|
||||
PayCashFingerDialog payCashFingerDialog;
|
||||
|
||||
ActivityLipinduihuanBinding viewBinding;
|
||||
boolean isShoukuan = false;
|
||||
private int viewType = 0;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_fffbfb));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_ffe49c));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityLipinduihuanBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
isShoukuan = getIntent().getBooleanExtra("isShoukuan", false);
|
||||
viewType = getIntent().getIntExtra("type", 0);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
initView();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void initView() {
|
||||
// if (viewType == 1) {
|
||||
// viewBinding.mainAboutTitleBar.setTitle("礼金兑换码");
|
||||
// viewBinding.lipingduihuanLy.setBackgroundColor(Color.parseColor("#FFE49C"));
|
||||
// viewBinding.fukuanRy.setBackgroundResource(R.mipmap.ic_redpay_bg);
|
||||
// int whiteColor = getResources().getColor(R.color.color_white);
|
||||
// viewBinding.tvShangjiamaHint.setTextColor(whiteColor);
|
||||
// viewBinding.tvShangjiamaHint.setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(R.mipmap.pay_qrcode_lijin_img), null, null, null);
|
||||
// viewBinding.shuaxinIv.setTextColor(whiteColor);
|
||||
// }
|
||||
viewBinding.mainAboutTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
|
||||
payType = DataUtils.get(this, "pay_type", 0);
|
||||
viewBinding.shoukuanmaLy.setOnClickListener(v -> changeType(0));
|
||||
|
||||
viewBinding.fukuanmaLy.setOnClickListener(v -> {
|
||||
getWallet();
|
||||
changeType(1);
|
||||
});
|
||||
// loginBean = lu1();
|
||||
// if(loginBean!=null){
|
||||
viewBinding.userNameTv.setText(IMKitClient.getUserInfo().getName());
|
||||
viewBinding.userHeadIv.setData(IMKitClient.getUserInfo().getAvatar(), IMKitClient.getUserInfo().getName());
|
||||
// }
|
||||
viewBinding.mainMoreSettingsSafa.setOnClickListener(v -> {
|
||||
// SelectPayTypeDialog selectPayTypeDialog = new SelectPayTypeDialog(CollectionAndPaymentActivity.this,payType,walletBean);
|
||||
// selectPayTypeDialog.setOnToVipListener(this);
|
||||
// selectPayTypeDialog.show();
|
||||
});
|
||||
viewBinding.baocunShoukuanmaLy.setOnClickListener(v -> {
|
||||
doSaveQrcode();
|
||||
|
||||
});
|
||||
changePayType();
|
||||
viewBinding.shuaxinIv.setOnClickListener(v -> {
|
||||
toShuaxin();
|
||||
});
|
||||
viewBinding.shuaxinIv1.setOnClickListener(v -> {
|
||||
toShuaxin();
|
||||
});
|
||||
|
||||
// viewBinding.fukuanQrcodeIv.setOnClickListener(v -> {
|
||||
// switch (FingerManager.checkSupport(CollectionAndPaymentActivity.this))
|
||||
// {
|
||||
// case DEVICE_UNSUPPORTED:
|
||||
// showPayDialog(0);
|
||||
// break;
|
||||
// case SUPPORT_WITHOUT_DATA:
|
||||
// showPayDialog(1);
|
||||
// break;
|
||||
// case SUPPORT:
|
||||
// showPayDialog(2);
|
||||
// break;
|
||||
// }
|
||||
// });
|
||||
|
||||
|
||||
Bitmap bitmap = CodeUtils.createQRCode(String.format(IMUIKitConfig.SHARE_USER_PAYMENT_CODE, IMKitClient.account()), DataUtils.dip2px(this, 175.0f), null);
|
||||
if (bitmap != null) {
|
||||
viewBinding.shoukuanmaQrcodeIv.setImageBitmap(bitmap);
|
||||
}
|
||||
if (isShoukuan) {
|
||||
changeType(0);
|
||||
} else {
|
||||
getWallet();
|
||||
}
|
||||
initStartDaojishi();
|
||||
|
||||
// viewBinding.fukuanQrcodeIv.setOnClickListener(new View.OnClickListener() {
|
||||
// @Override
|
||||
// public void onClick(View v) {
|
||||
// startActivity(new Intent(LipinDuiHuanActivity.this,LipinDuiHuanSuccessActivity.class));
|
||||
// }
|
||||
// });
|
||||
|
||||
}
|
||||
|
||||
private void initStartDaojishi() {
|
||||
if (myCountDownTimer != null) {
|
||||
myCountDownTimer.cancel();
|
||||
}
|
||||
myCountDownTimer = new MyCountDownTimer(1000 * 24 * 60 * 60, 3000);
|
||||
myCountDownTimer.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (myCountDownTimer != null) {
|
||||
myCountDownTimer.cancel();
|
||||
}
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
String payOuterCode;
|
||||
|
||||
private void getPayOuterCode() {
|
||||
Api.getInstance().payOuterCode()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<String> feedbackResp) {
|
||||
payOuterCode = feedbackResp.data;
|
||||
if (walletBean != null) {
|
||||
Bitmap bitmap = CodeUtils.createQRCode(payOuterCode + "/" + walletBean.getSilverCoin(), DataUtils.dip2px(LipinDuiHuanActivity.this, 175.0f), null);
|
||||
if (bitmap != null) {
|
||||
viewBinding.fukuanQrcodeIv.setImageBitmap(bitmap);
|
||||
}
|
||||
} else {
|
||||
Bitmap bitmap = CodeUtils.createQRCode(payOuterCode, DataUtils.dip2px(LipinDuiHuanActivity.this, 175.0f), null);
|
||||
if (bitmap != null) {
|
||||
viewBinding.fukuanQrcodeIv.setImageBitmap(bitmap);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toShuaxin() {
|
||||
|
||||
RotateAnimation ra = new RotateAnimation(0, 360, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
|
||||
// 设置动画时长
|
||||
ra.setDuration(1000);
|
||||
// 启动动画
|
||||
viewBinding.shuaxinIv1.startAnimation(ra);
|
||||
getWallet();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void changePayType() {
|
||||
viewBinding.yueTv.setVisibility(View.INVISIBLE);
|
||||
if (payType == 0) {
|
||||
viewBinding.payTypeTv.setText(R.string.silver_coins_txt);
|
||||
viewBinding.yueTv.setVisibility(View.VISIBLE);
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.wallet_yinbi_img);
|
||||
} else if (payType == 1) {
|
||||
viewBinding.payTypeTv.setText("line pay");
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.line_pay_img);
|
||||
} else {
|
||||
viewBinding.payTypeTv.setText(R.string.neweb_txt);
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.newebpay_img);
|
||||
}
|
||||
if(viewType==1){
|
||||
viewBinding.payTypeIv.setImageResource(R.mipmap.wallet_lijin_img);
|
||||
viewBinding.payTypeTv.setText("礼金积分");
|
||||
viewBinding.payTypeTv.setTextColor(getResources().getColor(R.color.color_fff5cb));
|
||||
viewBinding.yueTv.setVisibility(View.VISIBLE);
|
||||
viewBinding.yueTv.setTextColor(getResources().getColor(R.color.color_fffdf6));
|
||||
viewBinding.shuaxinIv1.setColorFilter(Color.WHITE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将2维码保存到系统相册。
|
||||
*/
|
||||
private void doSaveQrcode() {
|
||||
// 先生成bitmap对象
|
||||
Bitmap bmp = DataUtils.generateBitmap(viewBinding.shoukuanRy1);
|
||||
// bitmap对象生成成功
|
||||
if (bmp != null) {
|
||||
// 保存到相册成功
|
||||
if (ToolKits.saveBmp2Gallery(LipinDuiHuanActivity.this, bmp)) {
|
||||
ToastX.showShortToast(getString(R.string.qrcode_generate_activity_qr_save_sucess));
|
||||
} else {
|
||||
ToastX.showShortToast(getString(R.string.qrcode_generate_activity_qr_save_fail));
|
||||
|
||||
}
|
||||
} else {
|
||||
Log.w("TAG", "将2维码保存到相册时失败了,从view生成Bitmap对象失败,生成后的bmp=null!");
|
||||
ToastX.showShortToast(getString(R.string.qrcode_generate_activity_qr_generate_fail));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void changeType(int i) {
|
||||
|
||||
if (i == 0) {
|
||||
viewBinding.shoukuanRy.setVisibility(View.VISIBLE);
|
||||
viewBinding.fukuanRy.setVisibility(View.GONE);
|
||||
viewBinding.shoukuanmaIv.setImageResource(R.mipmap.pay_shoukuan_true);
|
||||
viewBinding.fukuanmaIv.setImageResource(R.mipmap.pay_zhifu_false);
|
||||
viewBinding.shoukuanmaTv.setTextColor(getResources().getColor(R.color.color_themeblue));
|
||||
viewBinding.fukuanmaTv.setTextColor(getResources().getColor(R.color.color_333333));
|
||||
viewBinding.shoukuanmaLy.setBackgroundResource(R.mipmap.pay_button_true);
|
||||
viewBinding.fukuanmaLy.setBackgroundResource(R.mipmap.pay_button_false);
|
||||
// viewBinding.mainAboutTitleBar.getTitleTextView().setText(getString(R.string.shoukuanma_txt));
|
||||
|
||||
} else {
|
||||
viewBinding.shoukuanRy.setVisibility(View.GONE);
|
||||
viewBinding.fukuanRy.setVisibility(View.VISIBLE);
|
||||
viewBinding.shoukuanmaIv.setImageResource(R.mipmap.pay_shoukuan_false);
|
||||
viewBinding.fukuanmaIv.setImageResource(R.mipmap.pay_zhifu_true);
|
||||
viewBinding.fukuanmaTv.setTextColor(getResources().getColor(R.color.color_themeblue));
|
||||
viewBinding.shoukuanmaTv.setTextColor(getResources().getColor(R.color.color_333333));
|
||||
viewBinding.shoukuanmaLy.setBackgroundResource(R.mipmap.pay_button_false);
|
||||
viewBinding.fukuanmaLy.setBackgroundResource(R.mipmap.pay_button_true);
|
||||
// viewBinding.mainAboutTitleBar.getTitleTextView().setText(getString(R.string.fukuanma_txt));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
private WalletBean walletBean;
|
||||
|
||||
private void getWallet() {
|
||||
Api.getInstance().walletInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<WalletBean> feedbackResp) {
|
||||
walletBean = feedbackResp.data;
|
||||
viewBinding.yueTv.setText(String.format(getResources().getString(R.string.yuee_2f_txt), AppUtils.getQian(feedbackResp.data.getSilverCoin())));
|
||||
// if(viewType==1){
|
||||
// viewBinding.yueTv.setText(String.format(getResources().getString(R.string.yuee_2f_txt), AppUtils.getQian(feedbackResp.data.getGiftCoin()*100)));
|
||||
// }
|
||||
getPayOuterCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void toType(int type) {
|
||||
DataUtils.set(LipinDuiHuanActivity.this, "pay_type", type);
|
||||
payType = type;
|
||||
changePayType();
|
||||
}
|
||||
|
||||
MyCountDownTimer myCountDownTimer;
|
||||
int count = 0;
|
||||
|
||||
//倒计时函数
|
||||
private class MyCountDownTimer extends CountDownTimer {
|
||||
|
||||
public MyCountDownTimer(long millisInFuture, long countDownInterval) {
|
||||
super(millisInFuture, countDownInterval);
|
||||
}
|
||||
|
||||
//计时过程
|
||||
@Override
|
||||
public void onTick(long l) {
|
||||
count++;
|
||||
getPayInfo();
|
||||
if (count > 59) {
|
||||
count = 0;
|
||||
if (!isShoukuan) {
|
||||
getWallet();
|
||||
}
|
||||
}
|
||||
if ((payDialog != null && payDialog.isShowing()) || (payCashFingerDialog != null && payCashFingerDialog.isShowing())) {
|
||||
if (System.currentTimeMillis() - passwordTime > 2 * 60 * 1000) {
|
||||
if (payDialog != null) {
|
||||
payDialog.dismiss();
|
||||
}
|
||||
if (payCashFingerDialog != null) {
|
||||
payCashFingerDialog.dismiss();
|
||||
}
|
||||
if (payInfoBeanTop != null) {
|
||||
cancelPay(payInfoBeanTop.getPayId());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//计时完毕的方法
|
||||
@Override
|
||||
public void onFinish() {
|
||||
finish();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
PayInfoBean payInfoBeanTop = null;
|
||||
|
||||
private void getPayInfo() {
|
||||
Api.getInstance().getPayInfo()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<PayInfoBean> feedbackResp) {
|
||||
//{"data":{"headImage":"https://letschat.oss-cn-hongkong.aliyuncs.com/media/userAvatarFileName/dc873aed-2726-4b23-83af-0a8f3e1dbc17_1699842807436.jpg","nickname":"\uD83D\uDC36不乖","payId":2,"amount":2000},"code":1}
|
||||
if (payInfoBeanTop != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (feedbackResp.data != null) {
|
||||
payInfoBeanTop = feedbackResp.data;
|
||||
getWallet();
|
||||
if (DataUtils.get(LipinDuiHuanActivity.this, "hasMianMi", false) && payInfoBeanTop.getAmount() <= 1000 * 100) {
|
||||
toChange(payInfoBeanTop, null, true);
|
||||
} else {
|
||||
passwordTime = System.currentTimeMillis();
|
||||
if (DataUtils.get(LipinDuiHuanActivity.this, "hasFinger", false)) {
|
||||
showPayCashFingerDialog(feedbackResp.data);
|
||||
} else {
|
||||
showPayCashDialog(feedbackResp.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
long passwordTime = 0;
|
||||
|
||||
|
||||
private void showPayCashDialog(PayInfoBean payInfoBean) {
|
||||
payDialog = new PayCashDialog(LipinDuiHuanActivity.this, String.format("%.2f", payInfoBean.getAmount() / 100f), true, 0, walletBean,
|
||||
null, 2, String.format(getString(R.string.fukuangei_txt), payInfoBean.getNickname()), 1);
|
||||
//免密支付的 要告诉 为什么 没有免密
|
||||
if ((payInfoBean.getAmount() > 1000 * 100) && DataUtils.get(LipinDuiHuanActivity.this, "hasMianMi", false)) {
|
||||
payDialog = new PayCashDialog(LipinDuiHuanActivity.this, String.format("%.2f", payInfoBean.getAmount() / 100f), true, 0, walletBean,
|
||||
null, 2, String.format(getString(R.string.fukuangei_txt), payInfoBean.getNickname()), getString(R.string.zfjecgxz_txt), 1);
|
||||
}
|
||||
payDialog.setOntoAlbumListener(new PayCashDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onPayPass(String position) {
|
||||
|
||||
toChange(payInfoBean, position, false);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onChangeFinger() {
|
||||
showPayCashFingerDialog(payInfoBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(LipinDuiHuanActivity.this,
|
||||
getString(R.string.quxiaozhifu_dialog_txt), true);
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
cancelPay(payInfoBean.getPayId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
actionDialog.dismiss();
|
||||
payDialog.show();
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
|
||||
}
|
||||
});
|
||||
payDialog.show();
|
||||
}
|
||||
|
||||
private void cancelPay(Long payId) {
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("payId", payId);
|
||||
Api.getInstance().payOuterCodeCancel(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result feedbackResp) {
|
||||
ToastX.showShortToast(R.string.zhifuchengong_txt1);
|
||||
payInfoBeanTop = null;
|
||||
if (payDialog != null) {
|
||||
payDialog.dismiss();
|
||||
}
|
||||
if (payCashFingerDialog != null) {
|
||||
payCashFingerDialog.dismiss();
|
||||
}
|
||||
getWallet();
|
||||
initStartDaojishi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void toChange(PayInfoBean payInfoBean, String password, boolean isMianMi) {
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("payId", payInfoBean.getPayId());
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
maps.put("payPassword", password);
|
||||
maps.put("payVerifyCode", 1);
|
||||
} else {
|
||||
maps.put("payVerifyCode", 3);
|
||||
|
||||
}
|
||||
|
||||
Api.getInstance().payOuterCodeConfirm(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result feedbackResp) {
|
||||
ToastX.showShortToast(R.string.zhifuchengong_txt);
|
||||
payInfoBeanTop = null;
|
||||
getWallet();
|
||||
Intent intent = new Intent(LipinDuiHuanActivity.this, LipinDuiHuanSuccessActivity.class);
|
||||
intent.putExtra("payId", payInfoBean.getPayId());
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
if (isMianMi) {//免密支付失败 校验支付密码 这些
|
||||
if (DataUtils.get(LipinDuiHuanActivity.this, "hasFinger", false)) {
|
||||
showPayCashFingerDialog(payInfoBeanTop);
|
||||
} else {
|
||||
showPayCashDialog(payInfoBeanTop);
|
||||
}
|
||||
} else {
|
||||
payInfoBeanTop = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void showPayCashFingerDialog(PayInfoBean payInfoBean) {
|
||||
//Context context, String data, boolean showNumber, int payType, WalletBean walletBean, SelectPayTypeDialog.OnToTypeListener onToTypeListener, int isShowFinger
|
||||
payCashFingerDialog = new PayCashFingerDialog(this, String.format("%.2f", payInfoBean.getAmount() / 100f), true,
|
||||
0, walletBean, null, 2, String.format(getString(R.string.fukuangei_txt), payInfoBean.getNickname()), true);
|
||||
if ((payInfoBean.getAmount() > 1000 * 100) && DataUtils.get(LipinDuiHuanActivity.this, "hasMianMi", false)) {
|
||||
payCashFingerDialog = new PayCashFingerDialog(this, String.format("%.2f", payInfoBean.getAmount() / 100f), true,
|
||||
0, walletBean, null, 2, String.format(getString(R.string.fukuangei_txt), payInfoBean.getNickname()), getString(R.string.zfjecgxz_txt), true);
|
||||
}
|
||||
payCashFingerDialog.setOntoAlbumListener(new PayCashFingerDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onChangePassword() {
|
||||
showPayCashDialog(payInfoBean);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toFinger() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
checkPayFinger(payInfoBean);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(LipinDuiHuanActivity.this,
|
||||
getString(R.string.quxiaozhifu_dialog_txt), true);
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
cancelPay(payInfoBean.getPayId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
actionDialog.dismiss();
|
||||
payCashFingerDialog.show();
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
});
|
||||
payCashFingerDialog.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void checkPayFinger(PayInfoBean payInfoBean) {
|
||||
|
||||
FingerManager.build().setApplication(IMApplication.getInstance())
|
||||
.setTitle(" ")
|
||||
.setDes(" ")
|
||||
.setNegativeText(" ")
|
||||
.setFingerCheckCallback(new SimpleFingerCheckCallback() {
|
||||
|
||||
@Override
|
||||
public void onSucceed() {
|
||||
ToastX.showShortToast("验证成功");
|
||||
payCashFingerDialog.dismiss();
|
||||
toChange(payInfoBean, null, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastX.showShortToast("验证失败");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
ToastX.showShortToast("您取消了识别");
|
||||
|
||||
}
|
||||
})
|
||||
.setFingerChangeCallback(new AonFingerChangeCallback() {
|
||||
|
||||
@Override
|
||||
protected void onFingerDataChange() {
|
||||
// ToastX.showShortToast("指纹数据发生了变化");
|
||||
FingerManager.updateFingerData(LipinDuiHuanActivity.this);
|
||||
new Handler().postDelayed(() -> checkPayFinger(payInfoBean), 1000);
|
||||
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.startListener(LipinDuiHuanActivity.this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.databinding.ActivityLipinSuccessBinding;
|
||||
|
||||
import com.hbl.lewan.model.FukuanResultBean;
|
||||
import com.hbl.lewan.network.Api;
|
||||
import com.hbl.lewan.network.BaseObserver;
|
||||
import com.hbl.lewan.network.Result;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
|
||||
public class LipinDuiHuanSuccessActivity extends BaseActivity {
|
||||
ActivityLipinSuccessBinding viewBinding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_fcfcfc));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_white));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityLipinSuccessBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
initView();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
protected void initView() {
|
||||
viewBinding.aboutTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
viewBinding.buttonTv.setOnClickListener(v -> finish());
|
||||
getPayInfo();
|
||||
}
|
||||
|
||||
private void getPayInfo() {
|
||||
|
||||
Api.getInstance().getPayResult(getIntent().getLongExtra("payId",0l)+"")
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<FukuanResultBean> feedbackResp) {
|
||||
viewBinding.numberTv.setText(String.format("%.2f",feedbackResp.data.getAmount()/100f));
|
||||
viewBinding.timeTv.setText(feedbackResp.data.getPayTime()+"");
|
||||
if(!TextUtils.isEmpty(feedbackResp.data.getRemark())){
|
||||
String text = feedbackResp.data.getRemark();
|
||||
if(text.endsWith("-")){
|
||||
text = text.substring(0,text.length());
|
||||
}
|
||||
String[] name = text.split("[-]");
|
||||
if(name.length>1){
|
||||
viewBinding.mendianTv.setText(name[0]);
|
||||
String names ="";
|
||||
for (int i =1;i<name.length;i++){
|
||||
names+=(name[i]+",");
|
||||
}
|
||||
names = names.substring(0,names.length()-1);
|
||||
viewBinding.lipinTv.setText(names);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
186
app/src/main/java/com/hbl/lewan/pay/NfcReaderActivity.java
Normal file
186
app/src/main/java/com/hbl/lewan/pay/NfcReaderActivity.java
Normal file
@@ -0,0 +1,186 @@
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.nfc.NfcAdapter;
|
||||
import android.nfc.NfcManager;
|
||||
import android.nfc.Tag;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.provider.Settings;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.base.LllChatBaseActivity;
|
||||
import com.hbl.lewan.databinding.ActivityNfcreaderBinding;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
|
||||
|
||||
public class NfcReaderActivity extends LllChatBaseActivity {
|
||||
|
||||
private NfcAdapter nfcAdapter;
|
||||
public ActivityNfcreaderBinding binding;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
binding = ActivityNfcreaderBinding.inflate(getLayoutInflater());
|
||||
setContentView(binding.getRoot());
|
||||
binding.aboutTitleBar.setOnBackIconClickListener(view -> onBackPressed());
|
||||
// 检查设备是否支持NFC功能
|
||||
NfcManager nfcManager = (NfcManager) getSystemService(Context.NFC_SERVICE);
|
||||
nfcAdapter = nfcManager.getDefaultAdapter();
|
||||
if (nfcAdapter == null) {
|
||||
// 设备不支持NFC功能
|
||||
Toast.makeText(this, "该设备不支持NFC功能", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
// 检查NFC是否打开
|
||||
if (!nfcAdapter.isEnabled()) {
|
||||
// NFC未打开,跳转到系统设置页面
|
||||
startActivity(new Intent(Settings.ACTION_NFC_SETTINGS));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int initNavigationBarColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int initStatusBarColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (nfcAdapter != null) {
|
||||
showReadDialog(true);
|
||||
nfcAdapter.enableReaderMode(this, new NfcAdapter.ReaderCallback() {
|
||||
@Override
|
||||
public void onTagDiscovered(Tag tag) {
|
||||
byte[] byteArray = tag.getId();
|
||||
for (int i = 0; i < byteArray.length / 2; i++) {
|
||||
byte temp = byteArray[i];
|
||||
byteArray[i] = byteArray[byteArray.length - 1 - i];
|
||||
byteArray[byteArray.length - 1 - i] = temp;
|
||||
}
|
||||
String result = byteArrayToHexStr(byteArray);
|
||||
runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showReadDialog(false);
|
||||
binding.tvNfcresult.setText("结果:" + result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
}, (NfcAdapter.FLAG_READER_NFC_F |
|
||||
NfcAdapter.FLAG_READER_NFC_V |
|
||||
NfcAdapter.FLAG_READER_NFC_BARCODE), null);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
//转hex
|
||||
public static String byteArrayToHexStr(byte[] byteArray) {
|
||||
if (byteArray == null) {
|
||||
return null;
|
||||
}
|
||||
char[] hexArray = "0123456789abcdef".toCharArray();
|
||||
char[] hexChars = new char[byteArray.length * 2];
|
||||
for (int j = 0; j < byteArray.length; j++) {
|
||||
int v = byteArray[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
}
|
||||
return new String(hexChars);
|
||||
|
||||
}
|
||||
|
||||
BottomSheetDialog bottomSheetDialog;
|
||||
View bottomView;
|
||||
TextView tvTitle;
|
||||
AppCompatImageView ivStatus;
|
||||
TextView tvStatus;
|
||||
TextView tvCancel;
|
||||
|
||||
public void showReadDialog(boolean isStart) {
|
||||
if (bottomSheetDialog != null) {
|
||||
bottomSheetDialog.dismiss();
|
||||
}
|
||||
bottomSheetDialog = new BottomSheetDialog(this, R.style.BottomSheetDialog);
|
||||
bottomView = LayoutInflater.from(this).inflate(R.layout.dialog_bottom_nfcread, null);
|
||||
tvTitle = bottomView.findViewById(R.id.tv_nfcread_title);
|
||||
ivStatus = bottomView.findViewById(R.id.iv_nfcread_status);
|
||||
tvStatus = bottomView.findViewById(R.id.tv_nfcread_status);
|
||||
tvCancel = bottomView.findViewById(R.id.tv_nfcread_cancel);
|
||||
bottomSheetDialog.setContentView(bottomView);
|
||||
if (isStart) {
|
||||
tvTitle.setVisibility(View.VISIBLE);
|
||||
tvCancel.setVisibility(View.VISIBLE);
|
||||
tvStatus.setText(getString(com.hbl.lewan.R.string.nfctitle_dialog_status));
|
||||
Glide.with(this).load(R.mipmap.nfc_read).into(ivStatus);
|
||||
tvCancel.setOnClickListener(view -> {
|
||||
nfcAdapter.disableReaderMode(this);
|
||||
bottomSheetDialog.dismiss();
|
||||
});
|
||||
} else {
|
||||
tvTitle.setVisibility(View.INVISIBLE);
|
||||
tvCancel.setVisibility(View.INVISIBLE);
|
||||
tvStatus.setText(getString(R.string.nfctitle_dialog_succes));
|
||||
ivStatus.setImageResource(R.mipmap.nfc_success);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
bottomSheetDialog.dismiss();
|
||||
}
|
||||
}, 1000);
|
||||
}
|
||||
bottomSheetDialog.setCanceledOnTouchOutside(false);
|
||||
bottomSheetDialog.show();
|
||||
}
|
||||
// private NfcReadBottomDialog readBottomDialog;
|
||||
//
|
||||
// public void showReadDialog() {
|
||||
// if (readBottomDialog == null) {
|
||||
// readBottomDialog = new NfcReadBottomDialog(this);
|
||||
// }
|
||||
// readBottomDialog.showStart(
|
||||
// () -> {
|
||||
//
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// public void showSuccessDialog() {
|
||||
// if (readBottomDialog == null) {
|
||||
// readBottomDialog = new NfcReadBottomDialog(this);
|
||||
// }
|
||||
// readBottomDialog.showEnd();
|
||||
// }
|
||||
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
if (nfcAdapter != null) {
|
||||
nfcAdapter.disableReaderMode(this);
|
||||
}
|
||||
}
|
||||
}
|
||||
540
app/src/main/java/com/hbl/lewan/pay/PaymentActivity.java
Normal file
540
app/src/main/java/com/hbl/lewan/pay/PaymentActivity.java
Normal file
@@ -0,0 +1,540 @@
|
||||
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.RotateAnimation;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.codersun.fingerprintcompat.AonFingerChangeCallback;
|
||||
import com.codersun.fingerprintcompat.FingerManager;
|
||||
import com.codersun.fingerprintcompat.SimpleFingerCheckCallback;
|
||||
import com.hbl.lewan.IMApplication;
|
||||
import com.hbl.lewan.IMUIKitConfig;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.contact.UserInfoActivity;
|
||||
import com.hbl.lewan.databinding.ActivityCollectionAndPaymentBinding;
|
||||
import com.hbl.lewan.databinding.ActivityPaymentBinding;
|
||||
import com.hbl.lewan.dialog.ActionConfirmDialog;
|
||||
import com.hbl.lewan.dialog.PayCashDialog;
|
||||
import com.hbl.lewan.dialog.PayCashFingerDialog;
|
||||
import com.hbl.lewan.dialog.PayDialog;
|
||||
import com.hbl.lewan.dialog.SelectPayTypeDialog;
|
||||
import com.hbl.lewan.main.mine.ChangeAccoutActionActivity;
|
||||
import com.hbl.lewan.model.BindBean;
|
||||
import com.hbl.lewan.model.LoginBean;
|
||||
import com.hbl.lewan.model.WalletBean;
|
||||
import com.hbl.lewan.network.Api;
|
||||
import com.hbl.lewan.network.BaseObserver;
|
||||
import com.hbl.lewan.network.Result;
|
||||
import com.hbl.lewan.redpack.TransferAccountsActivity;
|
||||
import com.hbl.lewan.utils.DataUtils;
|
||||
import com.hbl.lewan.utils.GsonUtils;
|
||||
import com.hbl.lewan.utils.KeyboardUtil;
|
||||
import com.hbl.lewan.utils.LogUtils;
|
||||
import com.hbl.lewan.utils.ToolKits;
|
||||
import com.hbl.lewan.wallet.PaySettingActivity;
|
||||
import com.hbl.lewan.wallet.SetPayPasswordActivity;
|
||||
import com.hbl.lewan.wallet.WalletInfoActivity;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.msg.MessageBuilder;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.uinfo.UserService;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.netease.yunxin.kit.chatkit.repo.ChatRepo;
|
||||
import com.netease.yunxin.kit.chatkit.ui.custom.TransferAttachment;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.TransferBean;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
import com.netease.yunxin.kit.common.ui.utils.AvatarColor;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.provider.FetchCallback;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class PaymentActivity extends BaseActivity {
|
||||
|
||||
PayCashFingerDialog payCashFingerDialog;
|
||||
WalletBean walletBean;
|
||||
BindBean bindBean;
|
||||
float number = 0;
|
||||
PayCashDialog payDialog;
|
||||
ActivityPaymentBinding viewBinding;
|
||||
String userId;
|
||||
NimUserInfo userInfo;
|
||||
String userName;
|
||||
private int userType = 0; //用户类型, 0普通用户 1商户
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_fcfcfc));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_white));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityPaymentBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
initView();
|
||||
}
|
||||
userType = getIntent().getIntExtra("userType", 0); //
|
||||
userId = getIntent().getStringExtra("userId");
|
||||
if (userType == 0) {
|
||||
userInfo = NIMClient.getService(UserService.class).getUserInfo(userId);
|
||||
if (userInfo != null) {
|
||||
viewBinding.userNameTv.setText(userInfo.getName());
|
||||
viewBinding.userHeadIv.setData(userInfo.getAvatar(), userInfo.getName());
|
||||
userName = userInfo.getName();
|
||||
} else {
|
||||
getUserInfo1();
|
||||
}
|
||||
} else {
|
||||
viewBinding.numberHintEt.setHint("0");
|
||||
viewBinding.numberHintEt.setInputType(InputType.TYPE_CLASS_NUMBER);
|
||||
viewBinding.tvAmountTitle.setText("Cash:");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void getUserInfo1() {
|
||||
Api.getInstance().userInfo(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<LoginBean> feedbackResp) {
|
||||
viewBinding.userNameTv.setText(feedbackResp.data.getNickNameWithRemark());
|
||||
viewBinding.userHeadIv.setData(feedbackResp.data.getUserAvatarFileName(), feedbackResp.data.getNickNameWithRemark());
|
||||
userName = feedbackResp.data.getNickNameWithRemark();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
// WidgetUtils.showToast(getActivity(), msg, WidgetUtils.ToastType.ERROR);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void initView() {
|
||||
viewBinding.aboutTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
|
||||
viewBinding.tvLogin.setOnClickListener(v -> {
|
||||
if (bindBean != null) {
|
||||
if (!bindBean.getPhoneBind()) {
|
||||
showDialog();
|
||||
} else {
|
||||
if (!bindBean.getPayPasswordSet()) {
|
||||
showDialogPay();
|
||||
} else {
|
||||
if (TextUtils.isEmpty(viewBinding.numberHintEt.getText().toString().trim())) {
|
||||
ToastX.showShortToast(R.string.zzjebnwk_txt);
|
||||
return;
|
||||
}
|
||||
float number1 = Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim()) * 100;
|
||||
if (number1 < 1) {
|
||||
ToastX.showShortToast(R.string.zzjebnsy_txt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (walletBean != null) {
|
||||
if (Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim()) > (walletBean.getGoldCoin() / 100f)) {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(PaymentActivity.this,
|
||||
getString(R.string.sfqcz_txt), getString(R.string.general_cancel), getString(R.string.quchongzhi_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
Intent intent = new Intent(PaymentActivity.this, WalletInfoActivity.class);
|
||||
intent.putExtra("isG", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
ToastX.showShortToast(R.string.yebz_txt);
|
||||
|
||||
return;
|
||||
}
|
||||
number = Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim());
|
||||
// PayDialog payDialog = new PayDialog(PaymentActivity.this, number + "", true);
|
||||
// payDialog.setOntoAlbumListener(new PayDialog.OnListItemClickListener() {
|
||||
// @Override
|
||||
// public void onPayPass(String position) {
|
||||
// toChange(position, number);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void dimess() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// payDialog.show();
|
||||
if (DataUtils.get(PaymentActivity.this, "hasMianMi", false) && number <= 1000) {
|
||||
toChange(null, number, 2);
|
||||
} else {
|
||||
if (DataUtils.get(PaymentActivity.this, "hasFinger", false)) {
|
||||
showPayCashFingerDialog();
|
||||
} else {
|
||||
showPayCashDialog();
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
ToastX.showShortToast(R.string.hqqbxxsb_tx);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ToastX.showShortToast(R.string.hqqbxxsb_tx);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
viewBinding.numberHintEt.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String input = s.toString();
|
||||
if (input.startsWith(".")) {
|
||||
viewBinding.numberHintEt.setText("0" + viewBinding.numberHintEt.getText().toString());
|
||||
}
|
||||
if (input.contains(".")) {
|
||||
int dotIndex = input.indexOf(".");
|
||||
if (input.length() - dotIndex - 1 > 2) {
|
||||
viewBinding.numberHintEt.setText(input.substring(0, dotIndex + 3));
|
||||
}
|
||||
}
|
||||
viewBinding.numberHintEt.setSelection(viewBinding.numberHintEt.getText().length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private String getDialogUserName() {
|
||||
return String.format(getString(R.string.fukuangei_txt), userType == 0 ? userInfo.getName() : getString(R.string.shangjia_txt));
|
||||
}
|
||||
|
||||
private void showPayCashDialog() {
|
||||
payDialog = new PayCashDialog(PaymentActivity.this, number + "", true, 0, walletBean,
|
||||
null, 2, getDialogUserName());
|
||||
if (DataUtils.get(PaymentActivity.this, "hasMianMi", false) && ((int) (number * 100) > 1000 * 100)) {
|
||||
payDialog = new PayCashDialog(PaymentActivity.this, number + "", true, 0, walletBean,
|
||||
null, 2, getDialogUserName(), getString(R.string.zfjecgxz_txt));
|
||||
}
|
||||
payDialog.setOntoAlbumListener(new PayCashDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onPayPass(String position) {
|
||||
toChange(position, number, 1);
|
||||
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onChangeFinger() {
|
||||
showPayCashFingerDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
payDialog.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
payDialog.show();
|
||||
}
|
||||
|
||||
private void showPayCashFingerDialog() {
|
||||
//Context context, String data, boolean showNumber, int payType, WalletBean walletBean, SelectPayTypeDialog.OnToTypeListener onToTypeListener, int isShowFinger
|
||||
payCashFingerDialog = new PayCashFingerDialog(this, number + "", true, 0, walletBean, null, 2,
|
||||
getDialogUserName());
|
||||
if (DataUtils.get(PaymentActivity.this, "hasMianMi", false) && ((int) (number * 100) > 1000 * 100)) {
|
||||
payCashFingerDialog = new PayCashFingerDialog(this, number + "", true, 0, walletBean, null, 2,
|
||||
getDialogUserName(), getString(R.string.zfjecgxz_txt));
|
||||
}
|
||||
payCashFingerDialog.setOntoAlbumListener(new PayCashFingerDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onChangePassword() {
|
||||
showPayCashDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toFinger() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
checkPayFinger();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
payCashFingerDialog.dismiss();
|
||||
}
|
||||
});
|
||||
payCashFingerDialog.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void checkPayFinger() {
|
||||
|
||||
FingerManager.build().setApplication(IMApplication.getInstance())
|
||||
.setTitle(" ")
|
||||
.setDes(" ")
|
||||
.setNegativeText(" ")
|
||||
.setFingerCheckCallback(new SimpleFingerCheckCallback() {
|
||||
|
||||
@Override
|
||||
public void onSucceed() {
|
||||
ToastX.showShortToast("验证成功");
|
||||
payCashFingerDialog.dismiss();
|
||||
toChange(null, number, 2);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastX.showShortToast("验证失败");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
ToastX.showShortToast("您取消了识别");
|
||||
|
||||
}
|
||||
})
|
||||
.setFingerChangeCallback(new AonFingerChangeCallback() {
|
||||
|
||||
@Override
|
||||
protected void onFingerDataChange() {
|
||||
ToastX.showShortToast("指纹数据发生了变化");
|
||||
FingerManager.updateFingerData(PaymentActivity.this);
|
||||
new Handler().postDelayed(() -> checkPayFinger(), 1000);
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.startListener(PaymentActivity.this);
|
||||
}
|
||||
|
||||
|
||||
private void showDialog() {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(PaymentActivity.this,
|
||||
getString(R.string.bind_phone_des_txt), getString(R.string.nobind_txt), getString(R.string.tobind_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
Intent intent = new Intent(PaymentActivity.this, ChangeAccoutActionActivity.class);
|
||||
intent.putExtra("type", ChangeAccoutActionActivity.TYPE_BIND_PHONE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
|
||||
private void showDialogPay() {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(PaymentActivity.this,
|
||||
getString(R.string.bind_phone_des_txt1), getString(com.netease.yunxin.kit.chatkit.ui.R.string.cancel_txt), getString(com.netease.yunxin.kit.chatkit.ui.R.string.to_sett_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
// Intent intent = new Intent(PaymentActivity.this, ChangeAccoutActionActivity.class);
|
||||
// intent.putExtra("type", ChangeAccoutActionActivity.TYPE_CHANGE_PAY_PASSWORD);
|
||||
// startActivity(intent);
|
||||
Intent intent = new Intent(PaymentActivity.this, SetPayPasswordActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
|
||||
|
||||
private void toChange(String password, float number, int type) {
|
||||
KeyboardUtil.hideSoftInput(this);
|
||||
if (userType == 0) {
|
||||
transfer(password, number, type);
|
||||
} else {
|
||||
transferBiz(password, number, type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void transfer(String password, float number, int type) {
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("amount", (int) (number * 100));
|
||||
maps.put("senderUid", Integer.parseInt(IMKitClient.account()));
|
||||
maps.put("receiverUid", Integer.parseInt(userId));
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
maps.put("payPassword", password);
|
||||
}
|
||||
if (!TextUtils.isEmpty(viewBinding.memoEt.getText().toString().trim())) {
|
||||
maps.put("remark", viewBinding.memoEt.getText().toString().trim());
|
||||
}
|
||||
maps.put("coinType", 0);
|
||||
maps.put("substationId", IMUIKitConfig.SUBSTATIONID);
|
||||
maps.put("payVerifyCode", type);
|
||||
maps.put("receiptType", 2);
|
||||
|
||||
Api.getInstance().transferMoney(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<TransferBean> feedbackResp) {
|
||||
Intent intent = new Intent(PaymentActivity.this, PaymentSuccessActivity.class);
|
||||
intent.putExtra("bean", feedbackResp.data);
|
||||
intent.putExtra("name", userName);
|
||||
|
||||
startActivity(intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void transferBiz(String password, float number, int type) {
|
||||
KeyboardUtil.hideSoftInput(this);
|
||||
Map<String, Object> maps = new HashMap<>();
|
||||
maps.put("amount", number);
|
||||
maps.put("payVerifyCode", type);
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
maps.put("payPassword", password);
|
||||
}
|
||||
if (!TextUtils.isEmpty(viewBinding.memoEt.getText().toString().trim())) {
|
||||
maps.put("remark", viewBinding.memoEt.getText().toString().trim());
|
||||
}
|
||||
maps.put("bizId", userId);
|
||||
Api.getInstance().transferCashPay(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result feedbackResp) {
|
||||
ToastX.showShortToast(getString(R.string.zhiufuchengg_txt));
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getWallet();
|
||||
bindInfo();
|
||||
}
|
||||
|
||||
|
||||
private void bindInfo() {
|
||||
// if (u != null) {
|
||||
Api.getInstance().bindInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<BindBean>>() {
|
||||
@Override
|
||||
public void onSuccess(Result<BindBean> feedbackResp) {
|
||||
bindBean = feedbackResp.data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
private void getWallet() {
|
||||
Api.getInstance().walletInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<WalletBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<WalletBean> feedbackResp) {
|
||||
walletBean = feedbackResp.data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
// WidgetUtils.showToast(getActivity(), msg, WidgetUtils.ToastType.ERROR);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if (null != this.getCurrentFocus()) {
|
||||
/**
|
||||
* 点击空白位置 隐藏软键盘
|
||||
*/
|
||||
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
|
||||
}
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
950
app/src/main/java/com/hbl/lewan/pay/PaymentActivity1.java
Normal file
950
app/src/main/java/com/hbl/lewan/pay/PaymentActivity1.java
Normal file
@@ -0,0 +1,950 @@
|
||||
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import static com.netease.yunxin.kit.contactkit.ui.ContactConstant.LIB_TAG;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import androidx.appcompat.widget.AppCompatImageView;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.codersun.fingerprintcompat.AonFingerChangeCallback;
|
||||
import com.codersun.fingerprintcompat.FingerManager;
|
||||
import com.codersun.fingerprintcompat.SimpleFingerCheckCallback;
|
||||
import com.hbl.lewan.IMApplication;
|
||||
import com.hbl.lewan.IMUIKitConfig;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.databinding.ActivityPayment1Binding;
|
||||
import com.hbl.lewan.databinding.ActivityPaymentBinding;
|
||||
import com.hbl.lewan.dialog.ActionConfirmDialog;
|
||||
import com.hbl.lewan.dialog.PayCashDialog;
|
||||
import com.hbl.lewan.dialog.PayCashFingerDialog;
|
||||
import com.hbl.lewan.main.MainActivity;
|
||||
import com.hbl.lewan.main.mine.ChangeAccoutActionActivity;
|
||||
import com.hbl.lewan.model.BindBean;
|
||||
import com.hbl.lewan.model.LoginBean;
|
||||
import com.hbl.lewan.model.UsersExistBean;
|
||||
import com.hbl.lewan.model.WalletBean;
|
||||
import com.hbl.lewan.network.Api;
|
||||
import com.hbl.lewan.network.BaseObserver;
|
||||
import com.hbl.lewan.network.Result;
|
||||
import com.hbl.lewan.utils.AdaptScreenUtils;
|
||||
import com.hbl.lewan.utils.DataUtils;
|
||||
import com.hbl.lewan.utils.GsonUtils;
|
||||
import com.hbl.lewan.utils.KeyboardUtil;
|
||||
import com.hbl.lewan.utils.LogUtils;
|
||||
import com.hbl.lewan.utils.ShareDateUtils;
|
||||
import com.hbl.lewan.wallet.SetPayPasswordActivity;
|
||||
import com.hbl.lewan.wallet.WalletInfoActivity;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.friend.FriendService;
|
||||
import com.netease.nimlib.sdk.msg.MessageBuilder;
|
||||
import com.netease.nimlib.sdk.msg.MsgService;
|
||||
import com.netease.nimlib.sdk.msg.constant.SessionTypeEnum;
|
||||
import com.netease.nimlib.sdk.msg.model.IMMessage;
|
||||
import com.netease.nimlib.sdk.msg.model.RecentContact;
|
||||
import com.netease.nimlib.sdk.uinfo.UserService;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.netease.yunxin.kit.alog.ALog;
|
||||
import com.netease.yunxin.kit.chatkit.repo.ChatRepo;
|
||||
import com.netease.yunxin.kit.chatkit.repo.ContactRepo;
|
||||
import com.netease.yunxin.kit.chatkit.ui.adapter.CommonAdapter;
|
||||
import com.netease.yunxin.kit.chatkit.ui.adapter.ViewHolder;
|
||||
import com.netease.yunxin.kit.chatkit.ui.custom.TransferAttachment;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.TransferBean;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
import com.netease.yunxin.kit.common.ui.utils.ToastX;
|
||||
import com.netease.yunxin.kit.common.ui.viewmodel.LoadStatus;
|
||||
import com.netease.yunxin.kit.common.ui.widgets.BackTitleBar;
|
||||
import com.netease.yunxin.kit.common.ui.widgets.ContactAvatarView;
|
||||
import com.netease.yunxin.kit.contactkit.ui.model.ContactBlackListBean;
|
||||
import com.netease.yunxin.kit.contactkit.ui.utils.ColorUtils;
|
||||
import com.netease.yunxin.kit.corekit.im.IMKitClient;
|
||||
import com.netease.yunxin.kit.corekit.im.model.FriendInfo;
|
||||
import com.netease.yunxin.kit.corekit.im.model.UserInfo;
|
||||
import com.netease.yunxin.kit.corekit.im.provider.FetchCallback;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.schedulers.Schedulers;
|
||||
|
||||
public class PaymentActivity1 extends BaseActivity {
|
||||
|
||||
PayCashFingerDialog payCashFingerDialog;
|
||||
WalletBean walletBean;
|
||||
BindBean bindBean;
|
||||
float number = 0;
|
||||
PayCashDialog payDialog;
|
||||
ActivityPayment1Binding viewBinding;
|
||||
String userId;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_fcfcfc));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_white));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityPayment1Binding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
initView();
|
||||
}
|
||||
viewBinding.layoutSelectLy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showShareBusiness();
|
||||
}
|
||||
});
|
||||
viewBinding.userinfoLy.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showShareBusiness();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private void changeUserInfo() {
|
||||
// NimUserInfo userInfo = NIMClient.getService(UserService.class).getUserInfo(userId);
|
||||
Api.getInstance().userInfo(userId)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<LoginBean> feedbackResp) {
|
||||
if (feedbackResp.data != null) {
|
||||
LoginBean bean = feedbackResp.data;
|
||||
viewBinding.layoutSelectLy.setVisibility(View.GONE);
|
||||
viewBinding.userinfoLy.setVisibility(View.VISIBLE);
|
||||
viewBinding.userNameTv.setText(bean.getNickname());
|
||||
ColorUtils.loadAvator(bean.getUserAvatarFileName(), viewBinding.userHeadIv);
|
||||
viewBinding.cheatid.setText("CHATID:" + bean.getNwId());
|
||||
} else {
|
||||
viewBinding.layoutSelectLy.setVisibility(View.VISIBLE);
|
||||
viewBinding.userinfoLy.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
viewBinding.layoutSelectLy.setVisibility(View.VISIBLE);
|
||||
viewBinding.userinfoLy.setVisibility(View.GONE);
|
||||
}
|
||||
});
|
||||
// if (userInfo != null) {
|
||||
// viewBinding.layoutSelectLy.setVisibility(View.GONE);
|
||||
// viewBinding.userinfoLy.setVisibility(View.VISIBLE);
|
||||
// viewBinding.userNameTv.setText(userInfo.getName());
|
||||
// ColorUtils.loadAvator(userInfo.getAvatar(),viewBinding.userHeadIv);
|
||||
//// viewBinding.userHeadIv.setData(, userInfo.getName());
|
||||
//
|
||||
// viewBinding.cheatid.setText("CHATID:" + userInfo.getAccount() + "");
|
||||
//
|
||||
// } else {
|
||||
// viewBinding.layoutSelectLy.setVisibility(View.VISIBLE);
|
||||
// viewBinding.userinfoLy.setVisibility(View.GONE);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void initView() {
|
||||
viewBinding.contactListActivityTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
|
||||
viewBinding.tvLogin.setOnClickListener(v -> {
|
||||
|
||||
if (bindBean != null) {
|
||||
if (!bindBean.getPhoneBind()) {
|
||||
showDialog();
|
||||
} else {
|
||||
if (!bindBean.getPayPasswordSet()) {
|
||||
showDialogPay();
|
||||
} else {
|
||||
if (viewBinding.userinfoLy.getVisibility() == View.GONE) {
|
||||
ToastX.showShortToast(R.string.qxxzzzdx_txt);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (TextUtils.isEmpty(viewBinding.numberHintEt.getText().toString().trim())) {
|
||||
ToastX.showShortToast(R.string.zzjebnwk_txt);
|
||||
return;
|
||||
}
|
||||
float number1 = Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim()) * 100;
|
||||
if (number1 < 1) {
|
||||
ToastX.showShortToast(R.string.zzjebnsy_txt);
|
||||
return;
|
||||
}
|
||||
|
||||
if (walletBean != null) {
|
||||
if (Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim()) > (walletBean.getGoldCoin() / 100f)) {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(PaymentActivity1.this,
|
||||
getString(R.string.sfqcz_txt), getString(R.string.general_cancel), getString(R.string.quchongzhi_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
Intent intent = new Intent(PaymentActivity1.this, WalletInfoActivity.class);
|
||||
intent.putExtra("isG", true);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
ToastX.showShortToast(R.string.yebz_txt);
|
||||
|
||||
return;
|
||||
}
|
||||
number = Float.parseFloat(viewBinding.numberHintEt.getText().toString().trim());
|
||||
// PayDialog payDialog = new PayDialog(PaymentActivity.this, number + "", true);
|
||||
// payDialog.setOntoAlbumListener(new PayDialog.OnListItemClickListener() {
|
||||
// @Override
|
||||
// public void onPayPass(String position) {
|
||||
// toChange(position, number);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void dimess() {
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// payDialog.show();
|
||||
// if(DataUtils.get(PaymentActivity1.this, "hasMianMi", false)){
|
||||
// toChange(null, number, 2);
|
||||
// }else {
|
||||
if (DataUtils.get(PaymentActivity1.this, "hasFinger", false)) {
|
||||
showPayCashFingerDialog();
|
||||
|
||||
} else {
|
||||
showPayCashDialog();
|
||||
}
|
||||
// }
|
||||
|
||||
} else {
|
||||
ToastX.showShortToast(R.string.hqqbxxsb_tx);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ToastX.showShortToast(R.string.hqqbxxsb_tx);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
viewBinding.numberHintEt.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
String input = s.toString();
|
||||
if (input.startsWith(".")) {
|
||||
viewBinding.numberHintEt.setText("0" + viewBinding.numberHintEt.getText().toString());
|
||||
}
|
||||
if (input.contains(".")) {
|
||||
int dotIndex = input.indexOf(".");
|
||||
if (input.length() - dotIndex - 1 > 2) {
|
||||
viewBinding.numberHintEt.setText(input.substring(0, dotIndex + 3));
|
||||
}
|
||||
}
|
||||
viewBinding.numberHintEt.setSelection(viewBinding.numberHintEt.getText().length());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
getBlacks();
|
||||
}
|
||||
|
||||
List<Integer> blacks = new ArrayList<>();
|
||||
|
||||
private void getBlacks() {
|
||||
com.netease.yunxin.kit.chatkit.ui.network.Api.getInstance().blocks()
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new com.netease.yunxin.kit.chatkit.ui.network.BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(com.netease.yunxin.kit.chatkit.ui.network.Result<List<Integer>> feedbackResp) {
|
||||
blacks = feedbackResp.data;
|
||||
getLocBlack();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void getLocBlack() {
|
||||
List<String> accounts = NIMClient.getService(FriendService.class).getBlackList();
|
||||
if (accounts != null) {
|
||||
if (blacks == null) {
|
||||
blacks = new ArrayList<>();
|
||||
}
|
||||
for (String user : accounts) {
|
||||
blacks.add(Integer.parseInt(user));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void showPayCashDialog() {
|
||||
payDialog = new PayCashDialog(PaymentActivity1.this, number + "", true, 0, walletBean,
|
||||
null, 2, getString(R.string.fukuan_txt));
|
||||
payDialog.setOntoAlbumListener(new PayCashDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onPayPass(String position) {
|
||||
toChange(position, number, 1);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
@Override
|
||||
public void onChangeFinger() {
|
||||
showPayCashFingerDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
payCashFingerDialog.dismiss();
|
||||
|
||||
}
|
||||
});
|
||||
payDialog.show();
|
||||
}
|
||||
|
||||
private void showPayCashFingerDialog() {
|
||||
//Context context, String data, boolean showNumber, int payType, WalletBean walletBean, SelectPayTypeDialog.OnToTypeListener onToTypeListener, int isShowFinger
|
||||
payCashFingerDialog = new PayCashFingerDialog(this, number + "", true, 0, walletBean, null, 2, getString(R.string.fukuan_txt));
|
||||
payCashFingerDialog.setOntoAlbumListener(new PayCashFingerDialog.OnListItemClickListener() {
|
||||
@Override
|
||||
public void onChangePassword() {
|
||||
showPayCashDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toFinger() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
checkPayFinger();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dimess() {
|
||||
payCashFingerDialog.dismiss();
|
||||
}
|
||||
});
|
||||
payCashFingerDialog.show();
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
private void checkPayFinger() {
|
||||
|
||||
FingerManager.build().setApplication(IMApplication.getInstance())
|
||||
.setTitle(" ")
|
||||
.setDes(" ")
|
||||
.setNegativeText(" ")
|
||||
.setFingerCheckCallback(new SimpleFingerCheckCallback() {
|
||||
|
||||
@Override
|
||||
public void onSucceed() {
|
||||
ToastX.showShortToast("验证成功");
|
||||
payCashFingerDialog.dismiss();
|
||||
toChange(null, number, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(String error) {
|
||||
ToastX.showShortToast("验证失败");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {
|
||||
ToastX.showShortToast("您取消了识别");
|
||||
|
||||
}
|
||||
})
|
||||
.setFingerChangeCallback(new AonFingerChangeCallback() {
|
||||
|
||||
@Override
|
||||
protected void onFingerDataChange() {
|
||||
// ToastX.showShortToast("指纹数据发生了变化");
|
||||
FingerManager.updateFingerData(PaymentActivity1.this);
|
||||
new Handler().postDelayed(() -> checkPayFinger(), 1000);
|
||||
}
|
||||
})
|
||||
.create()
|
||||
.startListener(PaymentActivity1.this);
|
||||
}
|
||||
|
||||
|
||||
private void showDialog() {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(PaymentActivity1.this,
|
||||
getString(R.string.bind_phone_des_txt), getString(R.string.nobind_txt), getString(R.string.tobind_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
Intent intent = new Intent(PaymentActivity1.this, ChangeAccoutActionActivity.class);
|
||||
intent.putExtra("type", ChangeAccoutActionActivity.TYPE_BIND_PHONE);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
|
||||
private void showDialogPay() {
|
||||
|
||||
ActionConfirmDialog actionDialog = new ActionConfirmDialog(PaymentActivity1.this,
|
||||
getString(R.string.bind_phone_des_txt1), getString(com.netease.yunxin.kit.chatkit.ui.R.string.cancel_txt), getString(com.netease.yunxin.kit.chatkit.ui.R.string.to_sett_txt));
|
||||
actionDialog.setOnToActionListener(new ActionConfirmDialog.OnToActionListener() {
|
||||
@Override
|
||||
public void toSumbit() {
|
||||
// Intent intent = new Intent(PaymentActivity1.this, ChangeAccoutActionActivity.class);
|
||||
// intent.putExtra("type", ChangeAccoutActionActivity.TYPE_CHANGE_PAY_PASSWORD);
|
||||
// startActivity(intent);
|
||||
Intent intent = new Intent(PaymentActivity1.this, SetPayPasswordActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toCancel() {
|
||||
|
||||
}
|
||||
});
|
||||
actionDialog.show();
|
||||
}
|
||||
|
||||
|
||||
private void toChange(String password, float number, int type) {
|
||||
KeyboardUtil.hideSoftInput(this);
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("amount", (int) (number * 100));
|
||||
maps.put("senderUid", Integer.parseInt(IMKitClient.account()));
|
||||
maps.put("receiverUid", Integer.parseInt(userId));
|
||||
if (!TextUtils.isEmpty(password)) {
|
||||
maps.put("payPassword", password);
|
||||
}
|
||||
if (!TextUtils.isEmpty(viewBinding.memoEt.getText().toString().trim())) {
|
||||
maps.put("remark", viewBinding.memoEt.getText().toString().trim());
|
||||
}
|
||||
maps.put("coinType", 0);
|
||||
maps.put("substationId", IMUIKitConfig.SUBSTATIONID);
|
||||
maps.put("payVerifyCode", type);
|
||||
maps.put("receiptType", 1);
|
||||
|
||||
Api.getInstance().transferMoney(maps)
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<>() {
|
||||
@Override
|
||||
public void onSuccess(Result<TransferBean> feedbackResp) {
|
||||
|
||||
TransferBean albumBean1 = feedbackResp.data;
|
||||
TransferAttachment customerAttachment = new TransferAttachment(albumBean1.getId() + "",
|
||||
albumBean1.getStatus() + "", albumBean1.getAmount() + "",
|
||||
albumBean1.getSenderUid() + "", albumBean1.getReceiverUid() + "",
|
||||
albumBean1.getSendTime(), albumBean1.getReceiveTime(), albumBean1.getRemark(), albumBean1.getCoinType() + "");
|
||||
LogUtils.i("获取到的数据:" + GsonUtils.beanToJSONString(customerAttachment));
|
||||
toShareMessage(customerAttachment);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
ToastX.showShortToast(msg);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private void toShareMessage(TransferAttachment customerAttachment) {
|
||||
IMMessage customMessage = MessageBuilder.createCustomMessage(userId, SessionTypeEnum.P2P,
|
||||
getString(com.netease.yunxin.kit.chatkit.ui.R.string.zhuangzhang_chat_txt), customerAttachment);
|
||||
|
||||
LogUtils.i("发送消息结构体:" + GsonUtils.beanToJSONString(customerAttachment));
|
||||
if (customMessage != null) {
|
||||
ChatRepo.sendMessage(customMessage, false, new FetchCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(@Nullable Void unused) {
|
||||
finish();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailed(int i) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(@Nullable Throwable throwable) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
getWallet();
|
||||
bindInfo();
|
||||
}
|
||||
|
||||
|
||||
private void bindInfo() {
|
||||
// if (u != null) {
|
||||
Api.getInstance().bindInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<BindBean>>() {
|
||||
@Override
|
||||
public void onSuccess(Result<BindBean> feedbackResp) {
|
||||
bindBean = feedbackResp.data;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
LogUtils.i("获取到的错误:" + code + "" + msg);
|
||||
}
|
||||
});
|
||||
// }
|
||||
}
|
||||
|
||||
private void getWallet() {
|
||||
Api.getInstance().walletInfo(IMKitClient.account())
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.subscribe(new BaseObserver<Result<WalletBean>>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Result<WalletBean> feedbackResp) {
|
||||
walletBean = feedbackResp.data;
|
||||
if (walletBean != null) {
|
||||
viewBinding.jinbiTv.setText(String.format(getString(R.string.qbyf_txt), walletBean.getGoldCoin() / 100f));
|
||||
// viewBinding.yinbiTv.setText(String.format("%.2f", walletBean.getSilverCoin() / 100f));
|
||||
} else {
|
||||
viewBinding.jinbiTv.setText(String.format(getString(R.string.qbyf_txt), 0f));
|
||||
// viewBinding.yinbiTv.setText(String.format("%.2f", 0f));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(int code, String msg) {
|
||||
// WidgetUtils.showToast(getActivity(), msg, WidgetUtils.ToastType.ERROR);
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*************************************************以下是去赠送的流程***************************************************************/
|
||||
private LinearLayout layoutSelectorroot;
|
||||
private BackTitleBar title;
|
||||
private EditText editSelectorFriends;
|
||||
private AppCompatImageView icCleanEdit;
|
||||
private LinearLayout layoutSearchlist;
|
||||
private RecyclerView contactSearchlistView;
|
||||
private LinearLayout layoutContactlist;
|
||||
private RecyclerView contactLast;
|
||||
private RecyclerView contactListViewMylove;
|
||||
private TextView tvContactmember;
|
||||
private RecyclerView contactListView;
|
||||
private TextView zuijinTv;
|
||||
private TextView tebieTv;
|
||||
List<NimUserInfo> zuijinUsers;
|
||||
List<UsersExistBean> usersExistBeanList;
|
||||
List<NimUserInfo> users;
|
||||
|
||||
private void showShareBusiness() {
|
||||
BottomSheetDialog bottomSheetDialog = new BottomSheetDialog(PaymentActivity1.this, com.netease.yunxin.kit.chatkit.ui.R.style.BottomSheetDialog);
|
||||
|
||||
View bottomView = LayoutInflater.from(PaymentActivity1.this).inflate(com.netease.yunxin.kit.chatkit.ui.R.layout.fun_contact_selector_dialog, null);
|
||||
layoutSelectorroot = (LinearLayout) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.layout_selectorroot);
|
||||
title = (BackTitleBar) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.title);
|
||||
editSelectorFriends = (EditText) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.edit_selector_friends);
|
||||
icCleanEdit = (AppCompatImageView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.ic_clean_edit);
|
||||
layoutSearchlist = (LinearLayout) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.layout_searchlist);
|
||||
contactSearchlistView = (RecyclerView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.contact_searchlistView);
|
||||
layoutContactlist = (LinearLayout) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.layout_contactlist);
|
||||
contactLast = (RecyclerView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.contact_last);
|
||||
contactListViewMylove = (RecyclerView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.contact_listView_mylove);
|
||||
tvContactmember = (TextView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.tv_contactmember);
|
||||
contactListView = (RecyclerView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.contact_listView);
|
||||
title.getBackImageView().setImageResource(com.netease.yunxin.kit.chatkit.ui.R.drawable.map_colose_img);
|
||||
editSelectorFriends.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (TextUtils.isEmpty(editSelectorFriends.getText().toString())) {
|
||||
initDataDialog(true, null);
|
||||
} else {
|
||||
initDataDialog(true, editSelectorFriends.getText().toString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
zuijinTv = (TextView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.zuijin_tv);
|
||||
tebieTv = (TextView) bottomView.findViewById(com.netease.yunxin.kit.chatkit.ui.R.id.tebie_tv);
|
||||
initDataDialog(false, null);
|
||||
initAdapterLast(bottomSheetDialog);
|
||||
initAdapterLover(bottomSheetDialog);
|
||||
initAdapterUser(bottomSheetDialog);
|
||||
title.getBackImageView().setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bottomSheetDialog.dismiss();
|
||||
}
|
||||
});
|
||||
bottomSheetDialog.setContentView(bottomView);
|
||||
bottomSheetDialog.show();
|
||||
|
||||
bottomSheetDialog.setOnDismissListener(dialog -> PaymentActivity1.this.getWindow().setNavigationBarColor(getResources().getColor(com.netease.yunxin.kit.chatkit.ui.R.color.color_white)));
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
AdaptScreenUtils.setWhiteNavigationBar(bottomSheetDialog);
|
||||
}
|
||||
}
|
||||
|
||||
private void initDataDialog(boolean isChange, String fifter) {
|
||||
fifterDataDialog(fifter);
|
||||
if (isChange) {
|
||||
if (zuijinUsers != null) {
|
||||
commonAdapterReadContents.setDates(zuijinUsers);
|
||||
}
|
||||
if (usersExistBeanList != null) {
|
||||
commonAdapterLover.setDates(usersExistBeanList);
|
||||
}
|
||||
if (users != null) {
|
||||
commonAdapterReadContentsAll.setDates(users);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void fifterDataDialog(String fifter) {
|
||||
List<RecentContact> recentContact = NIMClient.getService(MsgService.class).queryRecentContactsBlock();
|
||||
List<String> users1 = new ArrayList<>();
|
||||
if (recentContact != null && recentContact.size() > 0) {
|
||||
for (RecentContact recentContact1 : recentContact) {
|
||||
if (recentContact1.getSessionType() == SessionTypeEnum.P2P) {
|
||||
users1.add(recentContact1.getContactId());
|
||||
}
|
||||
}
|
||||
}
|
||||
zuijinUsers = NIMClient.getService(UserService.class).getUserInfoList(users1);
|
||||
if (zuijinUsers != null) {
|
||||
for (int i = 0; i < zuijinUsers.size(); i++) {
|
||||
if (ContactRepo.isBlackList(zuijinUsers.get(i).getAccount())
|
||||
|| !ContactRepo.isFriend(zuijinUsers.get(i).getAccount())) {
|
||||
zuijinUsers.remove(i);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
usersExistBeanList = getFollowUsers();
|
||||
|
||||
List<String> friends = NIMClient.getService(FriendService.class).getFriendAccounts();
|
||||
if (friends.size() > 0) {
|
||||
users = NIMClient.getService(UserService.class).getUserInfoList(friends);
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
if (ContactRepo.isBlackList(users.get(i).getAccount())) {
|
||||
users.remove(i);
|
||||
}
|
||||
|
||||
}
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
if (users.get(i).getAccount().equals(IMKitClient.account())) {
|
||||
users.remove(i);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(fifter)) {
|
||||
if (zuijinUsers != null && zuijinUsers.size() > 0) {
|
||||
List<NimUserInfo> nimUserInfos = new ArrayList<>();
|
||||
for (int i = 0; i < zuijinUsers.size(); i++) {
|
||||
if (zuijinUsers.get(i).getName().contains(fifter)) {
|
||||
nimUserInfos.add(zuijinUsers.get(i));
|
||||
}
|
||||
}
|
||||
zuijinUsers = nimUserInfos;
|
||||
}
|
||||
|
||||
if (usersExistBeanList != null && usersExistBeanList.size() > 0) {
|
||||
List<UsersExistBean> nimUserInfos = new ArrayList<>();
|
||||
for (int i = 0; i < usersExistBeanList.size(); i++) {
|
||||
if (usersExistBeanList.get(i).getNickname().contains(fifter)) {
|
||||
nimUserInfos.add(usersExistBeanList.get(i));
|
||||
}
|
||||
}
|
||||
usersExistBeanList = nimUserInfos;
|
||||
}
|
||||
|
||||
if (users != null && users.size() > 0) {
|
||||
List<NimUserInfo> nimUserInfos = new ArrayList<>();
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
if (users.get(i).getName().contains(fifter)) {
|
||||
nimUserInfos.add(users.get(i));
|
||||
}
|
||||
}
|
||||
users = nimUserInfos;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (zuijinUsers != null) {
|
||||
for (int i = 0; i < zuijinUsers.size(); i++) {
|
||||
// 获取迭代器
|
||||
Iterator<Integer> it = blacks.iterator();
|
||||
while (it.hasNext()) {
|
||||
Integer str = it.next();
|
||||
if ((str + "").equals(zuijinUsers.get(i).getAccount())) {
|
||||
zuijinUsers.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (usersExistBeanList != null) {
|
||||
for (int i = 0; i < usersExistBeanList.size(); i++) {
|
||||
// 获取迭代器
|
||||
Iterator<Integer> it = blacks.iterator();
|
||||
while (it.hasNext()) {
|
||||
Integer str = it.next();
|
||||
if ((str + "").equals(usersExistBeanList.get(i).getUserId() + "")) {
|
||||
usersExistBeanList.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (users != null) {
|
||||
for (int i = 0; i < users.size(); i++) {
|
||||
// 获取迭代器
|
||||
Iterator<Integer> it = blacks.iterator();
|
||||
while (it.hasNext()) {
|
||||
Integer str = it.next();
|
||||
if ((str + "").equals(users.get(i).getAccount())) {
|
||||
users.remove(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
int size1 = 0;
|
||||
int size2 = 0;
|
||||
int size3 = 0;
|
||||
if (zuijinUsers != null && zuijinUsers.size() > 0) {
|
||||
size1 = zuijinUsers.size();
|
||||
}
|
||||
if (usersExistBeanList != null && usersExistBeanList.size() > 0) {
|
||||
size2 = usersExistBeanList.size();
|
||||
}
|
||||
if (users != null && users.size() > 0) {
|
||||
size3 = users.size();
|
||||
}
|
||||
zuijinTv.setText(getString(com.netease.yunxin.kit.chatkit.ui.R.string.jinjinlianxi_txt) + " " + size1);
|
||||
tebieTv.setText(getString(com.netease.yunxin.kit.chatkit.ui.R.string.tebieguanxin_txt) + " " + size2);
|
||||
tvContactmember.setText(getString(com.netease.yunxin.kit.chatkit.ui.R.string.all_txt) + " " + size3);
|
||||
|
||||
}
|
||||
|
||||
CommonAdapter commonAdapterReadContentsAll;
|
||||
|
||||
private void initAdapterUser(BottomSheetDialog bottomSheetDialog) {
|
||||
|
||||
if (users != null && users.size() > 0) {
|
||||
tvContactmember.setVisibility(View.VISIBLE);
|
||||
contactListView.setVisibility(View.VISIBLE);
|
||||
contactListView.setLayoutManager(new LinearLayoutManager(PaymentActivity1.this));
|
||||
commonAdapterReadContentsAll = new CommonAdapter<NimUserInfo>(PaymentActivity1.this, com.netease.yunxin.kit.chatkit.ui.R.layout.follow_child_item, users) {
|
||||
@Override
|
||||
public void convert(ViewHolder holder, NimUserInfo s, int index) {
|
||||
ContactAvatarView contactAvatarView = holder.getView(com.netease.yunxin.kit.chatkit.ui.R.id.logo_iv);
|
||||
// contactAvatarView.setData(
|
||||
// s.getAvatar(), s.getName());
|
||||
ColorUtils.loadAvator(s.getAvatar(), contactAvatarView);
|
||||
holder.setText(com.netease.yunxin.kit.chatkit.ui.R.id.item_title_tv, s.getName());
|
||||
|
||||
holder.getView(com.netease.yunxin.kit.chatkit.ui.R.id.big_ly).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bottomSheetDialog.dismiss();
|
||||
userId = s.getAccount();
|
||||
changeUserInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
contactListView.setAdapter(commonAdapterReadContentsAll);
|
||||
|
||||
} else {
|
||||
tvContactmember.setVisibility(View.GONE);
|
||||
contactListView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
CommonAdapter commonAdapterLover;
|
||||
|
||||
private void initAdapterLover(BottomSheetDialog bottomSheetDialog) {
|
||||
|
||||
if (usersExistBeanList != null && usersExistBeanList.size() > 0) {
|
||||
tebieTv.setVisibility(View.VISIBLE);
|
||||
contactListViewMylove.setVisibility(View.VISIBLE);
|
||||
|
||||
contactListViewMylove.setLayoutManager(new LinearLayoutManager(PaymentActivity1.this));
|
||||
commonAdapterLover = new CommonAdapter<UsersExistBean>(PaymentActivity1.this, com.netease.yunxin.kit.chatkit.ui.R.layout.follow_child_item, usersExistBeanList) {
|
||||
@Override
|
||||
public void convert(ViewHolder holder, UsersExistBean s, int index) {
|
||||
ContactAvatarView contactAvatarView = holder.getView(com.netease.yunxin.kit.chatkit.ui.R.id.logo_iv);
|
||||
Log.i("异常数据:", "异常数据:" + com.netease.yunxin.kit.chatkit.ui.common.GsonUtils.beanToJSONString(s));
|
||||
ColorUtils.loadAvator(s.getAvatar(), contactAvatarView);
|
||||
// contactAvatarView.setData(
|
||||
// s.getAvatar(), s.getNickname());
|
||||
holder.setText(com.netease.yunxin.kit.chatkit.ui.R.id.item_title_tv, s.getNickname());
|
||||
|
||||
holder.getView(com.netease.yunxin.kit.chatkit.ui.R.id.big_ly).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bottomSheetDialog.dismiss();
|
||||
userId = s.getUserId() + "";
|
||||
changeUserInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
contactListViewMylove.setAdapter(commonAdapterLover);
|
||||
|
||||
} else {
|
||||
tebieTv.setVisibility(View.GONE);
|
||||
contactListViewMylove.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有关注的用户
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<UsersExistBean> getFollowUsers() {
|
||||
return ShareDateUtils.getFollowUsers();
|
||||
}
|
||||
|
||||
CommonAdapter commonAdapterReadContents;
|
||||
|
||||
private void initAdapterLast(BottomSheetDialog bottomSheetDialog) {
|
||||
|
||||
if (zuijinUsers != null && zuijinUsers.size() > 0) {
|
||||
zuijinTv.setVisibility(View.VISIBLE);
|
||||
contactLast.setVisibility(View.VISIBLE);
|
||||
|
||||
contactLast.setLayoutManager(new LinearLayoutManager(PaymentActivity1.this));
|
||||
commonAdapterReadContents = new CommonAdapter<NimUserInfo>(PaymentActivity1.this, com.netease.yunxin.kit.chatkit.ui.R.layout.follow_child_item, zuijinUsers) {
|
||||
@Override
|
||||
public void convert(ViewHolder holder, NimUserInfo s, int index) {
|
||||
ContactAvatarView contactAvatarView = holder.getView(com.netease.yunxin.kit.chatkit.ui.R.id.logo_iv);
|
||||
ColorUtils.loadAvator(s.getAvatar(), contactAvatarView);
|
||||
// contactAvatarView.setData(
|
||||
// s.getAvatar(), s.getName());
|
||||
holder.setText(com.netease.yunxin.kit.chatkit.ui.R.id.item_title_tv, s.getName());
|
||||
|
||||
holder.getView(com.netease.yunxin.kit.chatkit.ui.R.id.big_ly).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
bottomSheetDialog.dismiss();
|
||||
userId = s.getAccount();
|
||||
changeUserInfo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
contactLast.setAdapter(commonAdapterReadContents);
|
||||
|
||||
} else {
|
||||
zuijinTv.setVisibility(View.GONE);
|
||||
contactLast.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
/*************************************************以上是去赠送的流程***************************************************************/
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
if(null != this.getCurrentFocus()){
|
||||
/**
|
||||
* 点击空白位置 隐藏软键盘
|
||||
*/
|
||||
InputMethodManager mInputMethodManager = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);
|
||||
return mInputMethodManager.hideSoftInputFromWindow(this.getCurrentFocus().getWindowToken(), 0);
|
||||
}
|
||||
return super .onTouchEvent(event);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
|
||||
package com.hbl.lewan.pay;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
|
||||
import com.hbl.lewan.IMUIKitConfig;
|
||||
import com.hbl.lewan.R;
|
||||
import com.hbl.lewan.databinding.ActivityPaymentSuccessBinding;
|
||||
|
||||
import com.netease.nimlib.sdk.NIMClient;
|
||||
import com.netease.nimlib.sdk.uinfo.UserService;
|
||||
import com.netease.nimlib.sdk.uinfo.model.NimUserInfo;
|
||||
import com.netease.yunxin.kit.chatkit.ui.model.TransferBean;
|
||||
import com.netease.yunxin.kit.common.ui.activities.BaseActivity;
|
||||
|
||||
|
||||
public class PaymentSuccessActivity extends BaseActivity {
|
||||
TransferBean transferBean;
|
||||
ActivityPaymentSuccessBinding viewBinding;
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
getWindow().setStatusBarColor(getResources().getColor(R.color.color_fcfcfc));
|
||||
getWindow().setNavigationBarColor(getResources().getColor(R.color.color_white));
|
||||
|
||||
super.onCreate(savedInstanceState);
|
||||
viewBinding = ActivityPaymentSuccessBinding.inflate(getLayoutInflater());
|
||||
setContentView(viewBinding.getRoot());
|
||||
transferBean = (TransferBean) getIntent().getSerializableExtra("bean");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
initView();
|
||||
}
|
||||
NimUserInfo userInfo = NIMClient.getService(UserService.class).getUserInfo(transferBean.getReceiverUid()+"");
|
||||
if(userInfo!=null){
|
||||
viewBinding.shoukuanfangTv.setText(userInfo.getName());
|
||||
}else{
|
||||
viewBinding.shoukuanfangTv.setText(getIntent().getStringExtra("name"));
|
||||
}
|
||||
if(TextUtils.isEmpty(transferBean.getRemark())){
|
||||
viewBinding.fukuanbeizhuTv.setText(getString(R.string.wu_txt));
|
||||
|
||||
}else{
|
||||
viewBinding.fukuanbeizhuTv.setText(transferBean.getRemark());
|
||||
}
|
||||
viewBinding.numberTv.setText(String.format("%.2f",transferBean.getAmount()/100f));
|
||||
|
||||
}
|
||||
/**
|
||||
*/
|
||||
@RequiresApi(api = Build.VERSION_CODES.M)
|
||||
protected void initView()
|
||||
{
|
||||
viewBinding.contactListActivityTitleBar.getBackImageView().setOnClickListener(v -> finish());
|
||||
|
||||
viewBinding.buttonTv.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user