接入Popup2进行UI调整

This commit is contained in:
ningwenqiang 2024-09-27 11:43:55 +08:00
parent 729db13ffd
commit b6d715d81c
7 changed files with 134 additions and 75 deletions

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--设置ProgressBar背景色-->
<item android:id="@android:id/background">
<shape>
<!--设置ProgressBar进度条圆角半径-->
<corners android:radius="1dp" />
<solid android:color="#15FFFFFF" />
</shape>
</item>
<!--设置ProgressBar进度条颜色-->
<item android:id="@android:id/progress">
<scale android:scaleWidth="100%">
<shape>
<corners android:radius="1dp" />
<gradient
android:endColor="#DED9A5"
android:startColor="#DED9A5" />
</shape>
</scale>
</item>
</layer-list>

View File

@ -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" />
<!--底部送礼选择数量备份 -->
<View
android:id="@+id/giftSendBgV"
@ -28,7 +28,7 @@
android:layout_marginBottom="16dp"
android:background="@drawable/bg_gift_send"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="3.74"
app:layout_constraintDimensionRatio="4"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintWidth_percent="0.34" />
@ -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"

View File

@ -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());

View File

@ -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<LiveGiftBean> 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<LiveGiftBean> 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);
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 {
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<File>() {
@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) {

View File

@ -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<GiftTopBean> name = new ArrayList<>();
@ -1018,29 +1041,20 @@ public class LiveGiftPopup2 extends AbsDialogFragment {
String giftJson = data.getString("giftlist");
List<LiveGiftBean> 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<LiveGiftBean> 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<LiveGiftBean> liveGiftBeans = JSONArray.parseArray(giftJson, LiveGiftBean.class);
mFrameGiftNewAdapter = new FrameGiftNewAdapter(liveGiftBeans, mStream, mLiveUid, mWishGiftId);
giftRecyclerView.setAdapter(mFrameGiftNewAdapter);
isWrap = false;
if (giftSendGroup.getVisibility() == View.INVISIBLE) {
hideLianBtn();

View File

@ -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">
<View
android:id="@+id/isSelectView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:layout_marginTop="6dp"
android:layout_marginBottom="10dp"
android:background="@drawable/background_gift_select2"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="0.79"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.80"
app:layout_constraintWidth_percent="0.78"
tools:visibility="visible" />
<ImageView
@ -35,7 +35,7 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.18"
app:layout_constraintVertical_bias="0.22"
app:layout_constraintWidth_percent="0.53"
tools:src="@mipmap/gif_rose" />
@ -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" />
<com.makeramen.roundedimageview.RoundedImageView
@ -129,6 +126,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
tools:visibility="visible"
app:constraint_referenced_ids="giftNamingBg,avatar,naming_name" />
<!--corner_mark 不知道干嘛的 -->
@ -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" />

View File

@ -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" />
</FrameLayout>