同步PIKO:完成送礼可用金币+钻石功能
This commit is contained in:
@@ -32,9 +32,6 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||
import com.chad.library.adapter.base.BaseViewHolder;
|
||||
import com.chwl.core.utils.extension.StringExtensionKt;
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog;
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
|
||||
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
|
||||
@@ -45,13 +42,10 @@ import com.chwl.app.application.ReportManager;
|
||||
import com.chwl.app.base.BaseActivity;
|
||||
import com.chwl.app.common.widget.CircleImageView;
|
||||
import com.chwl.app.radish.task.activity.TaskCenterActivity;
|
||||
import com.chwl.app.ui.adapter.StarWeekAdapter;
|
||||
import com.chwl.app.ui.gift.dialog.GiftInfoVm;
|
||||
import com.chwl.app.ui.gift.dialog.PageIndicatorView;
|
||||
import com.chwl.app.ui.pay.ChargeActivity;
|
||||
import com.chwl.app.ui.utils.ImageLoadUtils;
|
||||
import com.chwl.app.ui.webview.CommonWebViewActivity;
|
||||
import com.chwl.app.ui.webview.DialogWebViewActivity;
|
||||
import com.chwl.app.ui.widget.dialog.GiftManualQuantityDialog;
|
||||
import com.chwl.app.ui.widget.drawgift.DrawGiftHelper;
|
||||
import com.chwl.app.ui.widget.drawgift.DrawGiftView;
|
||||
@@ -61,16 +55,12 @@ import com.chwl.app.ui.widget.recyclerview.decoration.VerticalDecoration;
|
||||
import com.chwl.app.utils.RegexUtil;
|
||||
import com.chwl.app.utils.SpannableBuilder;
|
||||
import com.chwl.app.vip.VipMainActivity;
|
||||
import com.chwl.core.Constants;
|
||||
import com.chwl.core.UriProvider;
|
||||
import com.chwl.core.auth.AuthModel;
|
||||
import com.chwl.core.bean.RoomQueueInfo;
|
||||
import com.chwl.core.gift.GiftModel;
|
||||
import com.chwl.core.gift.bean.GiftInfo;
|
||||
import com.chwl.core.gift.bean.GiftTab;
|
||||
import com.chwl.core.gift.bean.GiftType;
|
||||
import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
|
||||
import com.chwl.core.gift.bean.SimpleUserInfo;
|
||||
import com.chwl.core.gift.event.UpdateKnapEvent;
|
||||
import com.chwl.core.gift.event.UpdateKnapFreeGiftDataEvent;
|
||||
import com.chwl.core.gift.event.UpdateKnapFreeGiftEvent;
|
||||
@@ -82,9 +72,7 @@ import com.chwl.core.manager.IMNetEaseManager;
|
||||
import com.chwl.core.manager.RoomEvent;
|
||||
import com.chwl.core.pay.PayModel;
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.core.pay.event.FirstChargeEvent;
|
||||
import com.chwl.core.pay.event.UpdateWalletInfoEvent;
|
||||
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent;
|
||||
import com.chwl.core.room.pk.model.PkModel;
|
||||
import com.chwl.core.room.queue.bean.MicMemberInfo;
|
||||
import com.chwl.core.user.UserModel;
|
||||
@@ -92,15 +80,11 @@ import com.chwl.core.user.bean.UserInfo;
|
||||
import com.chwl.core.utils.net.RxHelper;
|
||||
import com.chwl.library.bindinglist.IItem;
|
||||
import com.chwl.library.bindinglist.MultiTypeAdapter;
|
||||
import com.chwl.library.common.util.DeviceUtil;
|
||||
import com.chwl.library.utils.AppMetaDataUtil;
|
||||
import com.chwl.library.utils.FormatUtils;
|
||||
import com.chwl.library.utils.ListUtils;
|
||||
import com.chwl.library.utils.ResUtil;
|
||||
import com.chwl.library.utils.SingleToastUtil;
|
||||
import com.chwl.library.utils.TextWatcherWrapper;
|
||||
import com.zhpan.bannerview.BannerViewPager;
|
||||
import com.zhpan.bannerview.utils.BannerUtils;
|
||||
import com.zyyoona7.lib.EasyPopup;
|
||||
import com.zyyoona7.lib.HorizontalGravity;
|
||||
import com.zyyoona7.lib.VerticalGravity;
|
||||
@@ -109,13 +93,12 @@ import org.greenrobot.eventbus.EventBus;
|
||||
import org.greenrobot.eventbus.Subscribe;
|
||||
import org.greenrobot.eventbus.ThreadMode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.Single;
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
||||
import io.reactivex.disposables.CompositeDisposable;
|
||||
@@ -510,6 +493,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
});
|
||||
|
||||
compositeDisposable.add(GiftModel.get().requestKnapGiftInfos().subscribe());
|
||||
PayModel.get().getMyRemoteWalletInfo().compose(RxHelper.bindContext(context))
|
||||
.subscribe(info -> {
|
||||
goldWalletInfo = info;
|
||||
setGoldOrRadishText(lastSelectedItem);
|
||||
});
|
||||
}
|
||||
|
||||
private void showLoadingAnimation() {
|
||||
@@ -552,10 +540,25 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
||||
itemType = ITEM_TYPE_GOLD;
|
||||
|
||||
tvRecharge.setVisibility(View.VISIBLE);
|
||||
tvRecharge.setText(context.getText(R.string.charge));
|
||||
tvRecharge.setText(context.getText(R .string.charge));
|
||||
if (goldWalletInfo == null) {
|
||||
return;
|
||||
}
|
||||
if (goldWalletInfo.canGoldSendGift) {
|
||||
findViewById(R.id.iv_plus).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.iv_gold).setVisibility(View.VISIBLE);
|
||||
BigDecimal total = BigDecimal.valueOf(goldWalletInfo.getDiamondNum());
|
||||
total = total.add(BigDecimal.valueOf(goldWalletInfo.getGoldNum()));
|
||||
total = total.setScale(0, RoundingMode.DOWN);
|
||||
tvTextGold.setText(total.toPlainString());
|
||||
} else {
|
||||
findViewById(R.id.iv_plus).setVisibility(View.GONE);
|
||||
findViewById(R.id.iv_gold).setVisibility(View.GONE);
|
||||
BigDecimal total = BigDecimal.valueOf(goldWalletInfo.getDiamondNum());
|
||||
total = total.setScale(0, RoundingMode.DOWN);
|
||||
tvTextGold.setText(total.toPlainString());
|
||||
}
|
||||
|
||||
String goldNumText = getContext().getString(R.string.gold_num_text, goldWalletInfo.getDiamondNum());
|
||||
SpannableBuilder builder = new SpannableBuilder();
|
||||
builder.append(context.getText(R.string.gift_wallet_overage), new ForegroundColorSpan(
|
||||
|
26
app/src/main/res/drawable/gift_dialog_ic_plus.xml
Normal file
26
app/src/main/res/drawable/gift_dialog_ic_plus.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="14dp"
|
||||
android:height="14dp"
|
||||
android:viewportWidth="14"
|
||||
android:viewportHeight="14">
|
||||
<path
|
||||
android:pathData="M0,0h14v14h-14z"
|
||||
android:strokeAlpha="0"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#000000"
|
||||
android:fillType="nonZero"
|
||||
android:strokeColor="#00000000"
|
||||
android:fillAlpha="0"/>
|
||||
<path
|
||||
android:pathData="M6.59,2.078L7.41,2.078C7.483,2.078 7.52,2.115 7.52,2.188L7.52,11.813C7.52,11.885 7.483,11.922 7.41,11.922L6.59,11.922C6.517,11.922 6.48,11.885 6.48,11.813L6.48,2.188C6.48,2.115 6.517,2.078 6.59,2.078Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:strokeColor="#00000000"/>
|
||||
<path
|
||||
android:pathData="M2.406,6.48L11.594,6.48C11.667,6.48 11.703,6.517 11.703,6.59L11.703,7.41C11.703,7.483 11.667,7.52 11.594,7.52L2.406,7.52C2.333,7.52 2.297,7.483 2.297,7.41L2.297,6.59C2.297,6.517 2.333,6.48 2.406,6.48Z"
|
||||
android:strokeWidth="1"
|
||||
android:fillColor="#FFFFFF"
|
||||
android:fillType="nonZero"
|
||||
android:strokeColor="#00000000"/>
|
||||
</vector>
|
@@ -424,6 +424,7 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="@dimen/dp_50">
|
||||
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_recharge"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -432,27 +433,56 @@
|
||||
android:layout_toEndOf="@+id/tv_text_gold"
|
||||
android:drawablePadding="@dimen/dp_5"
|
||||
android:gravity="center"
|
||||
android:paddingStart="@dimen/dp_13"
|
||||
android:paddingEnd="@dimen/dp_13"
|
||||
android:paddingStart="@dimen/dp_10"
|
||||
android:paddingEnd="@dimen/dp_10"
|
||||
android:text="@string/charge"
|
||||
android:textColor="@color/color_FACB4D"
|
||||
android:textSize="@dimen/sp_13"
|
||||
app:drawableEndCompat="@drawable/ic_arrow_recharge_auto_mirrored" />
|
||||
app:drawableEndCompat="@drawable/ic_arrow_recharge" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_diamond"
|
||||
android:layout_width="@dimen/dp_16"
|
||||
android:layout_height="@dimen/dp_16"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_16"
|
||||
android:src="@drawable/ic_gift_diamond" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_plus"
|
||||
android:layout_width="@dimen/dp_14"
|
||||
android:layout_height="@dimen/dp_14"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_1"
|
||||
android:layout_toEndOf="@id/iv_diamond"
|
||||
android:src="@drawable/gift_dialog_ic_plus"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_gold"
|
||||
android:layout_width="@dimen/dp_14"
|
||||
android:layout_height="@dimen/dp_14"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_marginStart="@dimen/dp_2"
|
||||
android:layout_toEndOf="@id/iv_plus"
|
||||
android:src="@drawable/ic_gold"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_text_gold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerVertical="true"
|
||||
android:layout_alignParentStart="true"
|
||||
android:layout_marginStart="@dimen/dp_15"
|
||||
android:drawablePadding="3dp"
|
||||
android:layout_marginStart="@dimen/dp_2"
|
||||
android:layout_toEndOf="@id/iv_gold"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:text="0"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/sp_14"
|
||||
app:drawableEndCompat="@drawable/ic_gift_diamond" />
|
||||
android:textSize="@dimen/dp_14"
|
||||
tools:text="10000" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/send_container"
|
||||
|
@@ -11,6 +11,7 @@ import android.util.Log;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.chwl.core.pay.event.UpdateWalletInfoEvent;
|
||||
import com.netease.nim.uikit.common.util.log.LogUtil;
|
||||
import com.netease.nimlib.sdk.chatroom.model.ChatRoomMessage;
|
||||
import com.netease.nimlib.sdk.msg.constant.MsgTypeEnum;
|
||||
@@ -390,7 +391,12 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
||||
//应通过id去确定要需要更新的礼物背包
|
||||
EventBus.getDefault().post(new UpdateKnapEvent(giftId, finalGiftNum * targetUids.size()));
|
||||
} else {
|
||||
PayModel.get().minusGold(giftInfo.getGoldPrice() * finalGiftNum * targetUids.size());
|
||||
if (serviceResult.getData() != null && serviceResult.getData().getUserPurse() != null) {
|
||||
PayModel.get().setWalletInfo(serviceResult.getData().getUserPurse());
|
||||
EventBus.getDefault().post(new UpdateWalletInfoEvent());
|
||||
} else {
|
||||
PayModel.get().refreshWalletInfo(true);
|
||||
}
|
||||
}
|
||||
GiftMultiReceiverInfo giftMultiReceiverInfo = serviceResult.getData();
|
||||
if (giftId != giftMultiReceiverInfo.getGiftId()) {
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.chwl.core.gift.bean;
|
||||
|
||||
import com.chwl.core.pay.bean.WalletInfo;
|
||||
import com.chwl.core.room.giftvalue.bean.IndexGiftValue;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -26,4 +27,5 @@ public class GiftMultiReceiverInfo implements Serializable {
|
||||
private List<LuckyBagGifts> luckyBagGifts;
|
||||
private List<Long> targetUids;
|
||||
private LuckyGiftList luckyGiftList;
|
||||
private WalletInfo userPurse;
|
||||
}
|
||||
|
@@ -23,6 +23,8 @@ import io.reactivex.Single;
|
||||
*/
|
||||
|
||||
public interface IPayModel extends IModel {
|
||||
void refreshWalletInfo(boolean isNotice);
|
||||
|
||||
WalletInfo getCurrentWalletInfo();
|
||||
|
||||
void minusGold(float price);
|
||||
|
@@ -90,6 +90,15 @@ public class PayModel extends BaseModel implements IPayModel {
|
||||
EventBus.getDefault().register(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refreshWalletInfo(boolean isNotice) {
|
||||
getMyRemoteWalletInfo().subscribe(info -> {
|
||||
if (isNotice) {
|
||||
EventBus.getDefault().post(new UpdateWalletInfoEvent());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public WalletInfo getCurrentWalletInfo() {
|
||||
return walletInfo;
|
||||
@@ -134,6 +143,9 @@ public class PayModel extends BaseModel implements IPayModel {
|
||||
walletInfo.setCrystals(jsonObject.getDoubleValue("crystals"));
|
||||
walletInfo.nobleGoldNum = jsonObject.getDoubleValue("nobleGoldNum");
|
||||
walletInfo.chargeGoldNum = jsonObject.getDoubleValue("chargeGoldNum");
|
||||
if (jsonObject.containsKey("canGoldSendGift")) {
|
||||
walletInfo.canGoldSendGift = jsonObject.getBoolean("canGoldSendGift");
|
||||
}
|
||||
this.walletInfo = walletInfo;
|
||||
// 兼容新版
|
||||
setWalletInfo(walletInfo);
|
||||
|
@@ -38,6 +38,10 @@ public class WalletInfo implements Parcelable {
|
||||
private double canGiveGoldNum;
|
||||
/** 1:默认line,2:默认facebook */
|
||||
private int defaultPay;
|
||||
/**
|
||||
* 是否可以在送礼时合并使用金币
|
||||
*/
|
||||
public boolean canGoldSendGift;
|
||||
|
||||
public WalletInfo() {
|
||||
}
|
||||
@@ -53,6 +57,7 @@ public class WalletInfo implements Parcelable {
|
||||
nobleGoldNum = in.readDouble();
|
||||
canGiveGoldNum = in.readDouble();
|
||||
defaultPay = in.readInt();
|
||||
canGoldSendGift = in.readInt() == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -66,6 +71,7 @@ public class WalletInfo implements Parcelable {
|
||||
dest.writeDouble(nobleGoldNum);
|
||||
dest.writeDouble(canGiveGoldNum);
|
||||
dest.writeInt(defaultPay);
|
||||
dest.writeInt(canGoldSendGift ? 1 : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user