开箱消息对外展示开关增加等级限制

This commit is contained in:
huangjian
2022-05-05 10:29:34 +08:00
parent 3f8af55c58
commit a2e7775425
5 changed files with 42 additions and 14 deletions

View File

@@ -27,4 +27,12 @@ public class UserUtils {
return AvRoomDataManager.get().mCurrentRoomInfo.getRoomId();
}
public static int getExpLevel() {
UserInfo userInfo = UserModel.get().getCacheLoginUserInfo();
if (userInfo != null && userInfo.getUserLevelVo() != null) {
return userInfo.getUserLevelVo().getExperLevelSeq();
}
return 0;
}
}

View File

@@ -50,15 +50,16 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
@ActLayoutRes(R.layout.activity_treasure_box)
public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBoxBinding> implements View.OnClickListener {
private final Runnable removeRunnable = () -> mBinding.llPrizeHint.removeAllViews();
private int price = 20;
private volatile int keyNum;
private ArrayList<PrizeInfo> cacheList = new ArrayList<>();
private ArrayList<PrizeInfo> hintPrizeCacheList = new ArrayList<>();
private ObjectAnimator translationXAnimator;
private ObjectAnimator translationYAnimator;
private int boxType = IBoxModel.BOX_TYPE_NORMAL;
private int height;
private int sendMessageSwitchLevel;
public static void start(Context context) {
Intent starter = new Intent(context, TreasureBoxActivity.class);
@@ -123,6 +124,7 @@ public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBox
.subscribe(keyInfo -> {
changeKeyNum(keyInfo.getKeyNum());
price = keyInfo.getKeyPrice();
sendMessageSwitchLevel = keyInfo.getSendMessageSwitchLevel();
});
}
@@ -133,7 +135,7 @@ public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBox
finish();
break;
case R.id.iv_more:
new BoxMoreDialog(context).openDialog();
new BoxMoreDialog(context, sendMessageSwitchLevel).openDialog();
break;
case R.id.tv_rank:
// DialogWebViewActivity.start(context, UriProvider.getBoxRank(), false);
@@ -208,7 +210,6 @@ public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBox
.subscribe(prizeInfo -> hintPrizeCacheList.add(prizeInfo));
}
@SuppressLint("CheckResult")
private void looperPrize() {
Observable.interval(0, 100, TimeUnit.MILLISECONDS)
@@ -231,8 +232,6 @@ public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBox
}
private final Runnable removeRunnable = () -> mBinding.llPrizeHint.removeAllViews();
@SuppressLint("CheckResult")
private void looperHintPrize() {
Observable.interval(0, 250, TimeUnit.MILLISECONDS)
@@ -262,7 +261,7 @@ public class TreasureBoxActivity extends BaseBindingActivity<ActivityTreasureBox
linearLayout.setBackgroundResource(R.drawable.bg_box_prize_hint_v5);
break;
}
linearLayout.setPadding(ScreenUtil.dip2px(10),0,ScreenUtil.dip2px(10),0);
linearLayout.setPadding(ScreenUtil.dip2px(10), 0, ScreenUtil.dip2px(10), 0);
mBinding.llPrizeHint.addView(linearLayout);
if (mBinding.llPrizeHint.getChildCount() > 6) {
mBinding.llPrizeHint.removeViewAt(0);

View File

@@ -58,6 +58,7 @@ public class TreasureBoxHonourActivity extends BaseBindingActivity<ActivityTreas
private ObjectAnimator translationYAnimator;
private int boxType = IBoxModel.BOX_TYPE_HONOUR;
private int height;
private int sendMessageSwitchLevel;
public static void start(Context context) {
@@ -118,6 +119,7 @@ public class TreasureBoxHonourActivity extends BaseBindingActivity<ActivityTreas
.subscribe(keyInfo -> {
changeKeyNum(keyInfo.getKeyNum());
price = keyInfo.getKeyPrice();
sendMessageSwitchLevel = keyInfo.getSendMessageSwitchLevel();
});
}
@@ -131,7 +133,7 @@ public class TreasureBoxHonourActivity extends BaseBindingActivity<ActivityTreas
openBox(StringUtils.toInt(mBinding.editNum.getText().toString()));
break;
case R.id.iv_more:
new BoxMoreDialog(context).openDialog();
new BoxMoreDialog(context,sendMessageSwitchLevel).openDialog();
break;
case R.id.tv_rank:
BoxRankingActivity.start(this);

View File

@@ -10,18 +10,23 @@ import com.yizhuan.erban.R;
import com.yizhuan.erban.databinding.DialogBoxMoreBinding;
import com.yizhuan.erban.ui.webview.CommonWebViewActivity;
import com.yizhuan.erban.ui.webview.DialogWebViewActivity;
import com.yizhuan.erban.utils.UserUtils;
import com.yizhuan.xchat_android_core.DemoCache;
import com.yizhuan.xchat_android_core.UriProvider;
import com.yizhuan.xchat_android_core.user.UserModel;
import com.yizhuan.xchat_android_core.user.bean.UserInfo;
import com.yizhuan.xchat_android_library.annatation.ActLayoutRes;
@ActLayoutRes(R.layout.dialog_box_more)
public class BoxMoreDialog extends BaseBindingDialog<DialogBoxMoreBinding> {
private int sendMessageSwitchLevel;
public BoxMoreDialog(Context context) {
public BoxMoreDialog(Context context, int sendMessageSwitchLevel) {
super(context);
width = WindowManager.LayoutParams.MATCH_PARENT;
height = WindowManager.LayoutParams.WRAP_CONTENT;
this.sendMessageSwitchLevel = sendMessageSwitchLevel;
}
@Override
@@ -50,12 +55,17 @@ public class BoxMoreDialog extends BaseBindingDialog<DialogBoxMoreBinding> {
closeDialog();
});
updateMsgSwitch(DemoCache.readBoolean(DemoCache.KEY_BOX_MESSAGE, true));
binding.ivSwitch.setOnClickListener(v -> {
boolean sendMsg = !DemoCache.readBoolean(DemoCache.KEY_BOX_MESSAGE, true);
updateMsgSwitch(sendMsg);
DemoCache.saveBoolean(DemoCache.KEY_BOX_MESSAGE, sendMsg);
});
if (sendMessageSwitchLevel != 0 && UserUtils.getExpLevel() >= sendMessageSwitchLevel) {
binding.ivSwitch.setVisibility(View.VISIBLE);
updateMsgSwitch(DemoCache.readBoolean(DemoCache.KEY_BOX_MESSAGE, true));
binding.ivSwitch.setOnClickListener(v -> {
boolean sendMsg = !DemoCache.readBoolean(DemoCache.KEY_BOX_MESSAGE, true);
updateMsgSwitch(sendMsg);
DemoCache.saveBoolean(DemoCache.KEY_BOX_MESSAGE, sendMsg);
});
} else {
binding.ivSwitch.setVisibility(View.GONE);
}
}
private void updateMsgSwitch(boolean sendMsg) {

View File

@@ -12,6 +12,7 @@ public class KeyInfo implements Serializable {
private int keyPrice;
private int keyNum;
private int goldNum;//用户余额
private int sendMessageSwitchLevel;
public int getKeyPrice() {
return keyPrice;
@@ -36,4 +37,12 @@ public class KeyInfo implements Serializable {
public void setGoldNum(int goldNum) {
this.goldNum = goldNum;
}
public int getSendMessageSwitchLevel() {
return sendMessageSwitchLevel;
}
public void setSendMessageSwitchLevel(int sendMessageSwitchLevel) {
this.sendMessageSwitchLevel = sendMessageSwitchLevel;
}
}