新增礼物墙弹窗主题

This commit is contained in:
zlzw 2024-07-04 13:41:37 +08:00
parent 2cefd50ac3
commit 8cae89e7cd
15 changed files with 415 additions and 6 deletions

View File

@ -0,0 +1,150 @@
package com.yunbao.common.dialog;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import androidx.viewpager2.widget.ViewPager2;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.R;
import com.yunbao.common.fragment.BaseFragment;
import com.yunbao.common.fragment.GiftWallMainTab1Fragment;
import com.yunbao.common.fragment.GiftWallMainTab2Fragment;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.ScreenDimenUtil;
import com.yunbao.common.views.CustomEllipsizeTextView;
import com.yunbao.common.views.weight.ViewClicksAntiShake;
import java.util.ArrayList;
import java.util.List;
/**
* 礼物墙
*/
public class GiftWallDialog extends AbsDialogPopupWindow {
private ImageView mIvBg;
private ImageView mIvTips;
private ImageView mIvBack;
private CustomEllipsizeTextView mTvUserName;
private View mAchievement;
private TextView mTvTab1, mTvTab2;
private ViewPager2 mViewPager;
private LinearLayout mIvTabsLayout;
private List<BaseFragment> fragments = new ArrayList<>();
private boolean isFullWindows;
public GiftWallDialog(@NonNull Context context) {
super(context);
}
public GiftWallDialog setFullWindows(boolean fullWindows) {
isFullWindows = fullWindows;
return this;
}
@Override
public void buildDialog(XPopup.Builder builder) {
}
@Override
public int bindLayoutId() {
return R.layout.dialog_gift_wall;
}
@Override
protected int getPopupHeight() {
if (isFullWindows) {
return super.getPopupHeight();
}
int screenHeight = ScreenDimenUtil.getInstance().getScreenHeight();
return (int) (screenHeight * 0.8);
}
void initView() {
mIvBg = findViewById(R.id.iv_root_bg);
mIvTips = findViewById(R.id.v_tips);
mIvBack = findViewById(R.id.iv_back);
mTvUserName = findViewById(R.id.user_name);
mAchievement = findViewById(R.id.v_achievement);
mTvTab1 = findViewById(R.id.tab1);
mTvTab2 = findViewById(R.id.tab2);
mViewPager = findViewById(R.id.viewPager2);
mIvTabsLayout = findViewById(R.id.tab_layout);
fragments.add(new GiftWallMainTab1Fragment());
fragments.add(new GiftWallMainTab2Fragment());
mViewPager.setAdapter(new FragmentStateAdapter((FragmentActivity) mContext) {
@NonNull
@Override
public Fragment createFragment(int position) {
return fragments.get(position);
}
@Override
public int getItemCount() {
return fragments.size();
}
});
mViewPager.setUserInputEnabled(false);
ViewClicksAntiShake.clicksAntiShake(mTvTab1, () -> {
mIvBg.setImageResource(R.mipmap.bg_gift_wall_main_root);
mIvTabsLayout.setBackgroundResource(R.mipmap.icon_gift_wall_main_switch_main);
mTvTab1.setTextColor(Color.parseColor("#9CE7FF"));
mTvTab1.setTextSize(16);
mTvTab1.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
mTvTab2.setTextColor(Color.parseColor("#FFFFFF"));
mTvTab2.setTextSize(14);
mTvTab2.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
mViewPager.setCurrentItem(0,false);
});
ViewClicksAntiShake.clicksAntiShake(mTvTab2, () -> {
mIvBg.setImageResource(R.mipmap.bg_gift_wall_main_root2);
mIvTabsLayout.setBackgroundResource(R.mipmap.icon_gift_wall_main_switch_full);
mTvTab1.setTextColor(Color.parseColor("#FFFFFF"));
mTvTab1.setTextSize(14);
mTvTab1.setTypeface(Typeface.defaultFromStyle(Typeface.NORMAL));
mTvTab2.setTextColor(Color.parseColor("#FFC593"));
mTvTab2.setTextSize(16);
mTvTab2.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
mViewPager.setCurrentItem(1,false);
});
}
@Override
protected void onCreate() {
super.onCreate();
initView();
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) mIvBack.getLayoutParams();
if (isFullWindows) {
params.width=DpUtil.dp2px(20);
mIvBack.setVisibility(View.VISIBLE);
mIvBg.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
params.width=DpUtil.dp2px(1);
mIvBack.setVisibility(View.INVISIBLE);
mIvBg.setScaleType(ImageView.ScaleType.FIT_XY);
}
mIvBack.setLayoutParams(params);
}
}

View File

@ -0,0 +1,34 @@
package com.yunbao.common.fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class GiftWallMainTab1Fragment extends BaseFragment {
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
TextView textView = new TextView(getActivity());
textView.setText("第一页");
textView.setTextColor(Color.WHITE);
textView.setTextSize(24);
return textView;
}
@Override
protected void initVariables(Bundle bundle) {
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
}
@Override
protected void loadData() {
}
}

View File

@ -0,0 +1,34 @@
package com.yunbao.common.fragment;
import android.graphics.Color;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
public class GiftWallMainTab2Fragment extends BaseFragment {
@Override
public View createView(LayoutInflater inflater, ViewGroup container) {
TextView textView = new TextView(getActivity());
textView.setText("第二页");
textView.setTextColor(Color.WHITE);
textView.setTextSize(24);
return textView;
}
@Override
protected void initVariables(Bundle bundle) {
}
@Override
protected void initViews(Bundle savedInstanceState, View contentView) {
}
@Override
protected void loadData() {
}
}

View File

@ -0,0 +1,46 @@
package com.yunbao.common.views;
import android.content.Context;
import android.graphics.Canvas;
import android.text.Layout;
import android.text.TextPaint;
import android.text.TextUtils;
import android.util.AttributeSet;
import androidx.appcompat.widget.AppCompatTextView;
public class CustomEllipsizeTextView extends AppCompatTextView {
public CustomEllipsizeTextView(Context context) {
super(context);
}
public CustomEllipsizeTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public CustomEllipsizeTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
CharSequence text = getText();
float measureText = getPaint().measureText(text, 0, text.length());
if (measureText > getMeasuredWidth() && text.length() > 5) {
CharSequence end = text.subSequence(text.length() - 5, text.length());
CharSequence start = text.subSequence(0, text.length() - 5);
CharSequence newCharSequence = getAutoText(start, end, getPaint());
setText(newCharSequence);
}
}
private CharSequence getAutoText(CharSequence start, CharSequence end, TextPaint paint) {
CharSequence text = TextUtils.concat(start.subSequence(0, start.length() - 1), "...", end);
if (paint.measureText(text, 0, text.length()) > getMeasuredWidth()) {
return getAutoText(start.subSequence(0, start.length() - 1), end, paint);
}
return text;
}
}

View File

@ -0,0 +1,133 @@
<?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/rootView"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/iv_root_bg"
android:layout_width="0dp"
android:layout_height="0dp"
android:scaleType="fitXY"
android:src="@mipmap/bg_gift_wall_main_root"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/v_achievement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:layout_marginEnd="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="@+id/imageView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@mipmap/bg_gift_wall_main_achievement"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:layout_marginBottom="1dp"
android:text="@string/dialog_gift_wall_text_honors"
android:textColor="#FFFFFF"
android:textSize="6.8sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/v_tips"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="11dp"
app:layout_constraintBottom_toBottomOf="@+id/v_achievement"
app:layout_constraintEnd_toStartOf="@+id/v_achievement"
app:layout_constraintTop_toTopOf="@+id/v_achievement"
app:srcCompat="@mipmap/icon_gift_wall_main_tips" />
<com.yunbao.common.views.CustomEllipsizeTextView
android:id="@+id/user_name"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:singleLine="true"
android:text="111111111的礼物展馆"
android:textColor="#6BCDFF"
android:textSize="22sp"
app:layout_constraintBottom_toBottomOf="@+id/v_achievement"
app:layout_constraintEnd_toStartOf="@+id/v_tips"
app:layout_constraintStart_toEndOf="@+id/iv_back"
app:layout_constraintTop_toTopOf="@+id/v_achievement" />
<LinearLayout
android:id="@+id/tab_layout"
android:layout_width="205dp"
android:layout_height="36dp"
android:layout_marginTop="13dp"
android:background="@mipmap/icon_gift_wall_main_switch_main"
android:gravity="center"
android:scaleType="fitXY"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/v_achievement">
<TextView
android:id="@+id/tab1"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/dialog_gift_wall_text_personal_hal"
android:textSize="16sp"
android:textColor="#9CE7FF"
android:textStyle="bold" />
<TextView
android:id="@+id/tab2"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:text="@string/dialog_gift_wall_text_site_hal"
android:textColor="#FFFFFF"
android:textSize="14sp" />
</LinearLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager2"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tab_layout" />
<ImageView
android:id="@+id/iv_back"
android:layout_width="1dp"
android:layout_height="wrap_content"
android:layout_marginStart="15dp"
android:src="@mipmap/icon_sud_rule_close_bottom"
android:visibility="invisible"
app:layout_constraintBottom_toBottomOf="@+id/user_name"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="@+id/user_name" />
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1497,5 +1497,8 @@
<string name="main_type_theater">短劇</string>
<string name="prank_complete">完成*1</string>
<string name="pking_over">主播正在PK稍後再試</string>
<string name="dialog_gift_wall_user_name">的禮物展館</string>
<string name="dialog_gift_wall_text_personal_hal">個人展館</string>
<string name="dialog_gift_wall_text_site_hal">全站展館</string>
<string name="dialog_gift_wall_text_honors">榮譽成就</string>
</resources>

View File

@ -841,8 +841,7 @@
<string name="live_hot_ruletext31">How long does the heat card take effect?</string>
<string name="live_hot_ruletext32">After using the hot card for the designated anchor, it will take effect immediately. The effect time is 24 hours. Regardless of whether the anchor is online, the heat time will continue to decrease</string>
<string name="welcome_pd">Rewards coming!</string>
<string name="welcome_pd_tip">Receive free
Limited ride And limited avatar frame</string>
<string name="welcome_pd_tip">Receive free Limited ride And limited avatar frame</string>
<string name="do_you_like_find">Looking for you like?</string>
<string name="exclusive_instructor1">Go contact your personal guide to</string>
<string name="exclusive_instructor2">get your prize redemption code!</string>
@ -1506,4 +1505,8 @@ Limited ride And limited avatar frame</string>
<string name="main_type_theater" >Theater</string>
<string name="pking_over">The anchor is in PK, please try again later</string>
<string name="prank_complete">once</string>
<string name="dialog_gift_wall_user_name">\'sGift Hall</string>
<string name="dialog_gift_wall_text_personal_hal">Personal hal</string>
<string name="dialog_gift_wall_text_site_hal">Whole site hal</string>
<string name="dialog_gift_wall_text_honors">Honors</string>
</resources>

View File

@ -12,7 +12,10 @@ import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;
import com.lxj.xpopup.XPopup;
import com.lxj.xpopup.core.BottomPopupView;
import com.yunbao.common.dialog.GiftWallDialog;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.AppManager;
import com.yunbao.common.utils.MobclickAgent;
import com.yunbao.common.activity.AbsActivity;
import com.yunbao.common.dialog.SkitCheckInWasSuccessfulPopup;
@ -65,9 +68,12 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
img_trophy.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View view) {
LivePrankDialogFragment fragment = new LivePrankDialogFragment();
fragment.setmLiveUid(String.valueOf(IMLoginManager.get(mContext).getUserInfo().getId()));
fragment.show(((AppCompatActivity) mContext).getSupportFragmentManager(), "LivePrankDialogFragment");
AppManager.runDebugCode(new Runnable() {
@Override
public void run() {
new GiftWallDialog(mContext).setFullWindows(false).showDialog();
}
});
return true;
}
});