[Modify]礼物面板改造

This commit is contained in:
wushaocheng
2023-07-17 19:00:54 +08:00
parent 34b9233825
commit 7adefe8375
14 changed files with 812 additions and 491 deletions

View File

@@ -0,0 +1,53 @@
package com.yizhuan.erban.ui.adapter;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.appcompat.widget.AppCompatTextView;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.yizhuan.erban.R;
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
import com.yizhuan.xchat_android_core.gift.bean.SimpleUserInfo;
import com.yizhuan.xchat_android_core.room.anotherroompk.ShowUserInfoDialogEvent;
import com.yizhuan.xchat_android_core.utils.StringExtensionKt;
import com.yizhuan.xchat_android_core.utils.TextUtils;
import com.yizhuan.xchat_android_library.common.application.BaseApp;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.zhpan.bannerview.BaseBannerAdapter;
import com.zhpan.bannerview.BaseViewHolder;
import org.greenrobot.eventbus.EventBus;
public class StarWeekAdapter extends BaseBannerAdapter<SimpleUserInfo> {
@Override
public int getLayoutId(int viewType) {
return R.layout.star_week_banner;
}
@Override
protected void bindData(BaseViewHolder<SimpleUserInfo> helper, SimpleUserInfo item, int position, int pageSize) {
ConstraintLayout bg = helper.findViewById(R.id.ll_container);
AppCompatImageView ivAvatar = helper.findViewById(R.id.iv_avatar);
AppCompatTextView tvNickCharm = helper.findViewById(R.id.tv_name);
if (position == 0) {
bg.setBackgroundResource(R.drawable.bg_star_week_1);
} else {
bg.setBackgroundResource(R.drawable.bg_star_week_2);
}
if (TextUtils.isEmptyText(item.getAvatar())) {
ivAvatar.setImageResource(R.drawable.default_avatar);
ivAvatar.setOnClickListener(v -> {
if (item.getUid() == 0L) return;
EventBus.getDefault().post(new ShowUserInfoDialogEvent(String.valueOf(item.getUid())));
});
} else {
ImageLoadUtils.loadImage(BaseApp.getContext(), item.getAvatar(), ivAvatar);
}
if (TextUtils.isEmptyText(item.getNick())){
tvNickCharm.setText(ResUtil.getString(R.string.ui_widget_giftdialog_013));
} else {
tvNickCharm.setText(item.getNick());
}
}
}

View File

@@ -32,6 +32,8 @@ 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.google.android.material.bottomsheet.BottomSheetDialog;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
import com.trello.rxlifecycle3.components.support.RxAppCompatActivity;
@@ -43,6 +45,7 @@ import com.yizhuan.erban.avroom.firstcharge.FirstChargeDialog;
import com.yizhuan.erban.base.BaseActivity;
import com.yizhuan.erban.common.widget.CircleImageView;
import com.yizhuan.erban.radish.task.activity.TaskCenterActivity;
import com.yizhuan.erban.ui.adapter.StarWeekAdapter;
import com.yizhuan.erban.ui.gift.dialog.GiftInfoVm;
import com.yizhuan.erban.ui.gift.dialog.PageIndicatorView;
import com.yizhuan.erban.ui.pay.ChargeActivity;
@@ -66,6 +69,7 @@ import com.yizhuan.xchat_android_core.gift.GiftModel;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftTab;
import com.yizhuan.xchat_android_core.gift.bean.GiftType;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.gift.bean.SimpleUserInfo;
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapEvent;
import com.yizhuan.xchat_android_core.gift.event.UpdateKnapFreeGiftDataEvent;
@@ -96,6 +100,8 @@ import com.yizhuan.xchat_android_library.utils.ListUtils;
import com.yizhuan.xchat_android_library.utils.ResUtil;
import com.yizhuan.xchat_android_library.utils.SingleToastUtil;
import com.yizhuan.xchat_android_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;
@@ -108,7 +114,9 @@ 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;
@@ -151,6 +159,8 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private EasyPopup easyPopup;
private TextView giftNumberText;
private ImageView giftNumberOptions;
private View flLuckyDesc;
private RecyclerView rvLuckyMsg;
private ImageView ivOpenNoble;
private View ivFirstRecharge;
private TextView tvLuckyBagIntro;
@@ -171,7 +181,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private ImageView ivAvatarLevel;
private TextView tvNickCharm;
private TextView tvNickLevel;
private View llWeekIn;
private View llStarWeek;
private List<MicMemberInfo> micMemberInfos;
private View giftNumLayout;
@@ -193,6 +202,12 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
@Nullable
private DrawGiftHelper drawGiftHelper;
@Nullable
private Disposable luckyMsgDisposable;
private BaseQuickAdapter<LuckyBagNoticeInfo, BaseViewHolder> luckyMsgAdapter;
private BannerViewPager<SimpleUserInfo> mStarWeekBanner;
public GiftDialog(Context context, int giftId) {
this(context, 0, true, false, true, giftId);
}
@@ -377,6 +392,8 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ivDrawGiftRemoveLast = root.findViewById(R.id.iv_draw_gift_remove_last);
ivDrawGiftRemoveAll = root.findViewById(R.id.iv_draw_gift_remove_all);
ivDrawGiftClose = root.findViewById(R.id.iv_draw_gift_close);
flLuckyDesc = findViewById(R.id.fl_lucky_desc);
rvLuckyMsg = findViewById(R.id.rv_lucky_msg);
ivDrawGiftClose.setOnClickListener(this);
ivDrawGiftRemoveLast.setOnClickListener(this);
ivDrawGiftRemoveAll.setOnClickListener(this);
@@ -427,8 +444,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
tvNickCharm = root.findViewById(R.id.tv_nick_charm);
tvNickLevel = root.findViewById(R.id.tv_nick_level);
llStarWeek = root.findViewById(R.id.ll_star_week);
llWeekIn = root.findViewById(R.id.ll_week_in);
llWeekIn.setOnClickListener(this);
giftNumberText = root.findViewById(R.id.gift_number_text);
giftNumberOptions = root.findViewById(R.id.iv_gift_number_options);
@@ -445,8 +460,10 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
sendContainer = root.findViewById(R.id.send_container);
layoutEmpty.setVisibility(View.GONE);
ivFirstRecharge = root.findViewById(R.id.iv_first_recharge);
tvLuckyBagIntro = root.findViewById(R.id.tv_lucky_bag_intro);
tvLuckyBagIntro = findViewById(R.id.tv_lucky_bag_intro);
tvGiftValue = root.findViewById(R.id.tv_gift_value);
mStarWeekBanner = findViewById(R.id.star_week_list);
ivFirstRecharge.setOnClickListener(this);
tvLuckyBagIntro.setOnClickListener(this);
if (giftId == 0) {
@@ -594,7 +611,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
currentGiftInfoList = GiftModel.get().getKnapList();
} else if (position == GiftIndicator.TYPE_NOBLE) {
currentGiftInfoList = nobleGiftInfos;
ivOpenNoble.setVisibility(View.GONE);
ivOpenNoble.setVisibility(View.VISIBLE);
} else if (position == GiftIndicator.TYPE_NORMAL) {
currentGiftInfoList = getNormalGiftInfos();
} else if (position == GiftIndicator.TYPE_LUCKY) {
@@ -670,20 +687,62 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
} else {
tvLuckyBagIntro.setVisibility(View.VISIBLE);
}
if (luckyMsgDisposable != null) luckyMsgDisposable.dispose();
if (currentGiftInfo == null || currentGiftInfo.getGiftType() != GiftType.GIFT_TYPE_LUCKY) {
flLuckyDesc.setVisibility(View.GONE);
} else {
flLuckyDesc.setVisibility(View.VISIBLE);
if (luckyMsgAdapter == null) {
luckyMsgAdapter = new BaseQuickAdapter<>(R.layout.item_lucky_gift_msg) {
@Override
protected void convert(@NonNull BaseViewHolder helper, LuckyBagNoticeInfo noticeInfo) {
TextView tvName = helper.getView(R.id.tv_name);
TextView tvLucky = helper.getView(R.id.tv_luck);
TextView tvLuckyName = helper.getView(R.id.tv_luck_name);
String nickName = RegexUtil.getPrintableString(noticeInfo.getNick());
tvName.setText(nickName);
tvLucky.setText(noticeInfo.getLuckyBagName());
tvLuckyName.setText(noticeInfo.getGiftName());
}
};
rvLuckyMsg.setAdapter(luckyMsgAdapter);
rvLuckyMsg.setLayoutManager(new LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false));
rvLuckyMsg.setOnTouchListener((v, event) -> true);
}
luckyMsgDisposable = GiftModel.get().getLuckyGiftMsgList()
.compose(RxHelper.bindContext(context))
.doOnSuccess(luckyBagNoticeInfos -> luckyMsgAdapter.setNewData(luckyBagNoticeInfos))
.toObservable()
.flatMap(luckyBagNoticeInfos -> Observable.intervalRange(0, Integer.MAX_VALUE, 0, 5, TimeUnit.SECONDS))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(aLong -> {
int index = aLong.intValue() % luckyMsgAdapter.getItemCount();
if (index == 0) {
rvLuckyMsg.scrollToPosition(index);
} else {
rvLuckyMsg.smoothScrollToPosition(index);
}
});
}
}
private void updateWeekStarDesc() {
if (giftIndicator.getCurrrentType() == GiftIndicator.TYPE_WEEK) {
llWeekIn.setVisibility(View.VISIBLE);
llStarWeek.setVisibility(View.VISIBLE);
} else {
llWeekIn.setVisibility(View.GONE);
llStarWeek.setVisibility(View.GONE);
mStarWeekBanner.setVisibility(View.VISIBLE);
} else {
llStarWeek.setVisibility(View.GONE);
mStarWeekBanner.setVisibility(View.GONE);
return;
}
if (currentGiftInfo == null) {
llStarWeek.setVisibility(View.INVISIBLE);
mStarWeekBanner.setVisibility(View.GONE);
return;
}
@@ -714,7 +773,30 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ivAvatarLevel.setImageResource(R.drawable.default_avatar);
tvNickLevel.setText(ResUtil.getString(R.string.ui_widget_giftdialog_014));
}
List<SimpleUserInfo> list = new ArrayList<>();
if (firstCharmRankUser != null) {
list.add(firstCharmRankUser);
} else {
list.add(new SimpleUserInfo());
}
if (firstLevelRankUser != null) {
list.add(firstLevelRankUser);
} else {
list.add(new SimpleUserInfo());
}
mStarWeekBanner.setAdapter(new StarWeekAdapter());
mStarWeekBanner.setPageMargin(UIUtil.dip2px(context, 10))
.setScrollDuration(1200)
.setInterval(4000)
.setRevealWidth(BannerUtils.dp2px(0f))
.setOnPageClickListener((clickedView, position) -> {
DialogWebViewActivity.start(context, UriProvider.getWeekStarUrl(), true);
})
.create(list);
}
private void updateDrawGift() {
if (drawGiftHelper == null) {
@@ -852,7 +934,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
tvLuckyBagIntro.setVisibility(View.GONE);
tvGiftValue.setVisibility(View.GONE);
ivOpenNoble.setVisibility(View.GONE);
llWeekIn.setVisibility(View.GONE);
llStarWeek.setVisibility(View.GONE);
gridView.setVisibility(View.VISIBLE);
@@ -1274,9 +1355,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
case R.id.tv_reload:
reloadData(true);
break;
case R.id.ll_week_in:
DialogWebViewActivity.start(context, UriProvider.getWeekStarUrl(), true);
break;
case R.id.iv_draw_gift_close:
clearDrawGift();
isShowDrawGiftModel = false;
@@ -1485,9 +1563,9 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
for (GiftInfoVm item : page) {
if (item.data.getGiftId() == giftId) {
int count;
if(event.isReset()){
if (event.isReset()) {
count = 0;
}else {
} else {
count = item.data.getCount() + 1;
}
item.data.setCount(Math.max(count, 0));
@@ -1500,7 +1578,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
@Subscribe(threadMode = ThreadMode.MAIN)
public void onReceiveFreeGiftData(UpdateKnapFreeGiftDataEvent event){
public void onReceiveFreeGiftData(UpdateKnapFreeGiftDataEvent event) {
//刷新背包礼物
compositeDisposable.add(GiftModel.get().requestKnapGiftInfos()
.compose(RxHelper.handleSchedulers())

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,64 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/congratulation"
android:textColor="@color/color_white"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:maxEms="5"
android:textColor="@color/color_FFE785"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
tools:text="測試測試測試測試測試" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/open"
android:textColor="@color/color_white"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_luck"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="@color/color_FFE785"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
tools:text="幸運福袋" />
<androidx.appcompat.widget.AppCompatTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="@string/get"
android:textColor="@color/color_white"
android:textSize="@dimen/sp_12" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_luck_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:textColor="@color/color_FFE785"
android:textSize="@dimen/sp_12"
android:textStyle="bold"
tools:text="花神祈願" />
</LinearLayout>

View File

@@ -0,0 +1,48 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout 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:id="@+id/ll_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/bg_star_week_1">
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_star_week"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_10"
android:drawableEnd="@drawable/ic_star_week1"
android:drawablePadding="@dimen/dp_2"
android:text="@string/start_week"
android:textColor="@color/color_FFE694"
android:textSize="@dimen/sp_10"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/dp_15"
android:ellipsize="end"
android:lines="1"
android:maxEms="5"
android:textColor="@color/color_white"
android:textSize="@dimen/sp_12"
app:layout_constraintBottom_toBottomOf="@+id/tv_star_week"
app:layout_constraintEnd_toStartOf="@+id/tv_star_week"
app:layout_constraintTop_toTopOf="@+id/tv_star_week"
tools:text="紅紅火火恍恍惚惚" />
<com.yizhuan.erban.common.widget.CircleImageView
android:id="@+id/iv_avatar"
android:layout_width="@dimen/dp_22"
android:layout_height="@dimen/dp_22"
android:layout_marginEnd="@dimen/dp_4"
app:layout_constraintEnd_toStartOf="@+id/tv_name"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@@ -664,5 +664,8 @@
<color name="color_DF7604">#DF7604</color>
<color name="color_7B3700">#7B3700</color>
<color name="color_8A8CAB">#8A8CAB</color>
<color name="color_FFE694">#FFE694</color>
<color name="color_EB547C">#EB547C</color>
<color name="color_FFE785">#FFE785</color>
</resources>

View File

@@ -5085,5 +5085,9 @@
<string name="google_pay">谷歌支付</string>
<string name="payermax_pay">Payermax</string>
<string name="Winning_results_are_not_displayed">不展示中獎結果</string>
<string name="play_desc">玩法説明</string>
<string name="open">開啓</string>
<string name="get">獲得</string>
<string name="start_week">周星榜</string>
</resources>

View File

@@ -26,6 +26,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftSendType;
import com.yizhuan.xchat_android_core.gift.bean.GiftSource;
import com.yizhuan.xchat_android_core.gift.bean.GiftType;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagGifts;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import com.yizhuan.xchat_android_core.gift.bean.MultiGiftReceiveInfo;
import com.yizhuan.xchat_android_core.gift.bean.SimpleVipInfo;
import com.yizhuan.xchat_android_core.gift.event.RoomFreeGiftEvent;
@@ -703,6 +704,13 @@ public class GiftModel extends BaseModel implements IGiftModel {
}
}
@Override
public Single<List<LuckyBagNoticeInfo>> getLuckyGiftMsgList() {
return api.getLuckyGiftMsgList()
.compose(RxHelper.handleBeanData())
.compose(RxHelper.handleSchAndExce());
}
private interface Api {
/**
@@ -770,6 +778,14 @@ public class GiftModel extends BaseModel implements IGiftModel {
@GET("/roomFreeGift/get")
Single<ServiceResult<GiftFreeInfo>> getFreeGift();
/**
* 福袋最近20条全服记录
*
* @return
*/
@GET("/luckybag/getBannerList")
Single<ServiceResult<List<LuckyBagNoticeInfo>>> getLuckyGiftMsgList();
}
private static class UiHandler extends Handler {

View File

@@ -8,6 +8,7 @@ import com.yizhuan.xchat_android_core.gift.bean.GiftFreeInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftListInfo;
import com.yizhuan.xchat_android_core.gift.bean.GiftMultiReceiverInfo;
import com.yizhuan.xchat_android_core.gift.bean.LuckyBagNoticeInfo;
import java.util.List;
@@ -217,4 +218,11 @@ public interface IGiftModel {
*/
GiftFreeInfo getFreeGiftInfo();
/**
* 福袋最近20条全服记录
*
* @return -
*/
Single<List<LuckyBagNoticeInfo>> getLuckyGiftMsgList( );
}