feat:完成房间礼物面板-背包位置调整

feat:调整礼物面板部分layout的间距、高度
This commit is contained in:
max
2024-06-19 14:54:24 +08:00
parent a7faa20321
commit d8815a23e7
7 changed files with 167 additions and 134 deletions

View File

@@ -40,6 +40,7 @@ import com.chwl.core.gift.bean.LuckyBagNoticeInfo;
import com.chwl.core.gift.bean.SimpleUserInfo;
import com.chwl.core.room.anotherroompk.ShowUserInfoDialogEvent;
import com.chwl.core.utils.extension.StringExtensionKt;
import com.example.lib_utils.UiUtils;
import com.google.android.material.bottomsheet.BottomSheetBehavior;
import com.google.android.material.bottomsheet.BottomSheetDialog;
import com.netease.nim.uikit.common.util.sys.ScreenUtil;
@@ -156,7 +157,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private TextView giftNumberText;
private ImageView giftNumberOptions;
private ImageView ivOpenNoble;
private TextView tvGiftValue;
// private TextView tvGiftValue;
private EditText etSendMessage;
private Button sendGiftButton;
private View layoutEmpty;
@@ -177,7 +178,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
private List<List<GiftInfoVm>> pagerList;
private WalletInfo goldWalletInfo = PayModel.get().getCurrentWalletInfo();
private int itemType = ITEM_TYPE_GOLD;
private HorizontalScrollView hsvTabs;
private View rlGifts;
private View llTabs;
private View llDrawGift;
@@ -422,7 +422,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
reloadView = root.findViewById(R.id.tv_reload);
reloadView.setOnClickListener(this);
loadingView = root.findViewById(R.id.iv_loading);
hsvTabs = root.findViewById(R.id.hsv_tabs);
rlGifts = root.findViewById(R.id.rl_gifts);
llTabs = root.findViewById(R.id.ll_tabs);
llDrawGift = root.findViewById(R.id.ll_draw_gift);
@@ -446,7 +445,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_WEEK, ResUtil.getString(R.string.ui_widget_giftdialog_07), ResUtil.getString(R.string.ui_widget_giftdialog_08)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_DRAW_GIFT, ResUtil.getString(R.string.ui_widget_giftdialog_09), ResUtil.getString(R.string.ui_widget_giftdialog_010)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_SING_ROOM, ResUtil.getString(R.string.ui_widget_giftdialog_hot), ResUtil.getString(R.string.ui_widget_giftdialog_hot)));
tabInfoList.add(new GiftTab(GiftIndicator.TYPE_KNAP, ResUtil.getString(R.string.ui_widget_giftdialog_011), ResUtil.getString(R.string.ui_widget_giftdialog_012)));
// tabInfoList.add(new GiftTab(GiftIndicator.TYPE_KNAP, ResUtil.getString(R.string.ui_widget_giftdialog_011), ResUtil.getString(R.string.ui_widget_giftdialog_012)));
giftIndicator = root.findViewById(R.id.gift_indicator);
giftIndicator.initTab(
tabInfoList,
@@ -494,10 +493,13 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
ivOpenNoble = root.findViewById(R.id.iv_open_noble);
etSendMessage = root.findViewById(R.id.et_gift_message);
if (UiUtils.INSTANCE.isRtl(context)) {
ivOpenNoble.setScaleType(ImageView.ScaleType.FIT_START);
}
ivOpenNoble.setOnClickListener(this);
sendContainer = root.findViewById(R.id.send_container);
layoutEmpty.setVisibility(View.GONE);
tvGiftValue = root.findViewById(R.id.tv_gift_value);
// tvGiftValue = root.findViewById(R.id.tv_gift_value);
if (giftId == 0) {
// 更新所有礼物
@@ -532,19 +534,23 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
View descLayout = root.findViewById(R.id.desc_layout);
View seatLayout = root.findViewById(R.id.rl_avatars);
if (isInRoom && (userOnMic || uid == 0)) {
avatarList.setVisibility(View.VISIBLE);
descLayout.setVisibility(View.GONE);
avatarList.setVisibility(View.VISIBLE);
if (micMemberInfos != null && micMemberInfos.size() > 0) {
avatarListAdapter = new GiftAvatarAdapter(getContext());
avatarListAdapter.setMicMemberInfos(micMemberInfos);
avatarListAdapter.setOnItemSelectedListener(this);
avatarList.setAdapter(avatarListAdapter);
seatLayout.setVisibility(View.VISIBLE);
}else{
seatLayout.setVisibility(View.GONE);
}
} else {
avatarList.setVisibility(View.INVISIBLE);
avatarList.setVisibility(View.GONE);
descLayout.setVisibility(View.VISIBLE);
seatLayout.setVisibility(View.VISIBLE);
Single<UserInfo> single = UserModel.get().getUserInfo(uid);
@@ -652,7 +658,6 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
currentGiftInfoList = GiftModel.get().getKnapList();
} else if (position == GiftIndicator.TYPE_NOBLE) {
currentGiftInfoList = nobleGiftInfos;
ivOpenNoble.setVisibility(View.VISIBLE);
} else if (position == GiftIndicator.TYPE_NORMAL) {
currentGiftInfoList = getNormalGiftInfos();
} else if (position == GiftIndicator.TYPE_LUCKY) {
@@ -682,7 +687,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
if (ListUtils.isListEmpty(currentGiftInfoList)) {
currentGiftInfo = null;
if (isKnap) {
tvGiftValue.setVisibility(View.VISIBLE);
// tvGiftValue.setVisibility(View.VISIBLE);
showEmptyView();
} else if (position == GiftIndicator.TYPE_LUCKY ||
position == GiftIndicator.TYPE_WEEK ||
@@ -705,7 +710,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
pagerList = beanTransformVm(context, currentGiftInfoList, isKnap, position == GiftIndicator.TYPE_WEEK ? 4 : 8, currentGiftInfo);
setGridViewData(pagerList);
if (isKnap) {
tvGiftValue.setVisibility(View.VISIBLE);
// tvGiftValue.setVisibility(View.VISIBLE);
updateTotalPrice();
} else {
if (giftNumber == -1) {
@@ -719,9 +724,9 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
updateDrawGift();
giftIndicator.post(() -> {
if (position < GiftIndicator.TYPE_WEEK) {
hsvTabs.fullScroll(View.FOCUS_LEFT);
giftIndicator.fullScroll(View.FOCUS_LEFT);
} else {
hsvTabs.fullScroll(View.FOCUS_RIGHT);
giftIndicator.fullScroll(View.FOCUS_RIGHT);
}
});
}
@@ -945,21 +950,21 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
}
private void updateTotalPrice() {
String diamond = "";
double totalValue = 0;
for (int i = 0; i < currentGiftInfoList.size(); i++) {
totalValue += currentGiftInfoList.get(i).getCount() * currentGiftInfoList.get(i).getGoldPrice();
}
if (totalValue >= 10000) {
totalValue = totalValue / 10000.0f;
diamond = FormatUtils.formatBigDecimal(totalValue) + "W+";
} else {
diamond = String.valueOf((int) totalValue);
}
SpannableBuilder text = new SpannableBuilder()
.append(ResUtil.getString(R.string.ui_widget_giftdialog_021), new ForegroundColorSpan(Color.parseColor("#7A797A")))
.append(diamond + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(Color.WHITE));
tvGiftValue.setText(text.build());
// String diamond = "";
// double totalValue = 0;
// for (int i = 0; i < currentGiftInfoList.size(); i++) {
// totalValue += currentGiftInfoList.get(i).getCount() * currentGiftInfoList.get(i).getGoldPrice();
// }
// if (totalValue >= 10000) {
// totalValue = totalValue / 10000.0f;
// diamond = FormatUtils.formatBigDecimal(totalValue) + "W+";
// } else {
// diamond = String.valueOf((int) totalValue);
// }
// SpannableBuilder text = new SpannableBuilder()
// .append(ResUtil.getString(R.string.ui_widget_giftdialog_021), new ForegroundColorSpan(Color.parseColor("#7A797A")))
// .append(diamond + ResUtil.getString(R.string.avroom_widget_messageview_027), new ForegroundColorSpan(Color.WHITE));
// tvGiftValue.setText(text.build());
}
private void showEmptyView() {
@@ -992,8 +997,7 @@ public class GiftDialog extends BottomSheetDialog implements View.OnClickListene
layoutLoadFiled.setVisibility(View.GONE);
layoutEmpty.setVisibility(View.GONE);
etSendMessage.setVisibility(View.GONE);
tvGiftValue.setVisibility(View.GONE);
ivOpenNoble.setVisibility(View.GONE);
// tvGiftValue.setVisibility(View.GONE);
llStarWeek.setVisibility(View.GONE);
gridView.setVisibility(View.VISIBLE);

View File

@@ -2,8 +2,11 @@ package com.chwl.app.ui.widget.magicindicator;
import android.content.Context;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.HorizontalScrollView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -14,9 +17,7 @@ import com.chwl.app.ui.widget.magicindicator.buildins.UIUtil;
import com.chwl.core.gift.bean.GiftTab;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.reactivex.Observable;
import lombok.Getter;
@@ -29,37 +30,43 @@ import lombok.Getter;
*/
public class GiftIndicator extends LinearLayout {
/**普通礼物*/
/**
* 普通礼物
*/
public static final int TYPE_NORMAL = 0;
/**星球礼物*/
/**
* 星球礼物
*/
public static final int TYPE_LUCKY = 1;
/**贵族礼物*/
/**
* 贵族礼物
*/
public static final int TYPE_NOBLE = 2;
/**周星礼物*/
/**
* 周星礼物
*/
public static final int TYPE_WEEK = 3;
/**涂鸦礼物*/
/**
* 涂鸦礼物
*/
public static final int TYPE_DRAW_GIFT = 4;
/**背包礼物*/
/**
* 背包礼物
*/
public static final int TYPE_KNAP = 5;
/**个播人气礼物*/
/**
* 个播人气礼物
*/
public static final int TYPE_SING_ROOM = 6;
private Map<String, String> map = new HashMap<>();
public GiftIndicator(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
setOrientation(LinearLayout.HORIZONTAL);
}
private List<GiftTab> tabList = new ArrayList<>();
@Getter
@@ -67,13 +74,26 @@ public class GiftIndicator extends LinearLayout {
private int mFalseColor;
private int mTrueColor;
private LinearLayout tabLayout;
private View knapView;
private HorizontalScrollView scrollView;
public GiftIndicator(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
LayoutInflater.from(context).inflate(R.layout.gift_dialog_tab_indicator, this, true);
setOrientation(LinearLayout.HORIZONTAL);
setGravity(Gravity.CENTER_VERTICAL);
scrollView = findViewById(R.id.scroll_view);
tabLayout = findViewById(R.id.layout_tab);
knapView = findViewById(R.id.iv_knap);
}
public void initTab(List<GiftTab> list, int falseColor, int trueColor) {
for (int i = 0; i < list.size(); i++) {
GiftTab tab = list.get(i);
View view = inflate(GiftIndicator.this.getContext(), R.layout.layout_gift_indicator_item, null);
tab.setItemView(view);
addView(view, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
tabLayout.addView(view, new LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
UIUtil.dip2px(getContext(), 26)));
TextView tvTitle = view.findViewById(R.id.tv_title);
tvTitle.setText(tab.getUnSelectedTitle());
@@ -93,6 +113,10 @@ public class GiftIndicator extends LinearLayout {
emitter.onNext(index.getType());
});
}
knapView.setOnClickListener(v -> {
setPosition(TYPE_KNAP);
emitter.onNext(TYPE_KNAP);
});
});
}
@@ -130,4 +154,7 @@ public class GiftIndicator extends LinearLayout {
}
}
public void fullScroll(int direction) {
scrollView.fullScroll(direction);
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

View File

@@ -84,21 +84,21 @@
android:layout_width="match_parent"
android:layout_height="56dp"
android:visibility="gone"
app:bvp_can_loop="true"
app:bvp_auto_play="true"
app:bvp_can_loop="true"
app:bvp_indicator_visibility="gone"
app:bvp_page_style="multi_page_scale"
app:layout_constraintBottom_toTopOf="@+id/ll_dialog_bottom_gift"/>
app:layout_constraintBottom_toTopOf="@+id/ll_dialog_bottom_gift" />
<LinearLayout
android:id="@+id/ll_dialog_bottom_gift"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:background="@drawable/bg_dialog_room_operation"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
android:background="@drawable/bg_dialog_room_operation">
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:id="@+id/ll_draw_gift"
@@ -147,11 +147,40 @@
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="@dimen/dp_45">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|start"
android:layout_marginStart="@dimen/dp_15"
android:text="送禮"
android:textColor="@color/white"
android:textSize="@dimen/dp_15" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_open_noble"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_vertical|end"
android:layout_marginEnd="@dimen/dp_15"
android:scaleType="fitEnd"
android:src="@drawable/ic_vip_gift_dialog" />
<View
android:layout_width="match_parent"
android:layout_height="@dimen/dp_0_5"
android:layout_gravity="bottom"
android:background="#33FFFFFF" />
</FrameLayout>
<RelativeLayout
android:id="@+id/rl_avatars"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">
android:layout_marginTop="@dimen/dp_10">
<LinearLayout
android:id="@+id/desc_layout"
@@ -192,87 +221,19 @@
android:layout_marginEnd="@dimen/dp_15" />
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1px"
android:background="#05FFFFFF" />
<LinearLayout
android:id="@+id/ll_tabs"
android:layout_width="match_parent"
android:layout_height="@dimen/dp_26"
android:layout_marginTop="10dp"
android:layout_height="@dimen/dp_30"
android:layout_marginTop="@dimen/dp_10"
android:orientation="horizontal"
tools:background="@color/blue">
<HorizontalScrollView
android:id="@+id/hsv_tabs"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:clipToPadding="false"
android:paddingStart="9dp"
android:requiresFadingEdge="horizontal">
<com.chwl.app.ui.widget.magicindicator.GiftIndicator
android:id="@+id/gift_indicator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start|center_vertical" />
</HorizontalScrollView>
<FrameLayout
android:layout_width="wrap_content"
<com.chwl.app.ui.widget.magicindicator.GiftIndicator
android:id="@+id/gift_indicator"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginStart="15dp"
android:layout_marginEnd="15dp">
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_open_noble"
android:layout_width="wrap_content"
android:layout_height="20dp"
android:layout_gravity="center_vertical|end"
android:src="@drawable/ic_vip_gift_dialog"
android:visibility="gone"
tools:visibility="gone" />
<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/tv_gift_value"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_gravity="center_vertical|end"
android:gravity="center_vertical"
android:text="@string/layout_dialog_bottom_gift_05"
android:textColor="#7A7A7A"
android:textSize="@dimen/sp_13"
android:visibility="gone"
tools:visibility="gone" />
<LinearLayout
android:id="@+id/ll_week_in"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical|end"
android:gravity="center"
android:orientation="horizontal"
android:visibility="gone"
tools:visibility="gone">
<androidx.appcompat.widget.AppCompatImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_week_star" />
<com.chwl.app.view.AutoMirroredImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="4dp"
android:src="@drawable/ic_week_star_arrow" />
</LinearLayout>
</FrameLayout>
android:layout_gravity="start|center_vertical" />
</LinearLayout>
@@ -514,14 +475,19 @@
android:layout_height="25dp"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/tv_text_gold"
android:drawablePadding="@dimen/dp_5"
android:gravity="center"
android:paddingStart="@dimen/dp_10"
android:paddingEnd="@dimen/dp_10"
android:text="@string/charge"
android:textColor="@color/color_FACB4D"
android:textSize="@dimen/sp_13"
app:drawableEndCompat="@drawable/ic_arrow_recharge" />
android:textSize="@dimen/sp_13"/>
<com.chwl.app.view.AutoMirroredImageView
android:layout_marginStart="@dimen/dp_5"
android:layout_centerVertical="true"
android:layout_toEndOf="@+id/tv_recharge"
android:src="@drawable/ic_arrow_recharge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/iv_diamond"

View File

@@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
tools:parentTag="android.widget.LinearLayout">
<HorizontalScrollView
android:id="@+id/scroll_view"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<LinearLayout
android:id="@+id/layout_tab"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginStart="@dimen/dp_7_5"
android:gravity="center_vertical"
android:orientation="horizontal" />
</HorizontalScrollView>
<ImageView
android:id="@+id/iv_knap"
android:layout_width="@dimen/dp_30"
android:layout_height="@dimen/dp_30"
android:layout_gravity="center_vertical"
android:layout_marginStart="@dimen/dp_10"
android:layout_marginEnd="@dimen/dp_10"
android:padding="@dimen/dp_5"
android:scaleType="fitCenter"
android:src="@drawable/gift_dialog_ic_backpack" />
</merge>

View File

@@ -5,8 +5,8 @@
android:layout_height="26dp"
android:orientation="vertical"
android:gravity="center"
android:paddingStart="@dimen/dp_6"
android:paddingEnd="@dimen/dp_6">
android:paddingStart="@dimen/dp_7_5"
android:paddingEnd="@dimen/dp_7_5">
<TextView
android:id="@+id/tv_title"

View File

@@ -12,7 +12,7 @@
android:layout_width="@dimen/dp_299"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="@dimen/dp_37"
android:layout_marginTop="@dimen/dp_63"
android:background="@drawable/room_team_pk_result_bg"
android:clickable="true"
android:clipChildren="false"