From b6d715d81c8e8821b8f2b564b128e82e02f2a035 Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Fri, 27 Sep 2024 11:43:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=85=A5Popup2=E8=BF=9B=E8=A1=8CUI?= =?UTF-8?q?=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../res/drawable/bg_gift_progressbar2.xml | 23 ++++++ .../res/layout/dialog_live_gift_popup2.xml | 12 +-- .../live/activity/LiveAudienceActivity.java | 3 +- .../live/adapter/FrameGiftNewAdapter.java | 67 +++++++++++----- .../yunbao/live/dialog/LiveGiftPopup2.java | 76 +++++++++++-------- .../main/res/layout/item_frame_gift_new.xml | 23 +++--- .../src/main/res/layout/item_gift_top_new.xml | 5 +- 7 files changed, 134 insertions(+), 75 deletions(-) create mode 100644 common/src/main/res/drawable/bg_gift_progressbar2.xml diff --git a/common/src/main/res/drawable/bg_gift_progressbar2.xml b/common/src/main/res/drawable/bg_gift_progressbar2.xml new file mode 100644 index 000000000..5b972dc2b --- /dev/null +++ b/common/src/main/res/drawable/bg_gift_progressbar2.xml @@ -0,0 +1,23 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/dialog_live_gift_popup2.xml b/common/src/main/res/layout/dialog_live_gift_popup2.xml index aa156192a..ce33003eb 100644 --- a/common/src/main/res/layout/dialog_live_gift_popup2.xml +++ b/common/src/main/res/layout/dialog_live_gift_popup2.xml @@ -18,7 +18,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="@+id/openVipBg" - tools:background="@drawable/bg_gift_bottom_bg" /> + android:background="@drawable/bg_gift_bottom_bg" /> @@ -42,7 +42,7 @@ android:textColor="@color/black1" android:textSize="14sp" app:layout_constraintBottom_toBottomOf="@+id/giftSendBgV" - app:layout_constraintDimensionRatio="1.82" + app:layout_constraintDimensionRatio="2" app:layout_constraintEnd_toEndOf="@+id/giftSendBgV" app:layout_constraintTop_toTopOf="@+id/giftSendBgV" /> @@ -217,7 +217,7 @@ android:textColor="@color/white" android:textSize="12sp" android:textStyle="bold" - app:layout_constraintBottom_toTopOf="@+id/giftTitleRecyclerView" + app:layout_constraintBottom_toTopOf="@+id/giftWrapTv" app:layout_constraintStart_toStartOf="parent" tools:text="LV.8" /> @@ -259,7 +259,7 @@ android:layout_marginStart="1dp" android:layout_marginTop="2dp" android:layout_marginEnd="10dp" - android:progressDrawable="@drawable/bg_gift_progressbar" + android:progressDrawable="@drawable/bg_gift_progressbar2" app:layout_constraintStart_toStartOf="@+id/lvTipsTv" app:layout_constraintTop_toBottomOf="@+id/lvTipsTv" app:layout_constraintWidth_percent="0.54" @@ -289,7 +289,7 @@ android:id="@+id/openVipTv" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginBottom="16dp" + android:layout_marginBottom="14dp" android:text="@string/open_vip_live" android:textColor="@color/white" android:textSize="11sp" diff --git a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java index b618b8f64..61e146df5 100644 --- a/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java +++ b/live/src/main/java/com/yunbao/live/activity/LiveAudienceActivity.java @@ -124,6 +124,7 @@ import com.yunbao.live.dialog.DragonExpirePopup; import com.yunbao.live.dialog.LiveFansFragment; import com.yunbao.live.dialog.LiveGameDialogFragment; import com.yunbao.live.dialog.LiveGiftPopup; +import com.yunbao.live.dialog.LiveGiftPopup2; import com.yunbao.live.dialog.LiveHDDialogFragment; import com.yunbao.live.dialog.LiveInputDialogFragment; import com.yunbao.live.dialog.LiveMicUserDialogFragment; @@ -1161,7 +1162,7 @@ public class LiveAudienceActivity extends LiveActivity { break; case GIFT_POPUP: - LiveGiftPopup liveGiftPopup = new LiveGiftPopup(); + LiveGiftPopup2 liveGiftPopup = new LiveGiftPopup2(); bundle.putString("mLiveUid", mLiveUid); bundle.putString("mStream", mStream); bundle.putString("WishGiftId", event.getmWishGiftId()); diff --git a/live/src/main/java/com/yunbao/live/adapter/FrameGiftNewAdapter.java b/live/src/main/java/com/yunbao/live/adapter/FrameGiftNewAdapter.java index ccdf7d50b..9ed804aa9 100644 --- a/live/src/main/java/com/yunbao/live/adapter/FrameGiftNewAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/FrameGiftNewAdapter.java @@ -23,6 +23,7 @@ import androidx.recyclerview.widget.RecyclerView; import com.lxj.xpopup.XPopup; import com.makeramen.roundedimageview.RoundedImageView; import com.yunbao.common.bean.LiveGiftBean; +import com.yunbao.common.bean.LiveUserGiftBean; import com.yunbao.common.event.LiveGiftDialogEvent; import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.interfaces.CommonCallback; @@ -38,7 +39,7 @@ import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.R; import com.yunbao.live.dialog.SendRendPacketPopup; import com.yunbao.live.event.LiveGiftItemEvent; -import com.yunbao.live.views.FrameGiftViewHolder; + import java.io.File; import java.util.ArrayList; @@ -50,7 +51,6 @@ public class FrameGiftNewAdapter extends RecyclerView.Adapter { private String mStream, mLiveUid, wishGiftId; public FrameGiftNewAdapter(List giftJson, String mStream, String mLiveUid, String wishGiftId) { - ; this.giftJson = giftJson; this.mStream = mStream; this.mLiveUid = mLiveUid; @@ -58,11 +58,17 @@ public class FrameGiftNewAdapter extends RecyclerView.Adapter { } + public void setLiveUserGiftBeanList(List giftJson) { + this.giftJson = giftJson; + notifyDataSetChanged(); + } + + @NonNull @Override public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_frame_gift_new, parent, false); - return new FrameGiftViewHolder(herdView); + return new GiftViewHolder(herdView); } @@ -101,15 +107,15 @@ public class FrameGiftNewAdapter extends RecyclerView.Adapter { public static class GiftViewHolder extends RecyclerView.ViewHolder { // 声明所有需要初始化的视图组件 - private View isSelectView; + private View isSelectView, loadImgClickView; private ImageView giftIconImg; private TextView giftNameTv; private TextView priceTv; private ImageView payIco; - private ImageView giftNamingBg; + private ImageView giftNamingBg, loadImgImageView; private RoundedImageView avatar; private MarqueeTextView namingName; - private Group namingGroup; + private Group namingGroup, loadImgGroup; private ImageView cornerMark; private ScaleAnimation mAnimation; private View rootView; @@ -129,6 +135,9 @@ public class FrameGiftNewAdapter extends RecyclerView.Adapter { this.namingName = findViewById(R.id.naming_name); this.namingGroup = findViewById(R.id.namingGroup); this.cornerMark = findViewById(R.id.corner_mark); + loadImgImageView = findViewById(R.id.loadImgImageView); + loadImgGroup = findViewById(R.id.loadImgGroup); + loadImgClickView = findViewById(R.id.loadImgClickView); mAnimation = new ScaleAnimation(0.9f, 1.1f, 0.9f, 1.1f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); mAnimation.setInterpolator(new AccelerateDecelerateInterpolator()); @@ -147,12 +156,20 @@ public class FrameGiftNewAdapter extends RecyclerView.Adapter { } public void showData(LiveGiftBean model) { + isSelectView.setVisibility(model.isChecked() ? View.VISIBLE : View.INVISIBLE); if (model.isChecked()) { giftIconImg.startAnimation(mAnimation); + priceTv.setAlpha(1.0f); + } else { + priceTv.setAlpha(0.5f); } ImgLoader.display(getContext(), model.getIcon(), giftIconImg); - ImgLoader.display(getContext(), model.getCornerMark(), cornerMark); + if (TextUtils.isEmpty(model.getCornerMark())) { + cornerMark.setImageDrawable(null); + } else { + ImgLoader.display(getContext(), model.getCornerMark(), cornerMark); + } giftNameTv.setText(model.getName()); if (model.getNaming_user_gift_hall_rank_hide() == 1 && !model.getNamingUid().equals(IMLoginManager.get(getContext()).getUserInfo().getId() + "")) { avatar.setImageResource(com.yunbao.common.R.mipmap.hide); @@ -167,62 +184,70 @@ public class FrameGiftNewAdapter extends RecyclerView.Adapter { priceTv.setText(getContext().getString(R.string.build_up_popularity)); priceTv.setTextColor(Color.parseColor("#db8c4a")); priceTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 8); - } else { priceTv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 11); priceTv.setTextColor(Color.parseColor("#c8c8c8")); payIco.setVisibility(View.VISIBLE); //普通礼物 if (model.getSendType() != null && model.getSendType().equals("1")) { - payIco.setImageResource(R.mipmap.gold_coin); + if (model.isChecked()) { + payIco.setImageResource(R.mipmap.ic_golden_beans_3); + } else { + payIco.setImageResource(R.mipmap.ic_gold_beans_transp); + } } else { - payIco.setImageResource(R.mipmap.diamond); + if (model.isChecked()) { + payIco.setImageResource(R.mipmap.diamond); + } else { + payIco.setImageResource(R.mipmap.ic_diamond_transp); + } + } priceTv.setText(model.getPrice()); } if (model.getSwf() != null && model.getSwf().isEmpty()) { - mLoadingLayout.setVisibility(View.GONE); + loadImgGroup.setVisibility(View.GONE); } else { - mLoadingLayout.setVisibility(GiftCacheUtil.checkGiftIsDownload(model.getId()) ? View.GONE : View.VISIBLE); + loadImgGroup.setVisibility(GiftCacheUtil.checkGiftIsDownload(model.getId()) ? View.GONE : View.VISIBLE); } if (model.isChecked() && !StringUtil.isEmpty(model.getNamingUserName())) { - namingLayout.setVisibility(View.VISIBLE); + namingGroup.setVisibility(View.VISIBLE); } else { - namingLayout.setVisibility(View.GONE); + namingGroup.setVisibility(View.GONE); } } public void giftSelect(LiveGiftBean model, int position, String mStream, String mLiveUid, FrameGiftClickListener frameGiftClickListener) { - ViewClicksAntiShake.clicksAntiShake(mLoadingLayout, new ViewClicksAntiShake.ViewClicksCallBack() { + ViewClicksAntiShake.clicksAntiShake(loadImgClickView, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { - mLoading.setImageResource(R.mipmap.icon_loading_gift); + loadImgImageView.setImageResource(R.mipmap.icon_loading_gift); Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.anim_loading_gift); animation.setRepeatMode(Animation.RESTART); animation.setRepeatCount(Animation.INFINITE); animation.setInterpolator(new LinearInterpolator()); - mLoading.startAnimation(animation); + loadImgImageView.startAnimation(animation); GiftCacheUtil.getInstance().pause(); GiftCacheUtil.getInstance().downloadGiftForId(getContext(), model, new CommonCallback() { @Override public void callback(File bean) { if (bean == null) { ToastUtil.show(getContext().getString(R.string.load_failure_2)); - mLoading.setImageResource(R.mipmap.icon_download_gift); + loadImgImageView.setImageResource(R.mipmap.icon_download_gift); animation.setRepeatCount(0); animation.setDuration(0); animation.cancel(); - mLoading.setAnimation(animation); + loadImgImageView.setAnimation(animation); } else { - mLoadingLayout.setVisibility(View.GONE); + loadImgGroup.setVisibility(View.GONE); } GiftCacheUtil.getInstance().restart(); } }); } }); - ViewClicksAntiShake.clicksAntiShake(giftLayout, new ViewClicksAntiShake.ViewClicksCallBack() { + ViewClicksAntiShake.clicksAntiShake(rootView, new ViewClicksAntiShake.ViewClicksCallBack() { @Override public void onViewClicks() { if (model.getType() == 9999999) { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup2.java b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup2.java index 1ae26a7e1..c98688693 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup2.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveGiftPopup2.java @@ -28,6 +28,7 @@ import android.widget.ProgressBar; import android.widget.TextView; import androidx.core.content.ContextCompat; +import androidx.recyclerview.widget.GridLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; @@ -78,6 +79,7 @@ import com.yunbao.common.views.weight.MarqueeTextView; import com.yunbao.common.views.weight.ViewClicksAntiShake; import com.yunbao.live.activity.LiveActivity; import com.yunbao.live.activity.LiveAudienceActivity; +import com.yunbao.live.adapter.FrameGiftNewAdapter; import com.yunbao.live.adapter.GiftTitleAdapter; import com.yunbao.live.bean.CoinModel; import com.yunbao.live.bean.GiftTopBean; @@ -86,6 +88,7 @@ import com.yunbao.live.event.GiftTitleEvent; import com.yunbao.live.event.LiveAudienceEvent; import com.yunbao.live.event.LiveGiftItemEvent; import com.yunbao.live.event.LiveParcelItemRefreshEvent; +import com.yunbao.live.views.LiveGiftFragment; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; @@ -147,7 +150,7 @@ public class LiveGiftPopup2 extends AbsDialogFragment { //连送逻辑 private int mLianCountDownCount;//连送倒计时的数字 private int blindBoxType; - + private FrameGiftNewAdapter mFrameGiftNewAdapter; // 返回自定义弹窗的布局 @Override protected int getLayoutId() { @@ -228,6 +231,7 @@ public class LiveGiftPopup2 extends AbsDialogFragment { @SuppressLint("ClickableViewAccessibility") private void initView() { + // 初始化所有视图组件 giftBg = findViewById(R.id.giftBg); giftSendBgV = findViewById(R.id.giftSendBgV); @@ -280,6 +284,10 @@ public class LiveGiftPopup2 extends AbsDialogFragment { // gitBackground.setAlpha(0.97f); // ImgLoader.display(getContext(), R.mipmap.ic_gift_right_arrow, liveGiftImg); + //设置礼物的信息 + RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 4, GridLayoutManager.VERTICAL, false); + giftRecyclerView.setLayoutManager(layoutManager); + //礼物分类tab //礼物分类tab LinearLayoutManager manager = new LinearLayoutManager(getContext(), LinearLayoutManager.HORIZONTAL, false); @@ -294,6 +302,18 @@ public class LiveGiftPopup2 extends AbsDialogFragment { giftLevelGroup.setVisibility(View.VISIBLE); + mRootView.setOnClickListener(new View.OnClickListener(){ + @Override + public void onClick(View v) { + dismiss(); + } + }); + giftBg.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + + } + }); } @@ -396,13 +416,13 @@ public class LiveGiftPopup2 extends AbsDialogFragment { } }); - // 跳转充值 - ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.gold_layout), new ViewClicksAntiShake.ViewClicksCallBack() { - @Override - public void onViewClicks() { - forwardMyCoin(2); - } - }); +// // 跳转充值 +// ViewClicksAntiShake.clicksAntiShake(findViewById(R.id.gold_layout), new ViewClicksAntiShake.ViewClicksCallBack() { +// @Override +// public void onViewClicks() { +// forwardMyCoin(2); +// } +// }); // 盲盒说明 ViewClicksAntiShake.clicksAntiShake(description, new ViewClicksAntiShake.ViewClicksCallBack() { @@ -992,6 +1012,9 @@ public class LiveGiftPopup2 extends AbsDialogFragment { ARouter.getInstance().build(PATH_COIN).withInt("p", page).navigation(); } + + + //设置礼物类别数据 private void setTitleData() { List name = new ArrayList<>(); @@ -1018,29 +1041,20 @@ public class LiveGiftPopup2 extends AbsDialogFragment { String giftJson = data.getString("giftlist"); List liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class); for (LiveGiftBean model : liveGiftBeans) { - //TODO 需要根据wishGiftId判断跳转 -// if (TextUtils.equals(model.getId() + "", mWishGiftId)) { -// transaction = getTransaction(); -// contentFragment = LiveGiftFragment.newInstance(giftJson, -// liveGiftList.getJSONObject(i).getString("name"), -// mStream, mLiveUid, mWishGiftId); -// transaction.replace(R.id.context_layout_gift, contentFragment); -// transaction.commitAllowingStateLoss(); -// giftTitleAdapter.setTitleIndex(i); -// break; -// } + if (TextUtils.equals(model.getId() + "", mWishGiftId)) { + mFrameGiftNewAdapter = new FrameGiftNewAdapter(liveGiftBeans, mStream, mLiveUid, mWishGiftId); + giftRecyclerView.setAdapter(mFrameGiftNewAdapter); + giftTitleAdapter.setTitleIndex(i); + break; + } } } } else { JSONObject obj2 = liveGiftList.getJSONObject(0); String giftJson = obj2.getString("giftlist"); - //TODO 需要根据不同实现不同逻辑 -// transaction = getTransaction(); -// contentFragment = LiveGiftFragment.newInstance(giftJson, -// liveGiftList.getJSONObject(0).getString("name"), -// mStream, mLiveUid, mWishGiftId); -// transaction.replace(R.id.context_layout_gift, contentFragment); -// transaction.commitAllowingStateLoss(); + List liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class); + mFrameGiftNewAdapter = new FrameGiftNewAdapter(liveGiftBeans, mStream, mLiveUid, mWishGiftId); + giftRecyclerView.setAdapter(mFrameGiftNewAdapter); } } @@ -1103,11 +1117,11 @@ public class LiveGiftPopup2 extends AbsDialogFragment { giftSendGroup.setVisibility(View.INVISIBLE); JSONObject obj2 = liveGiftList.getJSONObject(event.getmPosition()); String giftJson = obj2.getString("giftlist"); - //TODO 需要替换 -// transaction = getTransaction(); -// contentFragment = LiveGiftFragment.newInstance(giftJson, event.getGiftTitle(), mStream, mLiveUid, mWishGiftId); -// transaction.replace(R.id.context_layout_gift, contentFragment); -// transaction.commitAllowingStateLoss(); + + List liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class); + mFrameGiftNewAdapter = new FrameGiftNewAdapter(liveGiftBeans, mStream, mLiveUid, mWishGiftId); + giftRecyclerView.setAdapter(mFrameGiftNewAdapter); + isWrap = false; if (giftSendGroup.getVisibility() == View.INVISIBLE) { hideLianBtn(); diff --git a/live/src/main/res/layout/item_frame_gift_new.xml b/live/src/main/res/layout/item_frame_gift_new.xml index 999a869a6..926e45a2a 100644 --- a/live/src/main/res/layout/item_frame_gift_new.xml +++ b/live/src/main/res/layout/item_frame_gift_new.xml @@ -4,26 +4,26 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/gift_layout" android:layout_width="match_parent" - android:layout_height="match_parent" + android:layout_height="wrap_content" android:gravity="center" android:orientation="vertical" tools:background="#171724" - tools:layout_height="100dp" tools:layout_width="90dp"> @@ -43,7 +43,7 @@ android:id="@+id/giftNameTv" android:layout_width="wrap_content" android:layout_height="wrap_content" - android:layout_marginTop="2dp" + android:layout_marginTop="1dp" android:textColor="@color/white" android:textSize="11sp" app:layout_constraintEnd_toEndOf="parent" @@ -56,7 +56,6 @@ android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginStart="11dp" - android:layout_marginTop="2dp" android:textColor="@color/white" android:textSize="9sp" app:layout_constraintEnd_toEndOf="@+id/giftIconImg" @@ -82,12 +81,10 @@ android:layout_width="0dp" android:layout_height="0dp" android:src="@mipmap/item_frame_gift_naming_bg" - app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintBottom_toBottomOf="@+id/giftIconImg" app:layout_constraintDimensionRatio="3.83" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" - app:layout_constraintVertical_bias="0.6" app:layout_constraintWidth_percent="0.6" /> @@ -137,7 +135,8 @@ android:layout_width="wrap_content" android:layout_height="11dp" android:layout_gravity="end" - android:layout_marginEnd="2dp" + android:layout_marginTop="3dp" + android:layout_marginEnd="3dp" app:layout_constraintEnd_toEndOf="@+id/isSelectView" app:layout_constraintTop_toTopOf="@+id/isSelectView" /> diff --git a/live/src/main/res/layout/item_gift_top_new.xml b/live/src/main/res/layout/item_gift_top_new.xml index 02b628504..dcc5de702 100644 --- a/live/src/main/res/layout/item_gift_top_new.xml +++ b/live/src/main/res/layout/item_gift_top_new.xml @@ -9,13 +9,10 @@ android:id="@+id/name" android:layout_width="match_parent" android:layout_height="match_parent" - android:layout_marginStart="8dp" - android:layout_marginEnd="8dp" android:gravity="center" android:text="@string/live_wrap" - android:textStyle="bold" android:textColor="@color/white" - android:textSize="16sp" /> + android:textSize="14sp" /> \ No newline at end of file