feat:完成送礼后的解锁礼物本地状态更新逻辑
This commit is contained in:
@@ -29,6 +29,8 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
|||||||
|
|
||||||
public final ObservableField<String> countText = new ObservableField<>();
|
public final ObservableField<String> countText = new ObservableField<>();
|
||||||
|
|
||||||
|
public final ObservableBoolean isLocked = new ObservableBoolean();
|
||||||
|
|
||||||
public Drawable nobleDrawable;
|
public Drawable nobleDrawable;
|
||||||
|
|
||||||
public Drawable radishDrawable;
|
public Drawable radishDrawable;
|
||||||
@@ -55,8 +57,6 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
|||||||
*/
|
*/
|
||||||
public boolean isExclusive;
|
public boolean isExclusive;
|
||||||
|
|
||||||
public boolean isLocked;
|
|
||||||
|
|
||||||
public String vipIcon;
|
public String vipIcon;
|
||||||
|
|
||||||
public boolean isPrivateChat;
|
public boolean isPrivateChat;
|
||||||
@@ -89,15 +89,8 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
|||||||
isShowEffect = data.isHasEffect();
|
isShowEffect = data.isHasEffect();
|
||||||
isExclusive = data.isRoomExclude();
|
isExclusive = data.isRoomExclude();
|
||||||
SimpleVipInfo vipInfo = data.getGiftVipInfo();
|
SimpleVipInfo vipInfo = data.getGiftVipInfo();
|
||||||
isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
|
|
||||||
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();
|
vipIcon = vipInfo == null ? "" : vipInfo.getVipIcon();
|
||||||
if (!isLocked) {
|
isLocked.set(getIsLocked());
|
||||||
if (data.getGiftType() == GiftType.GIFT_TYPE_UNLOCK) {
|
|
||||||
if (!data.isUnlocked()) {
|
|
||||||
isLocked = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -114,4 +107,20 @@ public class GiftInfoVm extends BaseItem<GiftInfo> {
|
|||||||
this.countText.set("x" + data.getCount());
|
this.countText.set("x" + data.getCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void refreshUnlockState() {
|
||||||
|
isLocked.set(getIsLocked());
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getIsLocked() {
|
||||||
|
SimpleVipInfo vipInfo = data.getGiftVipInfo();
|
||||||
|
boolean isLocked = vipInfo != null && VipHelper.getMyVipLevel() < vipInfo.getVipLevel();
|
||||||
|
if (!isLocked) {
|
||||||
|
if (data.getGiftType() == GiftType.GIFT_TYPE_UNLOCK) {
|
||||||
|
if (!data.isUnlocked()) {
|
||||||
|
isLocked = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isLocked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -61,4 +61,8 @@ class GIftDialogUnlockPanel : CardView {
|
|||||||
recyclerView?.smoothScrollToPosition(index)
|
recyclerView?.smoothScrollToPosition(index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun refreshState() {
|
||||||
|
adapter.notifyItemRangeChanged(0, adapter.itemCount, true)
|
||||||
|
}
|
||||||
}
|
}
|
@@ -75,6 +75,7 @@ import com.nnbc123.core.gift.bean.GiftPrivilegeInfo;
|
|||||||
import com.nnbc123.core.gift.bean.GiftTab;
|
import com.nnbc123.core.gift.bean.GiftTab;
|
||||||
import com.nnbc123.core.gift.bean.GiftType;
|
import com.nnbc123.core.gift.bean.GiftType;
|
||||||
import com.nnbc123.core.gift.bean.LuckyBagNoticeInfo;
|
import com.nnbc123.core.gift.bean.LuckyBagNoticeInfo;
|
||||||
|
import com.nnbc123.core.gift.bean.UnLockGiftInfo;
|
||||||
import com.nnbc123.core.gift.event.UpdateKnapEvent;
|
import com.nnbc123.core.gift.event.UpdateKnapEvent;
|
||||||
import com.nnbc123.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
import com.nnbc123.core.im.custom.bean.RoomReceivedLuckyGiftAttachment;
|
||||||
import com.nnbc123.core.initial.InitialModel;
|
import com.nnbc123.core.initial.InitialModel;
|
||||||
@@ -216,7 +217,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
private AppCompatTextView tvNum;
|
private AppCompatTextView tvNum;
|
||||||
private SuperTextView tvPrivilegeGive;
|
private SuperTextView tvPrivilegeGive;
|
||||||
private Group groupPrivilege;
|
private Group groupPrivilege;
|
||||||
private GIftDialogUnlockPanel panelUnLock;
|
private GIftDialogUnlockPanel unLockPanel;
|
||||||
|
|
||||||
private int mPrivilegePosition = 0;
|
private int mPrivilegePosition = 0;
|
||||||
|
|
||||||
@@ -423,7 +424,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
ivDrawGiftRemoveLast = findViewById(R.id.iv_draw_gift_remove_last);
|
ivDrawGiftRemoveLast = findViewById(R.id.iv_draw_gift_remove_last);
|
||||||
ivDrawGiftRemoveAll = findViewById(R.id.iv_draw_gift_remove_all);
|
ivDrawGiftRemoveAll = findViewById(R.id.iv_draw_gift_remove_all);
|
||||||
ivDrawGiftClose = findViewById(R.id.iv_draw_gift_close);
|
ivDrawGiftClose = findViewById(R.id.iv_draw_gift_close);
|
||||||
panelUnLock = findViewById(R.id.panel_unlock);
|
unLockPanel = findViewById(R.id.panel_unlock);
|
||||||
ivDrawGiftClose.setOnClickListener(this);
|
ivDrawGiftClose.setOnClickListener(this);
|
||||||
ivDrawGiftRemoveLast.setOnClickListener(this);
|
ivDrawGiftRemoveLast.setOnClickListener(this);
|
||||||
ivDrawGiftRemoveAll.setOnClickListener(this);
|
ivDrawGiftRemoveAll.setOnClickListener(this);
|
||||||
@@ -880,7 +881,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateUnLockTips() {
|
private void updateUnLockTips() {
|
||||||
panelUnLock.update(currentGiftInfo);
|
unLockPanel.update(currentGiftInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLuckyBagIntro() {
|
private void updateLuckyBagIntro() {
|
||||||
@@ -914,11 +915,14 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
.flatMap(luckyBagNoticeInfos -> Observable.intervalRange(0, Integer.MAX_VALUE, 0, 5, TimeUnit.SECONDS))
|
.flatMap(luckyBagNoticeInfos -> Observable.intervalRange(0, Integer.MAX_VALUE, 0, 5, TimeUnit.SECONDS))
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.subscribe(aLong -> {
|
.subscribe(aLong -> {
|
||||||
int index = aLong.intValue() % luckyMsgAdapter.getItemCount();
|
int count = luckyMsgAdapter.getItemCount();
|
||||||
if (index == 0) {
|
if (count > 0) {
|
||||||
rvLuckyMsg.scrollToPosition(index);
|
int index = aLong.intValue() % count;
|
||||||
} else {
|
if (index == 0) {
|
||||||
rvLuckyMsg.smoothScrollToPosition(index);
|
rvLuckyMsg.scrollToPosition(index);
|
||||||
|
} else {
|
||||||
|
rvLuckyMsg.smoothScrollToPosition(index);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -1333,10 +1337,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
micMemberInfo.setAccount(String.valueOf(uid));
|
micMemberInfo.setAccount(String.valueOf(uid));
|
||||||
targetUids.add(micMemberInfo);
|
targetUids.add(micMemberInfo);
|
||||||
Log.e(TAG, "onClick: indicator type: " + giftIndicator.getCurrrentType());
|
Log.e(TAG, "onClick: indicator type: " + giftIndicator.getCurrrentType());
|
||||||
|
int number = giftNumber == -1 ? finalCurrentGiftInfo.getCount() : giftNumber;
|
||||||
giftDialogBtnClickListener.onSendGiftBtnClick(
|
giftDialogBtnClickListener.onSendGiftBtnClick(
|
||||||
finalCurrentGiftInfo,
|
finalCurrentGiftInfo,
|
||||||
targetUids,
|
targetUids,
|
||||||
giftNumber == -1 ? finalCurrentGiftInfo.getCount() : giftNumber,
|
number,
|
||||||
giftMessage,
|
giftMessage,
|
||||||
giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP,
|
giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP,
|
||||||
false,
|
false,
|
||||||
@@ -1344,7 +1349,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
new SenGiftCallback() {
|
new SenGiftCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
onSendGiftSuccess(finalCurrentGiftInfo);
|
onSendGiftSuccess(finalCurrentGiftInfo, number, targetUids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1363,10 +1368,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
micMemberInfo.setAccount(String.valueOf(uid));
|
micMemberInfo.setAccount(String.valueOf(uid));
|
||||||
targetUids.add(micMemberInfo);
|
targetUids.add(micMemberInfo);
|
||||||
Log.e(TAG, "onClick: indicator type: " + giftIndicator.getCurrrentType());
|
Log.e(TAG, "onClick: indicator type: " + giftIndicator.getCurrrentType());
|
||||||
|
int number = giftNumber == -1 ? finalCurrentGiftInfo.getCount() : giftNumber;
|
||||||
giftDialogBtnClickListener.onSendGiftBtnClick(
|
giftDialogBtnClickListener.onSendGiftBtnClick(
|
||||||
finalCurrentGiftInfo,
|
finalCurrentGiftInfo,
|
||||||
targetUids,
|
targetUids,
|
||||||
giftNumber == -1 ? finalCurrentGiftInfo.getCount() : giftNumber,
|
number,
|
||||||
giftMessage,
|
giftMessage,
|
||||||
giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP,
|
giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP,
|
||||||
false,
|
false,
|
||||||
@@ -1374,7 +1380,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
new SenGiftCallback() {
|
new SenGiftCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
onSendGiftSuccess(finalCurrentGiftInfo);
|
onSendGiftSuccess(finalCurrentGiftInfo, number, targetUids);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1395,10 +1401,11 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
sendGiftButton.setEnabled(true);
|
sendGiftButton.setEnabled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
int number = giftNumber == -1 ? finalCurrentGiftInfo.getCount() : giftNumber;
|
||||||
giftDialogBtnClickListener.onSendGiftBtnClick(
|
giftDialogBtnClickListener.onSendGiftBtnClick(
|
||||||
finalCurrentGiftInfo,
|
finalCurrentGiftInfo,
|
||||||
selectedMembers,
|
selectedMembers,
|
||||||
giftNumber == -1 ? finalCurrentGiftInfo.getCount() : giftNumber,
|
number,
|
||||||
giftMessage,
|
giftMessage,
|
||||||
giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP,
|
giftIndicator.getCurrrentType() == GiftIndicator.TYPE_KNAP,
|
||||||
avatarListAdapter.getSelectType() == GiftAvatarAdapter.SELECT_TYPE_WHOLE_MIC,
|
avatarListAdapter.getSelectType() == GiftAvatarAdapter.SELECT_TYPE_WHOLE_MIC,
|
||||||
@@ -1406,7 +1413,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
new SenGiftCallback() {
|
new SenGiftCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess() {
|
public void onSuccess() {
|
||||||
onSendGiftSuccess(finalCurrentGiftInfo);
|
onSendGiftSuccess(finalCurrentGiftInfo, number, selectedMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -1557,7 +1564,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
updateGiftView(giftIndicator.getCurrrentType());
|
updateGiftView(giftIndicator.getCurrrentType());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onSendGiftSuccess(GiftInfo giftInfo) {
|
private void onSendGiftSuccess(GiftInfo giftInfo, int giftNumber, List<MicMemberInfo> receiveUsers) {
|
||||||
if (sendGiftButton == null) return;
|
if (sendGiftButton == null) return;
|
||||||
sendGiftButton.setText("赠送");
|
sendGiftButton.setText("赠送");
|
||||||
sendGiftButton.setEnabled(true);
|
sendGiftButton.setEnabled(true);
|
||||||
@@ -1565,6 +1572,65 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
|
|||||||
SingleToastUtil.showToast("发送涂鸦礼物:" + giftInfo.getGiftName() + "成功");
|
SingleToastUtil.showToast("发送涂鸦礼物:" + giftInfo.getGiftName() + "成功");
|
||||||
clearDrawGift();
|
clearDrawGift();
|
||||||
dismiss();
|
dismiss();
|
||||||
|
} else if (giftInfo.getGiftType() == GiftType.GIFT_TYPE_UNLOCK) {
|
||||||
|
int totalNumber = 0;
|
||||||
|
if (receiveUsers != null) {
|
||||||
|
totalNumber = receiveUsers.size() * giftNumber;
|
||||||
|
}
|
||||||
|
updateUnlockStateSendSuccess(giftInfo, totalNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新本地解锁礼物的数据状态(解锁状态、送出的数量)
|
||||||
|
private void updateUnlockStateSendSuccess(GiftInfo giftInfo, int totalNumber) {
|
||||||
|
if(giftInfo.getGiftType() != GiftType.GIFT_TYPE_UNLOCK){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
GiftInfo baseGift = giftInfo.getBaseGift();
|
||||||
|
if (baseGift == null || baseGift.getGiftId() != giftInfo.getGiftId()) {
|
||||||
|
// 不是基础礼物
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 先更新数据
|
||||||
|
updateUnlockGiftDataState(giftInfo.getGiftId(), totalNumber);
|
||||||
|
// 后更新UI
|
||||||
|
updateUnlockGiftUiState(giftInfo.getGiftId());
|
||||||
|
// 更新提示面板UI
|
||||||
|
unLockPanel.refreshState();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新解锁礼物数据状态
|
||||||
|
private void updateUnlockGiftDataState(int giftId, int number) {
|
||||||
|
List<GiftInfo> panelGiftList = GiftModel.get().getGiftInfoList(GiftType.GIFT_TYPE_UNLOCK);
|
||||||
|
if (panelGiftList == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (GiftInfo item : panelGiftList) {
|
||||||
|
if (item.getGiftType() != GiftType.GIFT_TYPE_UNLOCK) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (item.getBaseGift() == null || item.getBaseGift().getGiftId() != giftId) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
item.updateUnlockProgress(number);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新解锁礼物Ui状态
|
||||||
|
private void updateUnlockGiftUiState(int giftId) {
|
||||||
|
if (giftIndicator.getCurrrentType() != GiftIndicator.TYPE_INTEREST) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ListUtils.isListEmpty(pagerList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (List<GiftInfoVm> page : pagerList) {
|
||||||
|
for (GiftInfoVm item : page) {
|
||||||
|
GiftInfo itemBaseGift = item.data.getBaseGift();
|
||||||
|
if (itemBaseGift != null && itemBaseGift.getGiftId() == giftId) {
|
||||||
|
item.refreshUnlockState();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -31,6 +31,17 @@ class GiftUnLockInfoAdapter(list: List<UnlockItem>) :
|
|||||||
addItemType(UnlockItem.ITEM_TYPE_CHILD, R.layout.gift_dialog_lock_item_child)
|
addItemType(UnlockItem.ITEM_TYPE_CHILD, R.layout.gift_dialog_lock_item_child)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun convertPayloads(
|
||||||
|
helper: BaseViewHolder,
|
||||||
|
item: UnlockItem?,
|
||||||
|
payloads: MutableList<Any>
|
||||||
|
) {
|
||||||
|
super.convertPayloads(helper, item, payloads)
|
||||||
|
if (item?.itemType == UnlockItem.ITEM_TYPE_CHILD) {
|
||||||
|
convertChildState(helper, item)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
override fun convert(helper: BaseViewHolder, item: UnlockItem?) {
|
override fun convert(helper: BaseViewHolder, item: UnlockItem?) {
|
||||||
val giftInfo = item?.getGiftData()
|
val giftInfo = item?.getGiftData()
|
||||||
when (item?.itemType) {
|
when (item?.itemType) {
|
||||||
@@ -62,7 +73,6 @@ class GiftUnLockInfoAdapter(list: List<UnlockItem>) :
|
|||||||
unlockItem = item
|
unlockItem = item
|
||||||
}
|
}
|
||||||
val total = unlockItem?.condition ?: 0
|
val total = unlockItem?.condition ?: 0
|
||||||
val progress = (unlockItem?.process ?: 0).coerceAtMost(total)
|
|
||||||
helper.getView<ImageView>(R.id.iv_cover).load(giftInfo?.giftUrl)
|
helper.getView<ImageView>(R.id.iv_cover).load(giftInfo?.giftUrl)
|
||||||
val nameView = helper.getView<TextView>(R.id.tv_name)
|
val nameView = helper.getView<TextView>(R.id.tv_name)
|
||||||
SpannableTextBuilder(nameView)
|
SpannableTextBuilder(nameView)
|
||||||
@@ -72,27 +82,37 @@ class GiftUnLockInfoAdapter(list: List<UnlockItem>) :
|
|||||||
textColor = nameView.context.getColorById(R.color.color_FFDA24)
|
textColor = nameView.context.getColorById(R.color.color_FFDA24)
|
||||||
)
|
)
|
||||||
.appendText("${baseGiftName ?: ""}可解锁").apply()
|
.appendText("${baseGiftName ?: ""}可解锁").apply()
|
||||||
val progressBar = helper.getView<ProgressBar>(R.id.progress_bar)
|
convertChildState(helper, item)
|
||||||
progressBar.max = total
|
|
||||||
progressBar.progress = progress
|
|
||||||
helper.setText(R.id.tv_count, "$progress/$total")
|
|
||||||
val lockIconView = helper.getView<View>(R.id.iv_lock)
|
|
||||||
val alpha: Float
|
|
||||||
if (unlockItem?.unlocked == true) {
|
|
||||||
alpha = 1f
|
|
||||||
lockIconView.isVisible = false
|
|
||||||
} else {
|
|
||||||
alpha = 0.5f
|
|
||||||
lockIconView.isVisible = true
|
|
||||||
}
|
|
||||||
helper.setAlpha(R.id.tv_name, alpha)
|
|
||||||
helper.setAlpha(R.id.iv_cover, alpha)
|
|
||||||
helper.setAlpha(R.id.tv_count, alpha)
|
|
||||||
helper.setAlpha(R.id.progress_bar, alpha)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun convertChildState(helper: BaseViewHolder, item: UnlockItem?) {
|
||||||
|
var unlockItem: UnLockGiftInfo? = null
|
||||||
|
if (item is UnLockGiftInfo) {
|
||||||
|
unlockItem = item
|
||||||
|
}
|
||||||
|
val total = unlockItem?.condition ?: 0
|
||||||
|
val progress = (unlockItem?.process ?: 0).coerceAtMost(total)
|
||||||
|
val progressBar = helper.getView<ProgressBar>(R.id.progress_bar)
|
||||||
|
progressBar.max = total
|
||||||
|
progressBar.progress = progress
|
||||||
|
helper.setText(R.id.tv_count, "$progress/$total")
|
||||||
|
val lockIconView = helper.getView<View>(R.id.iv_lock)
|
||||||
|
val alpha: Float
|
||||||
|
if (unlockItem?.unlocked == true) {
|
||||||
|
alpha = 1f
|
||||||
|
lockIconView.isVisible = false
|
||||||
|
} else {
|
||||||
|
alpha = 0.5f
|
||||||
|
lockIconView.isVisible = true
|
||||||
|
}
|
||||||
|
helper.setAlpha(R.id.tv_name, alpha)
|
||||||
|
helper.setAlpha(R.id.iv_cover, alpha)
|
||||||
|
helper.setAlpha(R.id.tv_count, alpha)
|
||||||
|
helper.setAlpha(R.id.progress_bar, alpha)
|
||||||
|
}
|
||||||
|
|
||||||
fun setNewData(baseGiftInfo: GiftInfo?, data: MutableList<UnlockItem>?) {
|
fun setNewData(baseGiftInfo: GiftInfo?, data: MutableList<UnlockItem>?) {
|
||||||
this.baseGiftName = baseGiftInfo?.giftName
|
this.baseGiftName = baseGiftInfo?.giftName
|
||||||
super.setNewData(data)
|
super.setNewData(data)
|
||||||
|
@@ -81,7 +81,7 @@ public class GiftIndicator extends LinearLayout {
|
|||||||
public static final int TYPE_PRIVILEGE = 8;
|
public static final int TYPE_PRIVILEGE = 8;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 趣味
|
* 趣味(福袋礼物、解锁礼物、装扮礼物)
|
||||||
*/
|
*/
|
||||||
public static final int TYPE_INTEREST = 9;
|
public static final int TYPE_INTEREST = 9;
|
||||||
|
|
||||||
|
@@ -237,6 +237,7 @@ public class GiftModel extends BaseModel implements IGiftModel {
|
|||||||
giftInfos = allGiftListInfo.getPenaltyGift();
|
giftInfos = allGiftListInfo.getPenaltyGift();
|
||||||
break;
|
break;
|
||||||
case GiftType.GIFT_TYPE_INTEREST:
|
case GiftType.GIFT_TYPE_INTEREST:
|
||||||
|
case GiftType.GIFT_TYPE_UNLOCK:
|
||||||
giftInfos = allGiftListInfo.getInterestGift();
|
giftInfos = allGiftListInfo.getInterestGift();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -111,6 +111,30 @@ public class GiftInfo implements Serializable {
|
|||||||
this.unlocked = unlocked;
|
this.unlocked = unlocked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新解锁进度
|
||||||
|
*/
|
||||||
|
public void updateUnlockProgress(int addNumber) {
|
||||||
|
List<UnLockGiftInfo> childGiftList = getUnlockGiftList();
|
||||||
|
if (childGiftList == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (int j = 0; j < childGiftList.size(); j++) {
|
||||||
|
UnLockGiftInfo childItem = childGiftList.get(j);
|
||||||
|
if (childItem == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
childItem.addProgress(addNumber);
|
||||||
|
GiftInfo childGiftInfo = childItem.getTargetGift();
|
||||||
|
if (childGiftInfo != null && childGiftInfo.getGiftId() == getGiftId()) {
|
||||||
|
Boolean unlocked = childItem.getUnlocked();
|
||||||
|
if (unlocked != null) {
|
||||||
|
this.setUnlocked(unlocked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//<editor-fold defaultstate="collapsed" desc="delombok">
|
//<editor-fold defaultstate="collapsed" desc="delombok">
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
public GiftInfo() {
|
public GiftInfo() {
|
||||||
|
@@ -8,8 +8,8 @@ package com.nnbc123.core.gift.bean
|
|||||||
data class UnLockGiftInfo(
|
data class UnLockGiftInfo(
|
||||||
val targetGift: GiftInfo? = null,
|
val targetGift: GiftInfo? = null,
|
||||||
val condition: Int? = null,
|
val condition: Int? = null,
|
||||||
val process: Int? = null,
|
var process: Int? = null,
|
||||||
val unlocked: Boolean? = null
|
var unlocked: Boolean? = null
|
||||||
) : UnlockItem {
|
) : UnlockItem {
|
||||||
override fun getGiftData(): GiftInfo? {
|
override fun getGiftData(): GiftInfo? {
|
||||||
return targetGift
|
return targetGift
|
||||||
@@ -19,5 +19,13 @@ data class UnLockGiftInfo(
|
|||||||
return UnlockItem.ITEM_TYPE_CHILD
|
return UnlockItem.ITEM_TYPE_CHILD
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 加进度(发送基础礼物成功后:数量累加)
|
||||||
|
fun addProgress(count: Int) {
|
||||||
|
val p = process ?: 0
|
||||||
|
process = p + count
|
||||||
|
if ((process ?: 0) >= (condition ?: 0)) {
|
||||||
|
unlocked = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user