保存一波数据线

This commit is contained in:
ningwenqiang 2024-09-26 18:32:01 +08:00
parent d7a5d224b2
commit 729db13ffd
10 changed files with 474 additions and 12 deletions

View File

@ -161,12 +161,14 @@
<TextView
android:id="@+id/giftWrapTv"
android:layout_width="wrap_content"
android:layout_width="48dp"
android:layout_height="wrap_content"
android:layout_marginEnd="12dp"
android:layout_marginBottom="10dp"
android:gravity="center"
android:padding="6dp"
android:text="@string/live_wrap"
android:textStyle="bold"
android:textColor="#CCCDCE"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@+id/giftRecyclerView"
@ -353,7 +355,7 @@
android:textSize="12sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/openVipBg"
app:layout_constraintEnd_tostartOf="@+id/openVipBg"
app:layout_constraintEnd_toStartOf="@+id/openVipBg"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintWidth_percent="0.7"
tools:text="描述信信息描述信信息描述信信息描述信信息描述信信息描述信信息描述信信息描述信信息描述信信息描述信信息描述信信息" />

View File

@ -11,6 +11,7 @@
<color name="transparent">#00000000</color>
<color name="textColor">#323232</color>
<color name="white">#fff</color>
<color name="feea36">#feea36</color>
<color name="white_60">#99FFFFFF</color>
<color name="white_85">#85ffffff</color>
<color name="gray1">#969696</color>

View File

@ -0,0 +1,249 @@
package com.yunbao.live.adapter;
import android.content.Context;
import android.graphics.Color;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateDecelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.view.animation.ScaleAnimation;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.IdRes;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.Group;
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.event.LiveGiftDialogEvent;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.interfaces.CommonCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.Bus;
import com.yunbao.common.utils.GiftCacheUtil;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.utils.StringUtil;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.common.views.weight.MarqueeTextView;
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;
import java.util.List;
public class FrameGiftNewAdapter extends RecyclerView.Adapter {
private List<LiveGiftBean> giftJson = new ArrayList<>();
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;
this.wishGiftId = wishGiftId;
}
@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);
}
public void giftSelect(LiveGiftBean model) {
for (int i = 0; i < giftJson.size(); i++) {
giftJson.get(i).setChecked(giftJson.get(i).getId() == model.getId());
}
notifyDataSetChanged();
}
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
if (!TextUtils.isEmpty(wishGiftId) && TextUtils.equals(giftJson.get(position).getId() + "", wishGiftId)) {
Bus.get().post(new LiveGiftItemEvent().setLiveGiftModel(giftJson.get(position)));
wishGiftId = null;
}
GiftViewHolder frameGiftViewHolder = (GiftViewHolder) holder;
frameGiftViewHolder.showData(giftJson.get(position));
frameGiftViewHolder.giftSelect(giftJson.get(position), position, mStream, mLiveUid, new GiftViewHolder.FrameGiftClickListener() {
@Override
public void onCallBack(int position, LiveGiftBean model) {
Bus.get().post(new LiveGiftItemEvent().setLiveGiftModel(model));
wishGiftId = null;
giftSelect(model);
}
});
}
@Override
public int getItemCount() {
return giftJson.size();
}
public static class GiftViewHolder extends RecyclerView.ViewHolder {
// 声明所有需要初始化的视图组件
private View isSelectView;
private ImageView giftIconImg;
private TextView giftNameTv;
private TextView priceTv;
private ImageView payIco;
private ImageView giftNamingBg;
private RoundedImageView avatar;
private MarqueeTextView namingName;
private Group namingGroup;
private ImageView cornerMark;
private ScaleAnimation mAnimation;
private View rootView;
public GiftViewHolder(@NonNull View itemView) {
super(itemView);
rootView = itemView;
// 初始化所有视图组件
this.isSelectView = findViewById(R.id.isSelectView);
this.giftIconImg = findViewById(R.id.giftIconImg);
this.giftNameTv = findViewById(R.id.giftNameTv);
this.priceTv = findViewById(R.id.priceTv);
this.payIco = findViewById(R.id.pay_ico);
this.giftNamingBg = findViewById(R.id.giftNamingBg);
this.avatar = findViewById(R.id.avatar);
this.namingName = findViewById(R.id.naming_name);
this.namingGroup = findViewById(R.id.namingGroup);
this.cornerMark = findViewById(R.id.corner_mark);
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());
mAnimation.setDuration(400);
mAnimation.setRepeatMode(Animation.REVERSE);
mAnimation.setRepeatCount(-1);
}
private Context getContext() {
return rootView.getContext();
}
private final <T extends View> T findViewById(@IdRes int id) {
return rootView.findViewById(id);
}
public void showData(LiveGiftBean model) {
isSelectView.setVisibility(model.isChecked() ? View.VISIBLE : View.INVISIBLE);
if (model.isChecked()) {
giftIconImg.startAnimation(mAnimation);
}
ImgLoader.display(getContext(), model.getIcon(), giftIconImg);
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);
namingName.setText(WordUtil.getNewString(com.yunbao.common.R.string.mystery_man));
} else {
ImgLoader.display(getContext(), model.getNamingUserAvatar(), avatar);
namingName.setText(model.getNamingUserName());
}
//特殊礼物红包
if (model.getType() == 9999999) {
payIco.setVisibility(View.GONE);
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);
} else {
payIco.setImageResource(R.mipmap.diamond);
}
priceTv.setText(model.getPrice());
}
if (model.getSwf() != null && model.getSwf().isEmpty()) {
mLoadingLayout.setVisibility(View.GONE);
} else {
mLoadingLayout.setVisibility(GiftCacheUtil.checkGiftIsDownload(model.getId()) ? View.GONE : View.VISIBLE);
}
if (model.isChecked() && !StringUtil.isEmpty(model.getNamingUserName())) {
namingLayout.setVisibility(View.VISIBLE);
} else {
namingLayout.setVisibility(View.GONE);
}
}
public void giftSelect(LiveGiftBean model, int position, String mStream, String mLiveUid, FrameGiftClickListener frameGiftClickListener) {
ViewClicksAntiShake.clicksAntiShake(mLoadingLayout, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
mLoading.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);
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);
animation.setRepeatCount(0);
animation.setDuration(0);
animation.cancel();
mLoading.setAnimation(animation);
} else {
mLoadingLayout.setVisibility(View.GONE);
}
GiftCacheUtil.getInstance().restart();
}
});
}
});
ViewClicksAntiShake.clicksAntiShake(giftLayout, new ViewClicksAntiShake.ViewClicksCallBack() {
@Override
public void onViewClicks() {
if (model.getType() == 9999999) {
MobclickAgent.onEvent(getContext(), "gif_list_redpk", "用户点开礼物列表红包");
Bus.get().post(new LiveGiftDialogEvent());
new XPopup.Builder(getContext())
.asCustom(new SendRendPacketPopup(getContext(), mLiveUid))
.show();
} else {
if (frameGiftClickListener != null) {
frameGiftClickListener.onCallBack(position, model);
}
}
}
});
}
public interface FrameGiftClickListener {
void onCallBack(int position, LiveGiftBean model);
}
}
}

View File

@ -1,5 +1,6 @@
package com.yunbao.live.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -11,6 +12,8 @@ import com.yunbao.live.R;
import com.yunbao.live.bean.GiftTopBean;
import com.yunbao.live.views.GiftTitleViewHolder;
import net.lucode.hackware.magicindicator.buildins.UIUtil;
import java.util.ArrayList;
import java.util.List;
@ -22,10 +25,23 @@ public class GiftTitleAdapter extends RecyclerView.Adapter {
List<GiftTopBean> name = new ArrayList<>();
private int index = 0;
private int itemWidth = -1;
private int getItemWidth(Context context) {
if (itemWidth < 0) {
itemWidth = (UIUtil.getScreenWidth(context) - UIUtil.dip2px(context, 60)) / 5;
}
return itemWidth;
}
@NonNull
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View herdView = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_gift_top_new, parent, false);
ViewGroup.LayoutParams layoutParams = herdView.getLayoutParams();
layoutParams.width=getItemWidth(parent.getContext());
herdView.setLayoutParams(layoutParams);
return new GiftTitleViewHolder(herdView);
}

View File

@ -27,6 +27,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
@ -286,7 +287,6 @@ public class LiveGiftPopup2 extends AbsDialogFragment {
giftTitleAdapter = new GiftTitleAdapter();
giftTitleRecyclerView.setAdapter(giftTitleAdapter);
giftWrapTv.setAlpha(0.5f);
giftWrapTv.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
liveGiftSend.setEnabled(false);
giftSendGroup.setVisibility(View.INVISIBLE);
giftDescription.setVisibility(View.GONE);
@ -326,6 +326,7 @@ public class LiveGiftPopup2 extends AbsDialogFragment {
giftTitleAdapter.uncheck();
giftWrapTv.setAlpha(1.0f);
giftWrapTv.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
giftWrapTv.setTextColor(ContextCompat.getColor(mContext, com.yunbao.live.R.color.feea36));
//TODO 切换到包裹取消更爱
// transaction = getTransaction();
// contentFragment = LiveParcelFragment.newInstance(mStream, mLiveUid);
@ -1096,7 +1097,8 @@ public class LiveGiftPopup2 extends AbsDialogFragment {
public void onGiftTitleEvent(GiftTitleEvent event) {
giftWrapTv.setAlpha(0.5f);
giftWrapTv.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
giftWrapTv.setTextColor(ContextCompat.getColor(mContext, com.yunbao.live.R.color.white));
liveGiftSend.setEnabled(false);
giftSendGroup.setVisibility(View.INVISIBLE);
JSONObject obj2 = liveGiftList.getJSONObject(event.getmPosition());

View File

@ -4,6 +4,7 @@ import android.graphics.Typeface;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.utils.MobclickAgent;
@ -63,9 +64,11 @@ public class GiftTitleViewHolder extends RecyclerView.ViewHolder {
break;
}
name.setAlpha(1.0f);
name.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
//FEEA36
name.setTextColor(ContextCompat.getColor(itemView.getContext(),R.color.feea36));
} else {
name.setAlpha(0.5f);
name.setTextColor(ContextCompat.getColor(itemView.getContext(),R.color.white));
name.setTypeface(Typeface.SANS_SERIF, Typeface.NORMAL);
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle" xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="4dp" />
<solid android:color="#e6272C42" />
<stroke android:width="0.6dp" android:color="#AEAEB2" />
</shape>

View File

@ -114,7 +114,8 @@
android:layout_height="match_parent"
android:background="#C0000000"
android:gravity="center"
android:visibility="gone">
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/gift_loading"

View File

@ -0,0 +1,179 @@
<?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/gift_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
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:background="@drawable/background_gift_select2"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.80"
tools:visibility="visible" />
<ImageView
android:id="@+id/giftIconImg"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.18"
app:layout_constraintWidth_percent="0.53"
tools:src="@mipmap/gif_rose" />
<TextView
android:id="@+id/giftNameTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:textColor="@color/white"
android:textSize="11sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/giftIconImg"
tools:text="玫瑰" />
<TextView
android:id="@+id/priceTv"
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"
app:layout_constraintStart_toStartOf="@+id/giftIconImg"
app:layout_constraintTop_toBottomOf="@+id/giftNameTv"
tools:text="2000" />
<ImageView
android:id="@+id/pay_ico"
android:layout_width="9dp"
android:layout_height="9dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="2dp"
app:layout_constraintBottom_toBottomOf="@+id/priceTv"
app:layout_constraintEnd_toStartOf="@+id/priceTv"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintTop_toTopOf="@+id/priceTv"
tools:src="@mipmap/ic_diamond_transp" />
<!--这个是礼物冠名的 -->
<ImageView
android:id="@+id/giftNamingBg"
android:layout_width="0dp"
android:layout_height="0dp"
android:src="@mipmap/item_frame_gift_naming_bg"
app:layout_constraintBottom_toBottomOf="parent"
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
android:id="@+id/avatar"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="@drawable/m_chu_xia"
app:layout_constraintBottom_toBottomOf="@+id/giftNamingBg"
app:layout_constraintDimensionRatio="1"
app:layout_constraintStart_toStartOf="@+id/giftNamingBg"
app:layout_constraintTop_toTopOf="@+id/giftNamingBg"
app:riv_oval="true" />
<com.yunbao.common.views.weight.MarqueeTextView
android:id="@+id/naming_name"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textColor="#FFFFFFFF"
android:textSize="10sp"
app:layout_constraintBottom_toBottomOf="@+id/giftNamingBg"
app:layout_constraintEnd_toEndOf="@+id/giftNamingBg"
app:layout_constraintStart_toEndOf="@+id/avatar"
app:layout_constraintTop_toTopOf="@+id/giftNamingBg"
tools:text="fdgfgdfgdfgdfgdf" />
<androidx.constraintlayout.widget.Group
android:id="@+id/namingGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="giftNamingBg,avatar,naming_name" />
<!--corner_mark 不知道干嘛的 -->
<ImageView
android:id="@+id/corner_mark"
android:layout_width="wrap_content"
android:layout_height="11dp"
android:layout_gravity="end"
android:layout_marginEnd="2dp"
app:layout_constraintEnd_toEndOf="@+id/isSelectView"
app:layout_constraintTop_toTopOf="@+id/isSelectView" />
<View
android:id="@+id/loadImgClickView"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:background="#C0000000"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintWidth_percent="0.80"
tools:visibility="visible" />
<ImageView
android:id="@+id/loadImgImageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:src="@mipmap/icon_download_gift"
app:layout_constraintBottom_toBottomOf="@+id/loadImgClickView"
app:layout_constraintEnd_toEndOf="@+id/loadImgClickView"
app:layout_constraintStart_toStartOf="@+id/loadImgClickView"
app:layout_constraintTop_toTopOf="@+id/loadImgClickView" />
<androidx.constraintlayout.widget.Group
android:id="@+id/loadImgGroup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:constraint_referenced_ids="loadImgClickView,loadImgImageView" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="match_parent">
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
tools:background="@color/black1">
<com.yunbao.common.custom.DrawableTextView
android:id="@+id/name"
@ -9,10 +11,11 @@
android:layout_height="match_parent"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:gravity="center_vertical"
android:gravity="center"
android:text="@string/live_wrap"
android:textStyle="bold"
android:textColor="@color/white"
android:textSize="16sp" />
</LinearLayout>
</FrameLayout>