夺宝精灵:主页&精灵密藏 UI调整
This commit is contained in:
@@ -52,8 +52,14 @@ public class RoomPlayDialog extends BottomSheetDialog {
|
||||
|
||||
private void init() {
|
||||
binding.llRadish.setVisibility(GoldBoxHelper.isShowRadish() ? View.VISIBLE : View.GONE);
|
||||
binding.llRadish.setOnClickListener(v -> PullRadishActivity.start(context));
|
||||
binding.llFairy.setOnClickListener(v -> HomeFairyActivity.start(context));
|
||||
binding.llRadish.setOnClickListener(v -> {
|
||||
PullRadishActivity.start(context);
|
||||
dismiss();
|
||||
});
|
||||
binding.llFairy.setOnClickListener(v -> {
|
||||
HomeFairyActivity.start(context);
|
||||
dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
)
|
||||
}
|
||||
|
||||
private fun initPrizeInfoList() {
|
||||
fun initPrizeInfoList() {
|
||||
safeLaunch(
|
||||
onError = {
|
||||
_prizeInfoListLiveData.value = null
|
||||
@@ -94,6 +94,7 @@ class FairyViewModel : BaseViewModel() {
|
||||
block = {
|
||||
val result = TreasureFairyModel.drawForestFairy(drawNum, poolLevel)
|
||||
_drawForestLiveData.value = result?.let { Event(it) }
|
||||
_forestInfoLiveData.value = TreasureFairyModel.getForestInfo()
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@@ -4,11 +4,14 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import com.mango.core.utils.subAndReplaceDot
|
||||
import com.mango.moshen.R
|
||||
import com.mango.moshen.base.BaseDialog
|
||||
import com.mango.moshen.databinding.TreasureFairyDialogForestBinding
|
||||
import com.mango.moshen.ui.utils.loadAvatar
|
||||
|
||||
class ForestFairyDialog : BaseDialog<TreasureFairyDialogForestBinding>() {
|
||||
|
||||
@@ -33,10 +36,15 @@ class ForestFairyDialog : BaseDialog<TreasureFairyDialogForestBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
|
||||
binding.ivBack.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.ivRecord.setOnClickListener {
|
||||
ForestRecordDialog.newInstance().show(context)
|
||||
}
|
||||
binding.ivMyFairy.setOnClickListener {
|
||||
MyFairyDialog.newInstance().show(context)
|
||||
}
|
||||
|
||||
binding.ivPrevious.setOnClickListener {
|
||||
currentType--
|
||||
@@ -47,41 +55,61 @@ class ForestFairyDialog : BaseDialog<TreasureFairyDialogForestBinding>() {
|
||||
switchType()
|
||||
}
|
||||
binding.viewBgGrab1.setOnClickListener {
|
||||
enabledOpenBtn(false)
|
||||
viewModel.drawForestFairy(1, currentType)
|
||||
}
|
||||
|
||||
binding.viewBgGrab10.setOnClickListener {
|
||||
enabledOpenBtn(false)
|
||||
viewModel.drawForestFairy(10, currentType)
|
||||
}
|
||||
|
||||
viewModel.drawForestLiveData.observe(viewLifecycleOwner) {
|
||||
enabledOpenBtn(true)
|
||||
it?.getContentIfNotHandled()?.let {
|
||||
ForestPrizeDialog.newInstance().show(context)
|
||||
}
|
||||
}
|
||||
|
||||
viewModel.getForestInfo()
|
||||
|
||||
viewModel.forestInfoLiveData.observe(viewLifecycleOwner) {
|
||||
it?.let {
|
||||
binding.ivAvatar.loadAvatar(it.avatar)
|
||||
binding.tvNickname.text = it.nick.subAndReplaceDot(7)
|
||||
binding.tvKeyNumBase.text = it.lowBallNum
|
||||
binding.tvKeyNumEpic.text = it.middleBallNum
|
||||
binding.tvKeyNumLegend.text = it.highBallNum
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun enabledOpenBtn(enable: Boolean) {
|
||||
binding.viewBgGrab1.isEnabled = enable
|
||||
binding.viewBgGrab10.isEnabled = enable
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private fun switchType() {
|
||||
when (currentType) {
|
||||
BASE -> {
|
||||
binding.ivPrevious.isVisible = false
|
||||
binding.ivPrevious.isInvisible = true
|
||||
binding.tvGrabText1.text = "(初级球X1)"
|
||||
binding.tvGrabText10.text = "(初级球X10)"
|
||||
binding.tvTips.text = "使用初级球有一定几率抓到初级精灵"
|
||||
binding.viewBgForestBase.setBackgroundResource(R.drawable.treasure_fairy_bg_forest_base)
|
||||
}
|
||||
EPIC -> {
|
||||
binding.ivNext.isVisible = true
|
||||
binding.ivNext.isVisible = true
|
||||
binding.ivNext.isInvisible = false
|
||||
binding.ivPrevious.isInvisible = false
|
||||
binding.tvGrabText1.text = "(超级球X1)"
|
||||
binding.tvGrabText10.text = "(超级球X10)"
|
||||
binding.tvTips.text = "使用超级球有一定几率抓到史诗精灵"
|
||||
binding.viewBgForestBase.setBackgroundResource(R.drawable.treasure_fairy_bg_forest_epic)
|
||||
}
|
||||
LEGEND -> {
|
||||
binding.ivNext.isVisible = false
|
||||
binding.ivNext.isInvisible = true
|
||||
binding.tvGrabText1.text = "(大师球X1)"
|
||||
binding.tvGrabText10.text = "(大师球X10)"
|
||||
binding.tvTips.text = "使用大师球必定抓到传说精灵"
|
||||
|
@@ -0,0 +1,96 @@
|
||||
package com.mango.moshen.treasurefairy;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import com.mango.moshen.R;
|
||||
import com.mango.moshen.ui.widget.XRecyclerView.ScaleTransitionPagerTitleView;
|
||||
import com.mango.moshen.ui.widget.magicindicator.buildins.UIUtil;
|
||||
import com.mango.moshen.ui.widget.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
|
||||
import com.mango.moshen.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
|
||||
import com.mango.moshen.ui.widget.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
|
||||
import com.mango.moshen.ui.widget.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ForestIndicatorAdapter extends CommonNavigatorAdapter {
|
||||
private final Context mContext;
|
||||
private final List<? extends CharSequence> mTitleList;
|
||||
|
||||
private int textSize = 15;
|
||||
private float minScale = 1f;
|
||||
private OnItemSelectListener mOnItemSelectListener;
|
||||
|
||||
public ForestIndicatorAdapter(Context context, List<? extends CharSequence> charSequences) {
|
||||
this.mContext = context;
|
||||
this.mTitleList = charSequences;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return mTitleList == null ? 0 : mTitleList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerTitleView getTitleView(Context context, final int i) {
|
||||
ScaleTransitionPagerTitleView scaleTransitionPagerTitleView = new ScaleTransitionPagerTitleView(context, true);
|
||||
scaleTransitionPagerTitleView.setNormalColor(ContextCompat.getColor(context, R.color.white));
|
||||
scaleTransitionPagerTitleView.setSelectedColor(ContextCompat.getColor(context, R.color.white));
|
||||
scaleTransitionPagerTitleView.setMinScale(minScale);
|
||||
scaleTransitionPagerTitleView.setTextSize(textSize);
|
||||
int padding = UIUtil.dip2px(context, 12);
|
||||
scaleTransitionPagerTitleView.setPadding(padding, 0, padding, 0);
|
||||
scaleTransitionPagerTitleView.setText(mTitleList.get(i));
|
||||
scaleTransitionPagerTitleView.setOnClickListener(view -> {
|
||||
if (mOnItemSelectListener != null) {
|
||||
mOnItemSelectListener.onItemSelect(i, scaleTransitionPagerTitleView);
|
||||
}
|
||||
|
||||
});
|
||||
return scaleTransitionPagerTitleView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPagerIndicator getIndicator(Context context) {
|
||||
LinePagerIndicator indicator = new LinePagerIndicator(context);
|
||||
indicator.setMode(LinePagerIndicator.MODE_EXACTLY);
|
||||
indicator.setLineHeight(UIUtil.dip2px(mContext, 4));
|
||||
indicator.setRoundRadius(UIUtil.dip2px(mContext, 2));
|
||||
indicator.setLineWidth(UIUtil.dip2px(mContext, 60));
|
||||
indicator.setColors(Color.parseColor("#69FFEB"),Color.parseColor("#EAFF89"));
|
||||
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = Gravity.BOTTOM;
|
||||
indicator.setLayoutParams(lp);
|
||||
return indicator;
|
||||
}
|
||||
|
||||
public int getTextSize() {
|
||||
return textSize;
|
||||
}
|
||||
|
||||
public void setTextSize(int textSize) {
|
||||
this.textSize = textSize;
|
||||
}
|
||||
|
||||
public float getMinScale() {
|
||||
return minScale;
|
||||
}
|
||||
|
||||
public void setMinScale(float minScale) {
|
||||
this.minScale = minScale;
|
||||
}
|
||||
|
||||
public void setOnItemSelectListener(OnItemSelectListener onItemSelectListener) {
|
||||
mOnItemSelectListener = onItemSelectListener;
|
||||
}
|
||||
|
||||
public interface OnItemSelectListener {
|
||||
void onItemSelect(int position, TextView view);
|
||||
}
|
||||
}
|
@@ -7,8 +7,14 @@ import com.mango.moshen.R
|
||||
import com.mango.moshen.ui.utils.load
|
||||
import com.mango.core.treasurefairy.PrizeInfo
|
||||
|
||||
class ForestPrizeAdapter :
|
||||
BaseQuickAdapter<PrizeInfo, BaseViewHolder>(R.layout.treasure_fairy_item_forest_prize) {
|
||||
class ForestPrizeAdapter(val isSingle: Boolean = false) :
|
||||
BaseQuickAdapter<PrizeInfo, BaseViewHolder>(
|
||||
if (isSingle) {
|
||||
R.layout.treasure_fairy_item_forest_prize_single
|
||||
} else {
|
||||
R.layout.treasure_fairy_item_forest_prize
|
||||
}
|
||||
) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: PrizeInfo) {
|
||||
helper.getView<ImageView>(R.id.iv_prize_icon).load(item.rewardPicUrl)
|
||||
|
@@ -4,10 +4,12 @@ import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.Gravity
|
||||
import android.view.WindowManager
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mango.core.treasurefairy.PrizeInfo
|
||||
import com.mango.moshen.R
|
||||
import com.mango.moshen.base.BaseDialog
|
||||
import com.mango.moshen.databinding.TreasureFairyDialogForestPrizeBinding
|
||||
import com.mango.moshen.ui.utils.RVDelegate
|
||||
@@ -23,8 +25,9 @@ class ForestPrizeDialog : BaseDialog<TreasureFairyDialogForestPrizeBinding>() {
|
||||
private val viewModel: FairyViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
fun newInstance(): ForestPrizeDialog {
|
||||
fun newInstance(isFairy: Boolean = false): ForestPrizeDialog {
|
||||
val args = Bundle()
|
||||
args.putBoolean("isFairy", isFairy)
|
||||
val fragment = ForestPrizeDialog()
|
||||
fragment.arguments = args
|
||||
return fragment
|
||||
@@ -36,16 +39,41 @@ class ForestPrizeDialog : BaseDialog<TreasureFairyDialogForestPrizeBinding>() {
|
||||
binding.tvClose.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
prizeAdapter = ForestPrizeAdapter()
|
||||
val prizeInfoList = viewModel.drawForestLiveData.value?.peekContent()
|
||||
if (prizeInfoList.isNullOrEmpty()) return
|
||||
val isSingle = prizeInfoList.size == 1
|
||||
val hasSurprise = prizeInfoList.find { it.propType == 1 } != null
|
||||
val isFairy =
|
||||
requireArguments().getBoolean("isFairy", true) || !hasSurprise
|
||||
binding.tvTitle.text = if (isFairy) "获得精灵" else "意外发现"
|
||||
if (!isFairy && !isSingle && hasSurprise) {
|
||||
newInstance(true).show(context)
|
||||
}
|
||||
val showPrizeInfoList =
|
||||
prizeInfoList.filter { if (isFairy) (it.propType != 1) else (it.propType == 1) }
|
||||
val isShowDateSingle = showPrizeInfoList.size == 1
|
||||
if (!isShowDateSingle) {
|
||||
binding.viewBg.setBackgroundResource(R.drawable.treasure_fairy_bg_forest_prize)
|
||||
val layoutParams = binding.viewBg.layoutParams as ConstraintLayout.LayoutParams
|
||||
layoutParams.dimensionRatio = "636:766"
|
||||
layoutParams.matchConstraintPercentWidth = 0.85f
|
||||
binding.viewBg.layoutParams = layoutParams
|
||||
}
|
||||
prizeAdapter = ForestPrizeAdapter(isShowDateSingle)
|
||||
rvDelegate = RVDelegate.Builder<PrizeInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(GridLayoutManager(context, 3, LinearLayoutManager.VERTICAL, false))
|
||||
.setLayoutManager(
|
||||
if (isShowDateSingle) {
|
||||
LinearLayoutManager(context)
|
||||
} else {
|
||||
GridLayoutManager(context, 3, LinearLayoutManager.VERTICAL, false)
|
||||
}
|
||||
)
|
||||
.build()
|
||||
|
||||
viewModel.drawForestLiveData.observe(viewLifecycleOwner) { event ->
|
||||
rvDelegate.setNewData(event.peekContent())
|
||||
}
|
||||
rvDelegate.setNewData(showPrizeInfoList)
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -42,7 +42,7 @@ class ForestPrizesFragment : BaseViewBindingFragment<TreasureFairyFragmentForest
|
||||
tagList.add("传说森林")
|
||||
val commonNavigator = CommonNavigator(context)
|
||||
commonNavigator.setTitleWrapContent(true)
|
||||
val magicIndicatorAdapter = UserInfoIndicatorAdapter(context, tagList)
|
||||
val magicIndicatorAdapter = ForestIndicatorAdapter(context, tagList)
|
||||
magicIndicatorAdapter.setOnItemSelectListener { position: Int, _: TextView ->
|
||||
viewPager.currentItem = position
|
||||
}
|
||||
|
@@ -4,12 +4,15 @@ import android.animation.ObjectAnimator
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.graphics.Color
|
||||
import android.graphics.Path
|
||||
import android.text.style.ForegroundColorSpan
|
||||
import android.view.*
|
||||
import android.widget.LinearLayout
|
||||
import android.widget.TextView
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.graphics.toColorInt
|
||||
import com.mango.core.UriProvider
|
||||
import com.mango.core.treasurefairy.PrizeInfo
|
||||
import com.mango.moshen.R
|
||||
@@ -17,7 +20,7 @@ import com.mango.moshen.base.BaseViewBindingActivity
|
||||
import com.mango.moshen.common.widget.dialog.DialogManager
|
||||
import com.mango.moshen.databinding.TreasureFairyDialogHomeBinding
|
||||
import com.mango.moshen.ui.webview.FairyDialogWebViewActivity
|
||||
import com.netease.nim.uikit.common.ui.dialog.CustomPopupWindow
|
||||
import com.mango.moshen.utils.SpannableBuilder
|
||||
import com.netease.nim.uikit.common.util.sys.ScreenUtil
|
||||
import io.reactivex.Observable
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
@@ -87,16 +90,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
}
|
||||
|
||||
binding.ivMore.setOnClickListener {
|
||||
val popupWindow = CustomPopupWindow(context, LinearLayout.VERTICAL)
|
||||
popupWindow.addItem("规则说明") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyRule())
|
||||
}
|
||||
popupWindow.addItem("获奖记录") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyRecord())
|
||||
}
|
||||
popupWindow.addItem("夺宝达人") {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairySuperior())
|
||||
}
|
||||
val popupWindow = HomeMorePopupWindow(context)
|
||||
popupWindow.show(binding.ivMore, Gravity.BOTTOM or Gravity.CENTER_HORIZONTAL)
|
||||
}
|
||||
|
||||
@@ -113,7 +107,10 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
|
||||
viewModel.resultLiveData.observe(this) { event ->
|
||||
event?.getContentIfNotHandled()?.let {
|
||||
targetIndex = viewModel.prizeInfoListLiveData.value?.indexOf(it[0]) ?: -1
|
||||
targetIndex = viewModel.prizeInfoListLiveData.value?.indexOf(it[0]) ?: -2
|
||||
if (targetIndex == -2) {
|
||||
viewModel.initPrizeInfoList()
|
||||
}
|
||||
hintPrizeCacheList.addAll(it.filter { prizeInfo -> prizeInfo.rewardLevel >= 3 })
|
||||
} ?: run {
|
||||
targetIndex = -1
|
||||
@@ -131,7 +128,13 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
it?.let {
|
||||
binding.tvKeyNum.text = it.drawTicketNum.toString()
|
||||
binding.tvCurrentLuckyValue.text = it.luckyNum.toString()
|
||||
binding.tvShortLuckyValue.text = "达到${it.needLuckyNum}后下次夺宝,额外获赠精灵球"
|
||||
|
||||
binding.tvShortLuckyValue.text =
|
||||
SpannableBuilder()
|
||||
.append("达到 ", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.append("${it.needLuckyNum}", ForegroundColorSpan("#FFE8AA".toColorInt()))
|
||||
.append(" 后下次夺宝,额外获赠精灵球", ForegroundColorSpan("#59FDFF".toColorInt()))
|
||||
.build()
|
||||
binding.ivLuckyStone.post {
|
||||
val drawable = CustomDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
@@ -169,6 +172,7 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
}
|
||||
|
||||
private fun rotatePrize() {
|
||||
enabledOpenBtn(false)
|
||||
targetIndex = -1
|
||||
var minCount = 0
|
||||
disposable?.dispose()
|
||||
@@ -180,15 +184,24 @@ class HomeFairyActivity : BaseViewBindingActivity<TreasureFairyDialogHomeBinding
|
||||
selectIndex++
|
||||
minCount++
|
||||
if (selectIndex == fairyItems.size) selectIndex = 0
|
||||
fairyItems[selectIndex].isSelected = true
|
||||
if (selectIndex == targetIndex && minCount >= 24) {
|
||||
if (targetIndex != -2) {
|
||||
fairyItems[selectIndex].isSelected = true
|
||||
}
|
||||
if ((selectIndex == targetIndex || targetIndex == -2) && minCount >= 24) {
|
||||
HomePrizeDialog.newInstance().show(context)
|
||||
disposable?.dispose()
|
||||
}
|
||||
}
|
||||
.doFinally { enabledOpenBtn(true) }
|
||||
.subscribe()
|
||||
}
|
||||
|
||||
private fun enabledOpenBtn(enable: Boolean) {
|
||||
binding.ivOpen1.isEnabled = enable
|
||||
binding.ivOpen10.isEnabled = enable
|
||||
binding.ivOpen100.isEnabled = enable
|
||||
}
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
private fun looperHintPrize() {
|
||||
Observable.interval(0, 250, TimeUnit.MILLISECONDS)
|
||||
|
@@ -0,0 +1,37 @@
|
||||
package com.mango.moshen.treasurefairy
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Color
|
||||
import android.view.View
|
||||
import com.mango.core.UriProvider
|
||||
import com.mango.moshen.R
|
||||
import com.mango.moshen.ui.webview.FairyDialogWebViewActivity
|
||||
import razerdp.basepopup.BasePopupWindow
|
||||
|
||||
class HomeMorePopupWindow(private val context: Context) : BasePopupWindow(context) {
|
||||
|
||||
init {
|
||||
contentView = createPopupById(R.layout.treasure_fairy_popup_window_home_more)
|
||||
setOutSideDismiss(true)
|
||||
setBackgroundColor(Color.TRANSPARENT)
|
||||
setPopupAnimationStyle(-1)
|
||||
findViewById<View>(R.id.tv_rule).setOnClickListener {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyRule())
|
||||
dismiss()
|
||||
}
|
||||
findViewById<View>(R.id.tv_record).setOnClickListener {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairyRecord())
|
||||
dismiss()
|
||||
}
|
||||
findViewById<View>(R.id.tv_rank).setOnClickListener {
|
||||
FairyDialogWebViewActivity.start(context, UriProvider.getFairySuperior())
|
||||
dismiss()
|
||||
}
|
||||
}
|
||||
|
||||
fun show(anchor: View?, popupGravity: Int) {
|
||||
setPopupGravity(popupGravity)
|
||||
showPopupWindow(anchor)
|
||||
}
|
||||
|
||||
}
|
@@ -8,8 +8,14 @@ import com.mango.moshen.ui.utils.load
|
||||
import com.mango.core.room.game.GameInfo
|
||||
import com.mango.core.treasurefairy.PrizeInfo
|
||||
|
||||
class HomePrizeAdapter :
|
||||
BaseQuickAdapter<PrizeInfo, BaseViewHolder>(R.layout.treasure_fairy_item_home_prize) {
|
||||
class HomePrizeAdapter(val isSingle: Boolean = false) :
|
||||
BaseQuickAdapter<PrizeInfo, BaseViewHolder>(
|
||||
if (isSingle) {
|
||||
R.layout.treasure_fairy_item_home_prize_single
|
||||
} else {
|
||||
R.layout.treasure_fairy_item_home_prize
|
||||
}
|
||||
) {
|
||||
|
||||
override fun convert(helper: BaseViewHolder, item: PrizeInfo) {
|
||||
helper.getView<ImageView>(R.id.iv_prize_icon).load(item.rewardPicUrl)
|
||||
|
@@ -9,6 +9,7 @@ import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import com.mango.core.room.game.GameInfo
|
||||
import com.mango.core.treasurefairy.PrizeInfo
|
||||
import com.mango.moshen.R
|
||||
import com.mango.moshen.base.BaseDialog
|
||||
import com.mango.moshen.databinding.TreasureFairyDialogHomePrizeBinding
|
||||
import com.mango.moshen.ui.utils.RVDelegate
|
||||
@@ -36,16 +37,22 @@ class HomePrizeDialog : BaseDialog<TreasureFairyDialogHomePrizeBinding>() {
|
||||
binding.rootView.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
prizeAdapter = HomePrizeAdapter()
|
||||
val prizeInfoList = viewModel.resultLiveData.value?.peekContent()
|
||||
if (prizeInfoList.isNullOrEmpty()) return
|
||||
val isSingle = prizeInfoList.size == 1
|
||||
prizeAdapter = HomePrizeAdapter(isSingle)
|
||||
rvDelegate = RVDelegate.Builder<PrizeInfo>()
|
||||
.setAdapter(prizeAdapter)
|
||||
.setRecyclerView(binding.recyclerView)
|
||||
.setLayoutManager(GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false))
|
||||
.setLayoutManager(
|
||||
if (isSingle) {
|
||||
LinearLayoutManager(context)
|
||||
} else {
|
||||
GridLayoutManager(context, 4, LinearLayoutManager.VERTICAL, false)
|
||||
}
|
||||
)
|
||||
.build()
|
||||
|
||||
viewModel.resultLiveData.observe(viewLifecycleOwner) { event ->
|
||||
rvDelegate.setNewData(event.peekContent())
|
||||
}
|
||||
rvDelegate.setNewData(prizeInfoList)
|
||||
}
|
||||
|
||||
}
|
@@ -29,6 +29,9 @@ class MyFairyDialog : BaseDialog<TreasureFairyDialogMyFairyBinding>() {
|
||||
|
||||
@SuppressLint("CheckResult")
|
||||
override fun init() {
|
||||
binding.ivBack.setOnClickListener {
|
||||
dismissAllowingStateLoss()
|
||||
}
|
||||
binding.rg.setOnCheckedChangeListener { _, checkedId ->
|
||||
when (checkedId) {
|
||||
R.id.rb_base -> binding.viewPager.currentItem = 0
|
||||
|
@@ -2,8 +2,10 @@ package com.mango.moshen.ui.widget.magicindicator.buildins.commonnavigator.indic
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.LinearGradient;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Shader;
|
||||
import android.view.View;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.LinearInterpolator;
|
||||
@@ -27,7 +29,9 @@ public class LinePagerIndicator extends View implements IPagerIndicator {
|
||||
public static final int MODE_MATCH_EDGE = 0; // 直线宽度 == title宽度 - 2 * mXOffset
|
||||
public static final int MODE_WRAP_CONTENT = 1; // 直线宽度 == title内容宽度 - 2 * mXOffset
|
||||
public static final int MODE_EXACTLY = 2; // 直线宽度 == mLineWidth
|
||||
|
||||
private final int[] mGradientColors = {0xFF5BC8F8, 0xFF66D9D9};
|
||||
//渐变位置
|
||||
private final float[] mGradientPosition = new float[]{0, 1};
|
||||
private int mMode; // 默认为MODE_MATCH_EDGE模式
|
||||
|
||||
// 控制动画
|
||||
@@ -69,14 +73,6 @@ public class LinePagerIndicator extends View implements IPagerIndicator {
|
||||
return;
|
||||
}
|
||||
|
||||
// 计算颜色
|
||||
if (mColors != null && mColors.size() > 0) {
|
||||
int currentColor = mColors.get(Math.abs(position) % mColors.size());
|
||||
int nextColor = mColors.get(Math.abs(position + 1) % mColors.size());
|
||||
int color = ArgbEvaluatorHolder.eval(positionOffset, currentColor, nextColor);
|
||||
mPaint.setColor(color);
|
||||
}
|
||||
|
||||
// 计算锚点位置
|
||||
PositionData current = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position);
|
||||
PositionData next = FragmentContainerHelper.getImitativePositionData(mPositionDataList, position + 1);
|
||||
@@ -106,13 +102,23 @@ public class LinePagerIndicator extends View implements IPagerIndicator {
|
||||
mLineRect.right = rightX + (nextRightX - rightX) * mEndInterpolator.getInterpolation(positionOffset);
|
||||
mLineRect.top = getHeight() - mLineHeight - mYOffset;
|
||||
mLineRect.bottom = getHeight() - mYOffset;
|
||||
// 计算颜色
|
||||
if (mColors != null && mColors.size() > 0) {
|
||||
if (mColors.size() == 1) {
|
||||
mPaint.setColor(mColors.get(0));
|
||||
} else {
|
||||
mGradientColors[0] = mColors.get(0);
|
||||
mGradientColors[1] = mColors.get(1);
|
||||
mPaint.setShader(new LinearGradient(mLineRect.left, mLineRect.top, mLineRect.right, mLineRect.bottom, mGradientColors, mGradientPosition, Shader.TileMode.CLAMP));
|
||||
}
|
||||
}
|
||||
|
||||
invalidate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPageSelected(int position) {
|
||||
onPageScrolled(position,0,0);
|
||||
onPageScrolled(position, 0, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 203 KiB After Width: | Height: | Size: 280 KiB |
Binary file not shown.
After Width: | Height: | Size: 203 KiB |
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
BIN
app/src/main/res/drawable-xhdpi/treasure_fairy_ic_back.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/treasure_fairy_ic_back.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
@@ -27,6 +27,16 @@
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg"
|
||||
app:layout_constraintWidth_percent="0.408" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:src="@drawable/treasure_fairy_ic_back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_my_fairy"
|
||||
android:layout_width="50dp"
|
||||
@@ -97,6 +107,7 @@
|
||||
android:layout_height="42dp"
|
||||
android:layout_marginStart="10dp"
|
||||
android:src="@drawable/treasure_fairy_ic_forest_next"
|
||||
android:visibility="invisible"
|
||||
app:layout_constraintBottom_toBottomOf="@id/view_bg_forest_base"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg_forest_base"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg_forest_base"
|
||||
@@ -240,10 +251,11 @@
|
||||
android:src="@drawable/default_cover" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_key_num_base"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="3dp"
|
||||
android:text="1000"
|
||||
android:text="0"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
@@ -254,10 +266,11 @@
|
||||
android:src="@drawable/default_cover" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_key_num_epic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="3dp"
|
||||
android:text="1000"
|
||||
android:text="0"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
@@ -268,10 +281,11 @@
|
||||
android:src="@drawable/default_cover" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_key_num_legend"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="3dp"
|
||||
android:text="1000"
|
||||
android:text="0"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
|
@@ -10,7 +10,7 @@
|
||||
android:id="@+id/view_bg"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/treasure_fairy_bg_forest_prize"
|
||||
android:background="@drawable/treasure_fairy_bg_forest_prize_single"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="562:570"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
@@ -40,7 +40,7 @@
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginEnd="20dp"
|
||||
android:layout_marginBottom="18dp"
|
||||
app:layout_constraintBottom_toTopOf="@id/iv_close"
|
||||
app:layout_constraintBottom_toTopOf="@id/tv_close"
|
||||
app:layout_constraintEnd_toEndOf="@id/view_bg"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg"
|
||||
app:layout_constraintTop_toBottomOf="@id/tv_title" />
|
||||
|
@@ -12,7 +12,7 @@
|
||||
android:layout_height="0dp"
|
||||
android:background="@drawable/treasure_fairy_bg_forest_record"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintDimensionRatio="562:570"
|
||||
app:layout_constraintDimensionRatio="631:772"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
@@ -58,6 +58,10 @@
|
||||
android:id="@+id/view_pager"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginTop="24dp"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginEnd="15dp"
|
||||
android:layout_marginBottom="30dp"
|
||||
app:layout_constraintBottom_toBottomOf="@id/view_bg"
|
||||
app:layout_constraintEnd_toEndOf="@id/view_bg"
|
||||
app:layout_constraintStart_toStartOf="@id/view_bg"
|
||||
|
@@ -16,6 +16,16 @@
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_back"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="15dp"
|
||||
android:layout_marginTop="42dp"
|
||||
android:src="@drawable/treasure_fairy_ic_back"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/view_bg" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_title"
|
||||
android:layout_width="0dp"
|
||||
|
@@ -9,7 +9,7 @@
|
||||
<com.mango.moshen.ui.widget.magicindicator.MagicIndicator
|
||||
android:id="@+id/magic_indicator"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="20dp"
|
||||
android:layout_height="25dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
/>
|
||||
|
||||
|
@@ -40,8 +40,8 @@
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="20dp" />
|
||||
|
||||
</LinearLayout>
|
||||
|
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<com.mango.moshen.common.widget.CircleImageView
|
||||
android:id="@+id/iv_prize_icon"
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="90dp"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/default_cover"
|
||||
app:cborder_color="#F4FFC3"
|
||||
app:cborder_width="1px" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_prize_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="精灵球"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="12sp" />
|
||||
|
||||
</LinearLayout>
|
@@ -0,0 +1,53 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout 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="match_parent"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="90dp"
|
||||
android:layout_height="90dp"
|
||||
android:background="@drawable/treasure_fairy_bg_item_home_prize">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/iv_prize_icon"
|
||||
android:layout_width="72dp"
|
||||
android:layout_height="72dp"
|
||||
android:layout_gravity="center"
|
||||
android:scaleType="centerCrop"
|
||||
android:src="@drawable/default_cover" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_prize_num"
|
||||
android:layout_width="30dp"
|
||||
android:layout_height="30dp"
|
||||
android:layout_gravity="end|bottom"
|
||||
android:background="@drawable/treasure_fairy_bg_home_prize_number"
|
||||
android:gravity="center"
|
||||
android:paddingTop="3dp"
|
||||
android:text="X10"
|
||||
android:textColor="#ff1f5764"
|
||||
android:textSize="10sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_prize_name"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="5dp"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:maxLines="1"
|
||||
android:text="精灵球"
|
||||
android:textColor="#FFE8AA"
|
||||
android:textSize="13sp" />
|
||||
|
||||
</LinearLayout>
|
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="111dp"
|
||||
android:layout_height="131dp"
|
||||
android:background="@drawable/treasure_fairy_bg_home_popup_window"
|
||||
android:gravity="center_horizontal"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_rule"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:layout_marginTop="22dp"
|
||||
android:gravity="center"
|
||||
android:text="规则说明"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_record"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:gravity="center"
|
||||
android:text="奖励记录"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_rank"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="30dp"
|
||||
android:gravity="center"
|
||||
android:text="夺宝达人"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="13sp" />
|
||||
|
||||
|
||||
</LinearLayout>
|
@@ -3,9 +3,9 @@ package com.mango.core.treasurefairy
|
||||
data class ForestInfo(
|
||||
val avatar: String = "",
|
||||
val erbanNo: Int = 0,
|
||||
val highBallNum: Int = 0,
|
||||
val lowBallNum: Int = 0,
|
||||
val middleBallNum: Int = 0,
|
||||
val highBallNum: String = "0",
|
||||
val lowBallNum: String = "0",
|
||||
val middleBallNum: String = "0",
|
||||
val nick: String = "",
|
||||
val uid: Int = 0
|
||||
)
|
@@ -10,7 +10,8 @@ data class PrizeInfo(
|
||||
val rewardType: String = "",
|
||||
val rewardUnit: String = "",
|
||||
val drawTime: Long = 0,
|
||||
val poolLevel: Int = 0
|
||||
val poolLevel: Int = 0,
|
||||
val propType: Int? = null
|
||||
) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (this === other) return true
|
||||
|
Reference in New Issue
Block a user