新增房间内半屏充值页面,我的账户页面UI优化

This commit is contained in:
huangjian
2022-06-08 15:52:54 +08:00
parent 4f104f9685
commit 733824140c
21 changed files with 897 additions and 262 deletions

View File

@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="@drawable/dialog_charge_bg_checked" android:state_selected="true" />
<item android:drawable="@drawable/dialog_charge_bg_checked" android:state_checked="true" />
<item>
<shape android:shape="rectangle">
<solid android:color="@color/white" />
<corners android:radius="8dp"/>
</shape>
</item>
</selector>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 690 B

View File

@@ -615,10 +615,12 @@
android:name=".ui.pay.ChargeActivity"
android:label="充值"
android:screenOrientation="portrait" />
<activity
android:name=".ui.pay.CDKEYChargeActivity"
android:label="兑换码充值"
android:screenOrientation="portrait" />
android:name=".ui.pay.ChargeDialog"
android:label="充值"
android:theme="@style/dialog_web_view_activity"/>
<activity
android:name=".home.activity.CollectionRoomActivity"
android:label="收藏房间"

View File

@@ -1,80 +0,0 @@
package com.yizhuan.erban.ui.pay;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import com.netease.nim.uikit.common.util.string.StringUtil;
import com.yizhuan.erban.R;
import com.yizhuan.erban.base.BaseActivity;
import com.yizhuan.xchat_android_core.pay.PayModel;
import com.yizhuan.xchat_android_core.utils.net.BeanObserver;
import org.greenrobot.eventbus.EventBus;
/**
* Created by chenran on 2017/11/15.
*/
public class CDKEYChargeActivity extends BaseActivity implements View.OnClickListener {
private EditText editText;
private Button charge;
public static void start(Context context) {
if (context == null) return;
Intent intent = new Intent(context, CDKEYChargeActivity.class);
context.startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cd_key_charge);
initTitleBar("兑换码充值");
editText = (EditText) findViewById(R.id.cd_key_edit);
charge = (Button) findViewById(R.id.btn_charge);
charge.setOnClickListener(this);
}
@Override
public void onClick(View v) {
String text = editText.getText().toString();
if (StringUtil.isEmpty(text)) {
toast("兑换码为空");
return;
}
getDialogManager().showProgressDialog(this, "请稍后");
PayModel.get().requestCDKeyCharge(editText.getText().toString())
.compose(bindToLifecycle())
.subscribe(new BeanObserver<Integer>() {
@Override
public void onSuccess(Integer count) {
onCDKeyCharge(count);
}
@Override
public void onErrorMsg(String error) {
onCDKeyChargeFail(error);
}
});
editText.setText("");
}
public void onCDKeyCharge(int gold) {
getDialogManager().dismissDialog();
ChargeDialog dialog = new ChargeDialog(this, gold);
dialog.show();
}
public void onCDKeyChargeFail(String error) {
getDialogManager().dismissDialog();
toast(error);
}
}

View File

@@ -116,7 +116,7 @@ public class ChargeActivity extends BaseActivity {
setContentView(R.layout.activity_charge);
initWhiteTitleBar(getString(R.string.label_charge_gold));
mTitleBar.setLeftClickListener(v -> finishPage());
mTitleBar.addAction(new TitleBar.TextAction("我的收益", getResources().getColor(R.color.white)) {
mTitleBar.addAction(new TitleBar.TextAction("我的收益", getResources().getColor(R.color.color_333333)) {
@Override
public void performAction(View view) {
CommonWebViewActivity.start(ChargeActivity.this,
@@ -134,8 +134,8 @@ public class ChargeActivity extends BaseActivity {
if (mTitleBar != null) {
mTitleBar.setTitle(title);
mTitleBar.setImmersive(false);
mTitleBar.setTitleColor(getResources().getColor(R.color.white));
mTitleBar.setLeftImageResource(R.drawable.arrow_left_white);
mTitleBar.setTitleColor(getResources().getColor(R.color.color_333333));
mTitleBar.setLeftImageResource(R.drawable.arrow_left);
mTitleBar.setCommonBackgroundColor(getResources().getColor(R.color.transparent));
mTitleBar.setLeftClickListener(v -> onLeftClickListener());
}
@@ -206,20 +206,12 @@ public class ChargeActivity extends BaseActivity {
switch (defaultPay) {
case ALI_PAY_CLOSE:
iv_sel_first.setSelected(selectAliPay);
iv_sel_second.setSelected(selectWeChatPay);
break;
case WX_PAY_CLOSE:
iv_sel_first.setSelected(selectWeChatPay);
iv_sel_second.setSelected(selectAliPay);
break;
case ALI_PAY_OPEN:
iv_sel_first.setSelected(selectAliPay);
iv_sel_second.setSelected(selectWeChatPay);
break;
case WX_PAY_CLOSE:
case WX_PAY_OPEN:
iv_sel_first.setSelected(selectWeChatPay);
iv_sel_second.setSelected(selectAliPay);
@@ -246,7 +238,7 @@ public class ChargeActivity extends BaseActivity {
mRecyclerView = findViewById(R.id.recyclerView);
mRecyclerView.setNestedScrollingEnabled(false);
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
mChargeAdapter = new ChargeAdapter();
mChargeAdapter = new ChargeAdapter(false);
mRecyclerView.setAdapter(mChargeAdapter);
mChargeAdapter.setOnItemClickListener((baseQuickAdapter, view, position) -> {
setItemSelect(position);

View File

@@ -3,8 +3,11 @@ package com.yizhuan.erban.ui.pay;
import android.text.TextUtils;
import android.widget.LinearLayout;
import androidx.recyclerview.widget.RecyclerView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.yizhuan.erban.R;
import com.yizhuan.xchat_android_core.pay.bean.ChargeBean;
@@ -15,14 +18,24 @@ import org.jetbrains.annotations.NotNull;
* Created by Administrator on 2017/11/20.
*/
public class ChargeAdapter extends BaseQuickAdapter<ChargeBean, BaseViewHolder> {
ChargeAdapter() {
private final boolean isDialogCharge;
ChargeAdapter(boolean isDialogCharge) {
super(R.layout.list_item_charge);
this.isDialogCharge = isDialogCharge;
}
@Override
protected void convert(@NotNull BaseViewHolder baseViewHolder, ChargeBean chargeBean) {
if (chargeBean == null) return;
if (isDialogCharge) {
RecyclerView.LayoutParams layoutParams = (RecyclerView.LayoutParams) baseViewHolder.itemView.getLayoutParams();
layoutParams.height = ScreenUtil.dip2px(54);
baseViewHolder.itemView.setLayoutParams(layoutParams);
}
baseViewHolder.setVisible(R.id.ll_gold_charge, !TextUtils.isEmpty(chargeBean.getProdName()))
.setText(R.id.tv_money_gold, chargeBean.prodName.replace("钻石", ""))
.setText(R.id.cb_money, mContext.getString(R.string.charge_number, chargeBean.money));

View File

@@ -1,62 +1,597 @@
package com.yizhuan.erban.ui.pay;
import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.StyleRes;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.netease.nim.uikit.StatusBarUtil;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.yizhuan.erban.R;
import com.yizhuan.erban.bank_card.activity.AddBankCardAgreementActivity;
import com.yizhuan.erban.base.BaseActivity;
import com.yizhuan.erban.base.TitleBar;
import com.yizhuan.erban.common.widget.dialog.DialogManager;
import com.yizhuan.erban.ui.setting.ModifyPwdActivity;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.ui.widget.password.PassWordFragment;
import com.yizhuan.erban.ui.widget.password.PasswordEvent;
import com.yizhuan.xchat_android_core.Constants;
import com.yizhuan.xchat_android_core.UriProvider;
import com.yizhuan.xchat_android_core.auth.AuthModel;
import com.yizhuan.xchat_android_core.bean.response.ServiceResult;
import com.yizhuan.xchat_android_core.bean.response.result.ChargeListResult;
import com.yizhuan.xchat_android_core.pay.PayModel;
import com.yizhuan.xchat_android_core.pay.PaymentActivity;
import com.yizhuan.xchat_android_core.pay.bean.ChargeBean;
import com.yizhuan.xchat_android_core.pay.bean.PaymentResult;
import com.yizhuan.xchat_android_core.pay.bean.WalletInfo;
import com.yizhuan.xchat_android_core.pay.bean.unionpay.UnionPayOrder;
import com.yizhuan.xchat_android_core.pay.event.GetWalletInfoEvent;
import com.yizhuan.xchat_android_core.pay.event.UpdateWalletInfoEvent;
import com.yizhuan.xchat_android_core.pay.model.unionpay.UnionPayModel;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_core.utils.CheckUtils;
import com.yizhuan.xchat_android_core.utils.net.BeanObserver;
import com.yizhuan.xchat_android_core.web.event.WebViewRefreshEvent;
import com.yizhuan.xchat_android_library.utils.JavaUtil;
import com.yizhuan.xchat_android_library.utils.ListUtils;
import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import io.reactivex.Observable;
import io.reactivex.SingleObserver;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* Created by chenran on 2017/11/15.
* 充值界面
*
* @author zhouxiangfeng
* @date 2017/6/19
*/
public class ChargeDialog extends BaseActivity {
public class ChargeDialog extends Dialog implements View.OnClickListener{
private int gold;
private TextView goldText;
private Button btnIKnow;
public static final int ALI_PAY_CLOSE = 1;
public static final int WX_PAY_CLOSE = 2;
public static final int ALI_PAY_OPEN = 3;
public static final int WX_PAY_OPEN = 4;
private static final String TAG = "ChargeDialog";
private final int BINDCODE_GOLD = 200;
List<ChargeBean> mBigList;
List<ChargeBean> mList;
private TextView mTv_gold;
private LinearLayout ll_type_first;
private ImageView iv_type_first;
private TextView tv_type_first;
private LinearLayout ll_type_second;
private ImageView iv_type_second;
private TextView tv_type_second;
private TextView tvCharge;
private RecyclerView mRecyclerView;
private ChargeAdapter mChargeAdapter;
private TextView tvAgreement;
private LinearLayout ll_more;
private ChargeBean mSelectChargeBean;
private int mListSize;
private volatile String payChannel = Constants.CHARGE_WX;
private boolean mIsFromH5;
private CompositeDisposable compositeDisposable = new CompositeDisposable();
public ChargeDialog(@NonNull Context context, int gold) {
super(context, R.style.dialog);
this.gold = gold;
public static void start(Context context) {
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
if (context == null || userInfo == null) return;
Intent intent = new Intent(context, ChargeDialog.class);
context.startActivity(intent);
}
public ChargeDialog(@NonNull Context context, @StyleRes int themeResId, int gold) {
super(context, R.style.dialog);
this.gold = gold;
}
protected ChargeDialog(@NonNull Context context, boolean cancelable, @Nullable OnCancelListener cancelListener) {
super(context, cancelable, cancelListener);
public static void start(Context context, boolean isFromH5) {
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
if (context == null || userInfo == null) return;
Intent intent = new Intent(context, ChargeDialog.class);
intent.putExtra("isFromH5", isFromH5);
context.startActivity(intent);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.charge_dialog);
initView();
setContentView(R.layout.dialog_charge);
//这里的height用MATCH_PARENT状态栏会被顶上去,不知道什么鬼
int height = ScreenUtil.screenHeight - ScreenUtil.getStatusBarHeight(context);
getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, height);
getWindow().setGravity(Gravity.BOTTOM);
initTitleBar("充值");
mTitleBar.setLeftClickListener(v -> finishPage());
bindViews();
setListener();
initiate();
}
private void setListener() {
btnIKnow.setOnClickListener(this);
ll_more.setOnClickListener(v -> hideMoreButton());
tvCharge.setOnClickListener(v -> {
if (mSelectChargeBean == null) return;
getDialogManager().showProgressDialog(this, false);
PaymentActivity.start(this, payChannel, mSelectChargeBean.chargeProdId);
});
tvAgreement.setOnClickListener(v -> {
CommonWebViewActivity.start(this, UriProvider.getRechargeAgreementUrl());
});
}
private void initView() {
goldText = (TextView) findViewById(R.id.gold_text);
btnIKnow = (Button) findViewById(R.id.btn_charge);
goldText.setText(gold + "钻石");
private void hideMoreButton() {
ll_more.setVisibility(View.GONE);
ll_type_second.setVisibility(View.VISIBLE);
}
private void showMoreButton() {
ll_more.setVisibility(View.VISIBLE);
ll_type_second.setVisibility(View.GONE);
}
private void bindViews() {
mTv_gold = findViewById(R.id.tv_gold);
ll_type_first = findViewById(R.id.ll_type_first);
iv_type_first = findViewById(R.id.iv_type_first);
ll_type_second = findViewById(R.id.ll_type_second);
ll_more = findViewById(R.id.ll_more);
tvCharge = findViewById(R.id.tv_charge);
tvAgreement = findViewById(R.id.tv_agreement);
iv_type_second = findViewById(R.id.iv_type_second);
tv_type_first = findViewById(R.id.tv_type_first);
tv_type_second = findViewById(R.id.tv_type_second);
}
public void selectPayChannelDisplay(String payChannel, int defaultPay) {
this.payChannel = payChannel;
boolean selectWeChatPay = (Objects.equals(this.payChannel, Constants.CHARGE_WX));
boolean selectAliPay = (Objects.equals(this.payChannel, Constants.CHARGE_ALIPAY));
if (!ListUtils.isListEmpty(mBigList)) {
if (selectAliPay) {
if (mList.size() == mListSize) {
for (ChargeBean bigList : mBigList) {
mList.add(bigList);
}
mChargeAdapter.setNewData(mList);
mChargeAdapter.notifyDataSetChanged();
}
} else {
if (mList.size() > mListSize) {
setItemSelect(0);
}
for (ChargeBean bigList : mBigList) {
mList.remove(bigList);
}
mChargeAdapter.setNewData(mList);
mChargeAdapter.notifyDataSetChanged();
}
}
switch (defaultPay) {
case ALI_PAY_CLOSE:
case ALI_PAY_OPEN:
ll_type_first.setSelected(selectAliPay);
ll_type_second.setSelected(selectWeChatPay);
break;
case WX_PAY_CLOSE:
case WX_PAY_OPEN:
ll_type_first.setSelected(selectWeChatPay);
ll_type_second.setSelected(selectAliPay);
break;
default:
defaultSetPay(selectWeChatPay, selectAliPay);
break;
}
}
/**
* 默认选择的支付方式
*
* @param selectWeChatPay
* @param selectAliPay
*/
private void defaultSetPay(boolean selectWeChatPay, boolean selectAliPay) {
ll_type_first.setSelected(selectWeChatPay);
ll_type_second.setSelected(selectAliPay);
}
private void initiate() {
mIsFromH5 = getIntent().getBooleanExtra("isFromH5", false);
mRecyclerView = findViewById(R.id.recyclerView);
mRecyclerView.setNestedScrollingEnabled(false);
mRecyclerView.setLayoutManager(new GridLayoutManager(this, 3));
mChargeAdapter = new ChargeAdapter(true);
mRecyclerView.setAdapter(mChargeAdapter);
mChargeAdapter.setOnItemClickListener((baseQuickAdapter, view, position) -> {
setItemSelect(position);
});
onRefreshing();
onLoadingData();
}
private void setItemSelect(int position) {
List<ChargeBean> list = mChargeAdapter.getData();
if (ListUtils.isListEmpty(list)) return;
// 空对象不让蒙板遮挡最后一个item
ChargeBean temp = list.get(position);
if (TextUtils.isEmpty(temp.getProdName()))
return;
mSelectChargeBean = list.get(position);
int size = list.size();
for (int i = 0; i < size; i++) {
list.get(i).isSelected = position == i;
}
mChargeAdapter.notifyDataSetChanged();
}
public void onLoadingData() {
UserInfo userInfos = UserModel.get().getCacheLoginUserInfo();
if (userInfos != null) {
PayModel.get().getWalletInfo(userInfos.getUid()).subscribe(new SingleObserver<WalletInfo>() {
@Override
public void onSubscribe(Disposable d) {
mCompositeDisposable.add(d);
}
@Override
public void onSuccess(WalletInfo walletInfo) {
setWalletData(walletInfo);
}
@Override
public void onError(Throwable e) {
}
});
}
}
public void onRefreshing() {
PayModel.get().getChargeList(1, AuthModel.get().getCurrentUid()).subscribe(new BeanObserver<ChargeListResult>() {
@Override
public void onSuccess(ChargeListResult chargeBeans) {
if (chargeBeans == null) return;
mBigList = chargeBeans.getBigList();
mList = chargeBeans.getList();
mListSize = chargeBeans.getList().size();
onGetChargeList(chargeBeans.getList());
//默认选中
}
@Override
public void onErrorMsg(String error) {
onGetChargeListFail(error);
}
});
}
@Override
public void onClick(View v) {
dismiss();
protected void onResume() {
super.onResume();
EventBus.getDefault().register(this);
if (PayModel.get().isFirstChargeSuccess()) {
PayModel.get().setFirstChargeSuccess(false);
onRefreshing();
}
}
@Override
protected void onPause() {
super.onPause();
EventBus.getDefault().unregister(this);
}
public void onGetChargeList(List<ChargeBean> chargeBeanList) {
if (chargeBeanList != null && chargeBeanList.size() > 0) {
//先判断存不存在1元档位
boolean isExistOneYuan = false;
for (int i = 0; i < chargeBeanList.size(); i++) {
ChargeBean chargeBean = chargeBeanList.get(i);
if (chargeBean.getMoney() == 1) {
isExistOneYuan = true;
break;
}
}
int selectedMoney = isExistOneYuan ? 1 : 6;
for (int i = 0; i < chargeBeanList.size(); i++) {
ChargeBean chargeBean = chargeBeanList.get(i);
chargeBean.isSelected = chargeBean.getMoney() == selectedMoney;
if (selectedMoney == chargeBean.getMoney()) {
mSelectChargeBean = chargeBean;
}
}
mChargeAdapter.setNewData(chargeBeanList);
}
}
public void onGetChargeListFail(String error) {
toast(error);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
getDialogManager().dismissDialog();
if (resultCode != RESULT_OK) {
return;
}
//支付页面返回处理
if (requestCode == PaymentActivity.REQUEST_CODE_PAY) {
if (data != null && data.getExtras() != null) {
PaymentResult paymentResult = data.getParcelableExtra(PaymentActivity.KEY_PAY_RESULT);
if (paymentResult != null) {
// 充值金额超过限定时,就必须先实名认证
int payResultCode = JavaUtil.str2int(paymentResult.getCode());
switch (payResultCode) {
case PayModel.NOT_REAL_NAME_BEFORE_CHARGING:
getDialogManager().showTipsDialog(getString(R.string.tips_need_to_certification),
getString(R.string.go_to_certification),
new DialogManager.AbsOkDialogListener() {
@Override
public void onOk() {
// 跳去实名认证页面
CommonWebViewActivity.start(ChargeDialog.this,
UriProvider.getTutuRealNamePage());
}
});
break;
case UnionPayModel.CODE_NEED_BIND_BANK_CARD_FIRST:
getDialogManager().showTipsDialog(
getString(R.string.tips_need_bind_bank_card_first),
new DialogManager.AbsOkDialogListener() {
@Override
public void onOk() {
// 跳去添加银行卡页面
AddBankCardAgreementActivity.start(ChargeDialog.this);
}
});
break;
case PaymentResult.CODE_SHOW_PAYMENT_PSW:
showPaymentConfirmDialog();
break;
case PaymentResult.CODE_UNION_PAY_WAITING_FOR_RESULT:
queryingPaymentResult();
break;
default:
toast(paymentResult.getMsg());
//重新获取钱包信息
PayModel.get().getWalletInfo(AuthModel.get().getCurrentUid()).subscribe();
}
}
}
}
if (requestCode == BINDCODE_GOLD) {
ModifyPwdActivity.start(this, ModifyPwdActivity.FOGERT_PAY_PWD);
}
}
/**
* 银联支付下,弹出确认弹窗,方便用户查看支付金额和支付使用的银行卡,还能切换银行卡
*/
private void showPaymentConfirmDialog() {
if (mSelectChargeBean == null) {
return;
}
ConfirmPaymentDialog.newInstance(mSelectChargeBean.getMoney(),
selectedBankInfo -> {
UnionPayModel.getInstance().setSelectedBankInfo(selectedBankInfo);
PassWordFragment.newInstance().show(getSupportFragmentManager());
})
.show(getSupportFragmentManager(), ConfirmPaymentDialog.class.getName());
}
/**
* 银联支付存在一定的延时,所以这里加一个五秒的 loading 动画在前台,
* 后台在每秒轮询服务器获取订单状态
* 当获取到订单状态为成功或者失败的时候loading 结束,
* 否则一直 loading直到五秒结束后 toast 提示用户自行查账单
*/
private void queryingPaymentResult() {
UnionPayOrder unionPayOrder = UnionPayModel.getInstance().getUnionPayOrder();
if (unionPayOrder == null) {
getDialogManager().dismissDialog();
return;
}
// 前台 loading
getDialogManager().showProgressDialog(ChargeDialog.this,
getString(R.string.tips_querying_payment_result), false);
// 轮询订单支付结果
Observable<ServiceResult<String>> stringObservable =
Observable.interval(0, 1, TimeUnit.SECONDS)
.take(5)
.subscribeOn(Schedulers.io())
.concatMap(aLong -> UnionPayModel.getInstance()
.unionPayResult(unionPayOrder.getOrderNo())
.toObservable())
.observeOn(AndroidSchedulers.mainThread())
.filter(pollingJsonResult ->
pollingJsonResult.getCode() == ServiceResult.SC_SUCCESS ||
pollingJsonResult.getCode() == UnionPayModel.CODE_UNION_PAY_FAILED)
.timeout(5, TimeUnit.SECONDS);
compositeDisposable.add(
stringObservable.subscribe(stringServiceResult -> {
getDialogManager().dismissDialog();
disposeCompositeDisposable();
if (stringServiceResult != null) {
toast(stringServiceResult.getMessage());
if (stringServiceResult.getCode() == ServiceResult.SC_SUCCESS) {
PayModel.get().setFirstChargeSuccess(false);
onRefreshing();
}
}
}, throwable -> {
throwable.printStackTrace();
getDialogManager().dismissDialog();
toast(throwable.getMessage());
}, () -> {
getDialogManager().dismissDialog();
toast(R.string.toast_payment_result_delayed);
})
);
}
private void disposeCompositeDisposable() {
if (compositeDisposable != null && !compositeDisposable.isDisposed()) {
compositeDisposable.dispose();
}
}
@Override
protected void onDestroy() {
super.onDestroy();
disposeCompositeDisposable();
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onWalletInfoUpdate(UpdateWalletInfoEvent event) {
WalletInfo walletInfo = PayModel.get().getCurrentWalletInfo();
if (walletInfo != null) {
setWalletData(walletInfo);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onGetWalletInfo(GetWalletInfoEvent event) {
WalletInfo walletInfo = PayModel.get().getCurrentWalletInfo();
if (walletInfo != null) {
setWalletData(walletInfo);
}
}
/**
* defaultPay 1默认支付宝2默认微信
*/
private void setWalletData(WalletInfo walletInfo) {
if (walletInfo == null) return;
mTv_gold.setText(getString(R.string.charge_gold, walletInfo.getDiamondNum()));
int defaultPay = walletInfo.getDefaultPay();
switch (defaultPay) {
case ALI_PAY_CLOSE:
payChannel = Constants.CHARGE_ALIPAY;
showMoreButton();
setAliPayFirst(defaultPay);
break;
case WX_PAY_CLOSE:
payChannel = Constants.CHARGE_WX;
showMoreButton();
setWxPayFirst(defaultPay);
break;
case ALI_PAY_OPEN:
payChannel = Constants.CHARGE_ALIPAY;
hideMoreButton();
setAliPayFirst(defaultPay);
break;
case WX_PAY_OPEN:
payChannel = Constants.CHARGE_WX;
hideMoreButton();
setWxPayFirst(defaultPay);
break;
default:
defaultPay(defaultPay);
break;
}
if (CheckUtils.isCheckUser()) {
selectPayChannelDisplay(Constants.CHARGE_ALIPAY, defaultPay);
} else {
selectPayChannelDisplay(payChannel, defaultPay);
}
}
/**
* 默认支付方式
*
* @param defaultPay
*/
private void defaultPay(int defaultPay) {
payChannel = Constants.CHARGE_WX;
hideMoreButton();
setWxPayFirst(defaultPay);
}
private void setAliPayFirst(int defaultType) {
iv_type_first.setImageDrawable(getResources().getDrawable(R.drawable.dialog_charge_ic_alipay));
iv_type_second.setImageDrawable(getResources().getDrawable(R.drawable.dialog_charge_ic_wechat));
tv_type_first.setText("支付宝");
tv_type_second.setText("微信");
ll_type_first.setOnClickListener(v -> selectPayChannelDisplay(Constants.CHARGE_ALIPAY, defaultType));
ll_type_second.setOnClickListener(v -> selectPayChannelDisplay(Constants.CHARGE_WX, defaultType));
if (CheckUtils.isCheckUser()) {
ll_type_first.setVisibility(View.VISIBLE);
ll_type_second.setVisibility(View.GONE);
ll_more.setVisibility(View.GONE);
}
}
private void setWxPayFirst(int defaultType) {
iv_type_first.setImageDrawable(getResources().getDrawable(R.drawable.dialog_charge_ic_wechat));
iv_type_second.setImageDrawable(getResources().getDrawable(R.drawable.dialog_charge_ic_alipay));
tv_type_first.setText("微信");
tv_type_second.setText("支付宝");
ll_type_first.setOnClickListener(v -> selectPayChannelDisplay(Constants.CHARGE_WX, defaultType));
ll_type_second.setOnClickListener(v -> selectPayChannelDisplay(Constants.CHARGE_ALIPAY, defaultType));
if (CheckUtils.isCheckUser()) {
ll_type_first.setVisibility(View.GONE);
ll_type_second.setVisibility(View.VISIBLE);
ll_more.setVisibility(View.GONE);
}
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onGetPassword(PasswordEvent event) {
getDialogManager().showProgressDialog(this);
PaymentActivity.startToPay(this, Constants.CHARGE_UNION_PAY, event.getPassword());
}
@Override
protected boolean needSteepStateBar() {
return true;
}
@Override
protected void setStatusBar() {
super.setStatusBar();
StatusBarUtil.transparencyBar(this);
}
@Override
public void onBackPressed() {
super.onBackPressed();
finishPage();
}
private void finishPage() {
finish();
if (!mIsFromH5) return;
EventBus.getDefault().post(new WebViewRefreshEvent());
}
}

View File

@@ -1,30 +0,0 @@
package com.yizhuan.erban.ui.pay;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import androidx.annotation.NonNull;
import android.view.View;
import android.view.Window;
import com.yizhuan.erban.R;
public class ChargeSuccessDialog extends Dialog {
public ChargeSuccessDialog(@NonNull Context context) {
super(context, R.style.dialog);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.charge_success_dialog);
findViewById(R.id.tv_dialog_close).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
}
}

View File

@@ -54,6 +54,7 @@ import com.yizhuan.erban.ui.gift.dialog.GiftInfoVm;
import com.yizhuan.erban.ui.gift.dialog.MagicInfoVm;
import com.yizhuan.erban.ui.gift.dialog.PageIndicatorView;
import com.yizhuan.erban.ui.pay.ChargeActivity;
import com.yizhuan.erban.ui.pay.ChargeDialog;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.ui.webview.DialogWebViewActivity;
@@ -956,7 +957,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (itemType == ITEM_TYPE_GOLD) {
StatisticManager.Instance().onEvent(StatisticsProtocol.EVENT_GIFT_PANEL_TO_RECHARGE, "礼物面板_去充值:" + GIFT_DIALOG_FROM);
ChargeActivity.start(getContext());
ChargeDialog.start(getContext());
} else if (itemType == ITEM_TYPE_RADISH) {
TaskCenterActivity.start(context, TaskCenterActivity.FromPage.GIFT);
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -2,16 +2,16 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape android:shape="rectangle">
<corners android:radius="@dimen/dp_5" />
<stroke android:width="2dp" android:color="@color/app_248cfe" />
<solid android:color="@color/bg_secondary_2a2a39" />
<corners android:radius="@dimen/dp_8" />
<stroke android:width="1dp" android:color="@color/app_248cfe" />
<solid android:color="#FFFFFAEE" />
</shape>
</item>
<item>
<shape android:shape="rectangle">
<solid android:color="@color/bg_secondary_2a2a39" />
<corners android:radius="@dimen/dp_5" />
<corners android:radius="@dimen/dp_8" />
</shape>
</item>
</selector>

View File

@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid android:color="@color/color_f4f4fa"/>
<corners android:topLeftRadius="@dimen/dp_8"
android:topRightRadius="@dimen/dp_8"/>
</shape>

View File

@@ -11,16 +11,16 @@
android:id="@+id/iv_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:src="@mipmap/bg_charge"
android:scaleType="fitXY"
app:layout_constraintTop_toTopOf="parent"
/>
android:src="@mipmap/bg_charge"
app:layout_constraintTop_toTopOf="parent" />
<com.yizhuan.erban.base.TitleBar
android:id="@+id/title_bar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_30"
tools:layout_height="50dp"
app:layout_constraintTop_toTopOf="parent" />
@@ -30,7 +30,7 @@
android:layout_height="wrap_content"
android:text="我的钻石"
android:textSize="@dimen/dp_13"
android:textColor="@color/white"
android:textColor="@color/color_333333"
android:drawableStart="@mipmap/ic_charge_diamond"
android:drawablePadding="@dimen/dp_4"
android:layout_below="@id/title_bar"
@@ -44,20 +44,20 @@
android:id="@+id/tv_gold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/appColor"
android:textSize="@dimen/dp_36"
android:textColor="@color/color_333333"
android:textSize="@dimen/dp_24"
android:layout_below="@id/tv_title_diamond"
android:layout_centerHorizontal="true"
android:fontFamily="sans-serif-medium"
android:includeFontPadding="false"
tools:text="50" />
<androidx.core.widget.NestedScrollView
android:id="@+id/nsv_charge"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/tv_gold"
android:layout_marginTop="30dp"
android:layout_marginTop="45dp"
>
<LinearLayout
@@ -73,7 +73,17 @@
android:paddingStart="@dimen/dp_11"
android:paddingEnd="@dimen/dp_11"
android:visibility="visible" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_marginStart="30dp"
android:layout_marginEnd="30dp"
android:layout_marginTop="16dp"
android:text="未成年禁止充值消费!请勿轻易相信各类刷单、退款等信息,以免上当受骗!"
android:textColor="@color/color_666666"
android:textSize="14sp"
/>
<LinearLayout
android:layout_width="match_parent"
@@ -83,7 +93,7 @@
android:background="@drawable/bg_secondary_radius_5"
android:layout_marginStart="@dimen/dp_15"
android:layout_marginEnd="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_13"
android:layout_marginTop="@dimen/dp_16"
>

View File

@@ -1,74 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent">
<RelativeLayout
android:id="@+id/container"
android:layout_width="290dp"
android:layout_height="216dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true">
<RelativeLayout
android:id="@+id/open_red_packet"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/icon_charge_dialog_bg"
android:visibility="visible">
</RelativeLayout>
</RelativeLayout>
<LinearLayout
android:id="@+id/tip_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_below="@+id/container"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="14dp"
android:text="您已成功兑换"
/>
<TextView
android:id="@+id/gold_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/appColor"
android:textSize="16dp"
android:text="20钻石"
android:textStyle="bold"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:textSize="14dp"
android:text=",可到我的钱包里查看"
/>
</LinearLayout>
<Button
android:id="@+id/btn_charge"
android:layout_width="181dp"
android:layout_height="40dp"
android:layout_marginTop="20dp"
android:layout_below="@+id/tip_container"
android:layout_centerHorizontal="true"
android:background="@drawable/shape_semi_round_gray_solid"
android:text="我知道了"
android:textColor="@color/white"
android:textSize="16dp" />
</RelativeLayout>

View File

@@ -0,0 +1,239 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="505dp"
android:layout_gravity="bottom"
android:background="@drawable/shape_f4f4fa_top_8dp"
android:orientation="vertical">
<com.yizhuan.erban.base.TitleBar
android:id="@+id/title_bar"
android:layout_marginTop="5dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent" />
<LinearLayout
android:id="@+id/ll_gold"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/title_bar"
android:layout_marginTop="15dp"
android:baselineAligned="true"
android:orientation="horizontal">
<TextView
android:id="@+id/tv_title_diamond"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:drawablePadding="@dimen/dp_4"
android:text="我的钻石:"
android:textColor="@color/color_333333"
android:textSize="@dimen/dp_14" />
<TextView
android:id="@+id/tv_gold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:includeFontPadding="false"
android:textColor="@color/color_333333"
android:textSize="@dimen/dp_15"
android:textStyle="bold"
tools:text="50" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="15dp"
android:text="未成年人禁止充值"
android:textColor="#ff666666"
android:textSize="12sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/ll_gold"
android:layout_marginTop="15dp"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="186dp"
tools:itemCount="3"
tools:listitem="@layout/list_item_charge"
android:paddingStart="@dimen/dp_11"
android:paddingEnd="@dimen/dp_11"
android:visibility="visible" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/dp_15"
android:layout_marginTop="@dimen/dp_16"
android:layout_marginEnd="@dimen/dp_15"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="支付方式"
android:textColor="@color/text_normal_c6c6e9"
android:textSize="@dimen/dp_13" />
<LinearLayout
android:id="@+id/ll_charge_type"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:orientation="horizontal">
<LinearLayout
android:id="@+id/ll_type_first"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:background="@drawable/selector_dialog_charge"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_type_first"
android:layout_width="28dp"
android:layout_height="28dp"
android:clickable="false"
tools:src="@drawable/dialog_charge_ic_wechat" />
<TextView
android:id="@+id/tv_type_first"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:clickable="false"
android:textColor="@color/text_title_white"
android:textSize="@dimen/dp_15"
tools:text="微信支付" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_type_second"
android:layout_width="0dp"
android:layout_height="48dp"
android:layout_weight="1"
android:layout_marginStart="13dp"
android:background="@drawable/selector_dialog_charge"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:orientation="horizontal">
<ImageView
android:id="@+id/iv_type_second"
android:layout_width="28dp"
android:layout_height="28dp"
android:clickable="false"
tools:src="@drawable/dialog_charge_ic_alipay" />
<TextView
android:id="@+id/tv_type_second"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="10dp"
android:clickable="false"
android:textColor="@color/text_title_white"
android:textSize="@dimen/dp_15"
tools:text="支付宝支付" />
</LinearLayout>
<LinearLayout
android:id="@+id/ll_more"
android:layout_width="0dp"
android:layout_marginStart="13dp"
android:layout_height="48dp"
android:layout_weight="1"
android:clickable="true"
android:focusable="true"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"
tools:visibility="gone">
<com.yizhuan.xchat_android_library.widget.DrawableCenterTextView
android:id="@+id/tv_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:drawableEnd="@drawable/arrow_right"
android:drawablePadding="4dp"
android:gravity="center"
android:text="展开更多支付方式"
android:textColor="@color/text_normal_c6c6e9"
android:textSize="@dimen/dp_13" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
<TextView
android:id="@+id/tv_charge"
android:layout_width="match_parent"
android:layout_height="45dp"
android:layout_marginStart="60dp"
android:layout_marginTop="24dp"
android:layout_marginEnd="@dimen/dp_60"
android:background="@drawable/bg_common_confirm_normal"
android:gravity="center"
android:text="确认充值"
android:textColor="@color/white"
android:textSize="@dimen/dp_15"
app:layout_constraintBottom_toBottomOf="parent" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/dp_12"
android:layout_marginBottom="@dimen/dp_20"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/charge_agreement"
android:textColor="@color/text_secondary_4f516a"
android:textSize="@dimen/sp_12" />
<TextView
android:id="@+id/tv_agreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/agreement"
android:textColor="@color/app_248cfe"
android:textSize="@dimen/sp_12" />
</LinearLayout>
</LinearLayout>
</RelativeLayout>

View File

@@ -1,45 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_gold_charge"
android:layout_width="match_parent"
android:layout_height="85dp"
xmlns:tools="http://schemas.android.com/tools"
android:gravity="center"
android:orientation="vertical"
android:layout_height="64dp"
android:layout_margin="@dimen/dp_4"
android:background="@drawable/selector_gold_price" >
android:background="@drawable/selector_gold_price"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
>
android:gravity="center">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_charge_diamond" />
<TextView
android:id="@+id/tv_money_gold"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/color_selector_app_color_false_white"
android:layout_marginStart="5dp"
android:fontFamily="sans-serif-medium"
android:includeFontPadding="false"
android:textSize="18dp"
android:textColor="@color/color_333333"
android:textSize="14dp"
tools:text="8" />
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="@string/diamond"
android:textSize="@dimen/dp_11"
android:gravity="center_vertical"
android:layout_marginStart="@dimen/dp_5"
android:gravity="center_vertical"
android:text="@string/diamond"
android:textColor="@color/text_normal_c6c6e9"
/>
android:textSize="@dimen/dp_11"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/cb_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="15dp"
tools:text="¥8元"
android:textColor="@color/text_normal_c6c6e9" />
android:textColor="@color/color_999999"
android:textSize="12dp"
tools:text="¥8元" />
</LinearLayout>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 299 KiB

After

Width:  |  Height:  |  Size: 284 KiB