add:守护列表改版

This commit is contained in:
zlzw 2022-08-29 13:57:54 +08:00
parent c9ce55f483
commit 639b3c09bf
12 changed files with 443 additions and 14 deletions

View File

@ -56,6 +56,7 @@ import com.yunbao.live.dialog.LiveGuardDialogFragment;
import com.yunbao.live.dialog.LiveInputDialogFragment;
import com.yunbao.live.dialog.LiveMoreDialogFragment;
import com.yunbao.live.dialog.LiveNewGuardBuyDialogFragment;
import com.yunbao.live.dialog.LiveNewGuardListDialogFragment;
import com.yunbao.live.dialog.LiveRedPackListDialogFragment;
import com.yunbao.live.dialog.LiveRedPackSendDialogFragment;
import com.yunbao.live.dialog.LiveShareDialogFragment;
@ -1251,6 +1252,18 @@ public abstract class LiveActivity extends AbsActivity implements SocketMessageL
fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment");
}
/**
* 守护列表弹窗
*/
public void openNewGuardListWindow() {
LiveNewGuardListDialogFragment fragment = new LiveNewGuardListDialogFragment();
fragment.setLiveGuardInfo(mLiveGuardInfo);
Bundle bundle = new Bundle();
bundle.putString(Constants.LIVE_UID, mLiveUid);
bundle.putBoolean(Constants.ANCHOR, mIsAnchor);
fragment.setArguments(bundle);
fragment.show(getSupportFragmentManager(), "LiveGuardDialogFragment");
}
/**
* 打開粉絲團

View File

@ -2,9 +2,11 @@ package com.yunbao.live.adapter;
import android.content.Context;
import android.graphics.drawable.Drawable;
import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import android.text.Html;
import android.view.View;
import android.view.ViewGroup;
@ -35,9 +37,11 @@ public class GuardAdapter extends RefreshAdapter<GuardUserBean> {
private Drawable mGuardDrawable0;
private Drawable mGuardDrawable1;
private Drawable mGuardDrawable2;
private boolean isShowTitle;
public GuardAdapter(Context context, boolean dialog) {
public GuardAdapter(Context context, boolean dialog, boolean isShowTitle) {
super(context);
this.isShowTitle = isShowTitle;
mDialog = dialog;
mVotesName = CommonAppConfig.getInstance().getVotesName();
mWeekContributeString = WordUtil.getString(R.string.guard_week_con);
@ -46,9 +50,15 @@ public class GuardAdapter extends RefreshAdapter<GuardUserBean> {
mGuardDrawable2 = ContextCompat.getDrawable(context, R.mipmap.icon_guard_type_2);
}
public GuardAdapter(Context context, boolean dialog) {
this(context, dialog, true);
}
@Override
public int getItemViewType(int position) {
if(!isShowTitle){
return NORMAL;
}
if (position == 0) {
return HEAD;
}

View File

@ -8,6 +8,7 @@ import android.view.Gravity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.Nullable;

View File

@ -0,0 +1,206 @@
package com.yunbao.live.dialog;
import android.graphics.Color;
import android.os.Bundle;
import android.text.Html;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.fragment.app.FragmentTransaction;
import androidx.recyclerview.widget.LinearLayoutManager;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.opensource.svgaplayer.SVGAImageView;
import com.yunbao.common.CommonAppConfig;
import com.yunbao.common.Constants;
import com.yunbao.common.adapter.RefreshAdapter;
import com.yunbao.common.bean.IMLoginModel;
import com.yunbao.common.bean.LevelBean;
import com.yunbao.common.custom.CommonRefreshView;
import com.yunbao.common.dialog.AbsDialogFragment;
import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.http.HttpCallback;
import com.yunbao.common.manager.IMLoginManager;
import com.yunbao.common.utils.CommonIconUtil;
import com.yunbao.common.utils.DpUtil;
import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.R;
import com.yunbao.live.activity.LiveActivity;
import com.yunbao.live.adapter.GuardAdapter;
import com.yunbao.live.bean.GuardUserBean;
import com.yunbao.live.bean.LiveGuardInfo;
import com.yunbao.live.http.LiveHttpUtil;
import java.util.Arrays;
import java.util.List;
public class LiveNewGuardListDialogFragment extends AbsDialogFragment implements View.OnClickListener {
private ImageView guardIcon, userSex, userLevel;
private ConstraintLayout mRootLayout;
private CommonRefreshView mRefreshView;
private TextView mBtnBuy, userName, userGuard,tip1, tip2;
private SVGAImageView giftSvga;
private LinearLayout userLayout;
private GuardAdapter mGuardAdapter;
private LiveGuardInfo mLiveGuardInfo;
private String mLiveUid;
private boolean mIsAnchor;//是否是主播
@Override
protected int getLayoutId() {
return R.layout.dialog_new_guard_list;
}
@Override
protected int getDialogStyle() {
return R.style.dialog2;
}
@Override
protected boolean canCancel() {
return true;
}
public void setLiveGuardInfo(LiveGuardInfo info) {
mLiveGuardInfo = info;
}
@Override
protected void setWindowAttributes(Window window) {
window.setWindowAnimations(R.style.bottomToTopAnim);
WindowManager.LayoutParams params = window.getAttributes();
params.width = WindowManager.LayoutParams.MATCH_PARENT;
params.height = WindowManager.LayoutParams.WRAP_CONTENT;
params.gravity = Gravity.BOTTOM;
window.setAttributes(params);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
Bundle bundle = getArguments();
if (bundle == null) {
return;
}
mIsAnchor = bundle.getBoolean(Constants.ANCHOR, false);
mLiveUid = bundle.getString(Constants.LIVE_UID);
guardIcon = mRootView.findViewById(R.id.guard_imageView);
mRootLayout = mRootView.findViewById(R.id.guard_constraintLayout);
mBtnBuy = mRootView.findViewById(R.id.guard_btn_buy);
giftSvga = mRootView.findViewById(R.id.gift_svga);
mRefreshView = mRootView.findViewById(R.id.refreshView);
userName = mRootView.findViewById(R.id.list_guard_list_user_name);
userGuard = mRootView.findViewById(R.id.list_guard_list_user_guard);
userLevel = mRootView.findViewById(R.id.list_guard_list_user_level);
userSex = mRootView.findViewById(R.id.list_guard_list_user_sex);
userLayout = mRootView.findViewById(R.id.guard_linearLayout);
tip1 = mRootView.findViewById(R.id.guard_tip1);
tip2 = mRootView.findViewById(R.id.guard_tip2);
mBtnBuy.setOnClickListener(this);
mBtnBuy.setEnabled(true);
mBtnBuy.setText(R.string.guard_buy_2);
initView();
}
private void initView() {
mRefreshView.setEmptyLayoutId(mIsAnchor ? R.layout.view_no_data_guard_anc : R.layout.view_no_data_guard_aud);
mRefreshView.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false));
mRefreshView.setDataHelper(new CommonRefreshView.DataHelper<GuardUserBean>() {
@Override
public RefreshAdapter<GuardUserBean> getAdapter() {
if (mGuardAdapter == null) {
mGuardAdapter = new GuardAdapter(mContext, true, false);
}
return mGuardAdapter;
}
@Override
public void loadData(int p, HttpCallback callback) {
LiveHttpUtil.getGuardList(mLiveUid, p, callback);
}
@Override
public List<GuardUserBean> processData(String[] info) {
List<GuardUserBean> list = JSON.parseArray(Arrays.toString(info), GuardUserBean.class);
if (list.isEmpty()) {
userLayout.setVisibility(View.INVISIBLE);
}else {
GuardUserBean bean = list.get(0);
giftSvga.setImageResource(R.drawable.guardian_img_wings_p);
ImgLoader.display(mContext, bean.getAvatar(), guardIcon);
guardIcon.setVisibility(View.VISIBLE);
userName.setText(bean.getUserNiceName());
String guardString = WordUtil.getString(R.string.guard_week_con);
userGuard.setText(guardString + " " + bean.getContribute());
userSex.setImageResource(CommonIconUtil.getSexIcon(bean.getSex()));
LevelBean levelBean = CommonAppConfig.getInstance().getLevel(bean.getLevel());
if (levelBean != null) {
ImgLoader.display(mContext, levelBean.getThumb(), userLevel);
}
}
if (mLiveGuardInfo != null) {
int guardType = mLiveGuardInfo.getMyGuardType();
if (guardType == Constants.GUARD_TYPE_NONE) {
tip1.setText(R.string.guard_tip_0);
} else if (guardType == Constants.GUARD_TYPE_DAY) {
tip1.setText(WordUtil.getString(R.string.guard_tip_day) + mLiveGuardInfo.getMyGuardEndTime());
mBtnBuy.setText(R.string.guard_buy_3);
} else if (guardType == Constants.GUARD_TYPE_MONTH) {
tip1.setText(WordUtil.getString(R.string.guard_tip_1) + mLiveGuardInfo.getMyGuardEndTime());
mBtnBuy.setText(R.string.guard_buy_3);
} else if (guardType == Constants.GUARD_TYPE_YEAR) {
tip1.setText(WordUtil.getString(R.string.guard_tip_2) + mLiveGuardInfo.getMyGuardEndTime());
mBtnBuy.setText(R.string.guard_buy_3);
}
}
return list;
}
@Override
public void onRefreshSuccess(List<GuardUserBean> list, int listCount) {
}
@Override
public void onRefreshFailure() {
}
@Override
public void onLoadMoreSuccess(List<GuardUserBean> loadItemList, int loadItemCount) {
}
@Override
public void onLoadMoreFailure() {
}
});
System.out.println(">>>>>>>>>>>>>设置数据");
mRefreshView.initData();
}
@Override
public void onClick(View view) {
dismiss();
((LiveActivity) mContext).openNewBuyGuardWindow();
}
@Override
public int show(@NonNull FragmentTransaction transaction, @Nullable String tag) {
int show = super.show(transaction, tag);
initView();
return show;
}
}

View File

@ -143,7 +143,7 @@ public class LiveUserMoreDialogFragment extends AbsDialogFragment implements Vie
((LiveActivity) mContext).openLuckGiftTip();
} else if (Tips.equals("2")) {
dismiss();
((LiveActivity) mContext).openGuardListWindow();
((LiveActivity) mContext).openNewGuardListWindow();
} else if (Tips.equals("3")) {
dismiss();
((LiveActivity) mContext).openFansWindow();

View File

@ -1501,7 +1501,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
//直播间 粉丝排行榜
openMedalRankWindow();
} else if (i == R.id.btn_guard) {
((LiveActivity) mContext).openGuardListWindow();
((LiveActivity) mContext).openNewGuardListWindow();
} else if (i == R.id.btn_red_pack) {
((LiveActivity) mContext).openRedPackListWindow();
@ -1521,7 +1521,7 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
((LiveActivity) mContext).openHotListWindow(1);
} else if (i == R.id.user_guard) {
// ((LiveActivity) mContext).openUserMoreListWindow(2, true);
((LiveActivity) mContext).openGuardListWindow();
((LiveActivity) mContext).openNewGuardListWindow();
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 228 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 222 KiB

View File

@ -56,11 +56,10 @@
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_toLeftOf="@id/btn_buy"
android:background="#161616"
android:gravity="center_vertical"
android:textColor="@color/gray1"
android:textSize="12sp"
android:background="#161616"
/>
android:textSize="12sp" />
</RelativeLayout>

View File

@ -0,0 +1,200 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/transparent"
android:clipChildren="false">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/guard_rootView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="52dp"
android:background="@drawable/guardian_img_bg"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:id="@+id/guard_linearLayout"
android:layout_width="182dp"
android:layout_height="42dp"
android:layout_marginTop="52dp"
android:layout_marginBottom="21dp"
android:gravity="center"
android:orientation="vertical"
app:layout_constraintBottom_toTopOf="@+id/guard_constraintLayout"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:gravity="center"
android:orientation="horizontal">
<TextView
android:id="@+id/list_guard_list_user_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#FFFFFF"
android:textSize="14sp" />
<ImageView
android:id="@+id/list_guard_list_user_sex"
android:layout_width="18dp"
android:layout_height="15dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
tools:srcCompat="@tools:sample/avatars" />
<ImageView
android:id="@+id/list_guard_list_user_level"
android:layout_width="30dp"
android:layout_height="15dp"
tools:srcCompat="@tools:sample/avatars" />
</LinearLayout>
<TextView
android:id="@+id/list_guard_list_user_guard"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textColor="#FFFFFF"
android:textSize="12sp" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/guard_constraintLayout"
android:layout_width="0dp"
android:layout_height="365dp"
android:layout_marginStart="5dp"
android:layout_marginTop="11dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_guard_info"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guard_linearLayout">
<com.yunbao.common.custom.CommonRefreshView
android:id="@+id/refreshView"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
app:crv_loadMoreEnable="false"
app:crv_refreshEnable="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:id="@+id/guard_relativeLayout"
android:layout_width="match_parent"
android:layout_height="77dp"
android:layout_marginTop="-20dp"
android:background="@drawable/img_guard_bottom"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/guard_constraintLayout">
<RelativeLayout
android:id="@+id/guard_tip_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="25dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:orientation="vertical">
<TextView
android:id="@+id/guard_tip1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:text=""
android:textColor="#A281FD"
android:textSize="14sp" />
<TextView
android:id="@+id/guard_tip2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@id/guard_coin_name"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:drawablePadding="4dp"
android:text="456"
android:textColor="#A281FD"
android:textSize="14sp"
android:visibility="gone" />
</LinearLayout>
<TextView
android:id="@+id/guard_btn_buy"
android:layout_width="90dp"
android:layout_height="30dp"
android:layout_alignParentEnd="true"
android:layout_centerVertical="true"
android:layout_marginEnd="15dp"
android:background="@drawable/bg_guard_btn_buy"
android:enabled="false"
android:gravity="center"
android:text="@string/guard_buy_2"
android:textColor="@color/white"
android:textSize="14sp" />
</RelativeLayout>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
<RelativeLayout
android:layout_width="243dp"
android:layout_height="117dp"
android:layout_above="@id/guard_rootView"
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:layout_marginBottom="-102dp"
android:scaleType="centerCrop"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/guard_imageView"
android:layout_width="58dp"
android:layout_height="58dp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="@drawable/guardian_img_wings"
android:visibility="visible"
app:riv_oval="true" />
<com.opensource.svgaplayer.SVGAImageView
android:id="@+id/gift_svga"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/guardian_img_wings"
android:visibility="visible"
app:autoPlay="true" />
</RelativeLayout>
</RelativeLayout>

View File

@ -48,7 +48,7 @@
android:ellipsize="end"
android:maxWidth="100dp"
android:singleLine="true"
android:textColor="#F6F7FB"
android:textColor="#3F3F3F"
android:textSize="15sp"
/>
@ -85,6 +85,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:layout_marginEnd="20dp"
android:layout_marginTop="4dp"
android:orientation="vertical">
@ -102,8 +103,9 @@
android:id="@+id/votes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="123456789"
android:textColor="#ffc2dff0"
android:text="1"
android:textColor="#979797"
android:layout_gravity="right"
android:gravity="center"
android:textSize="12sp"/>

View File

@ -198,8 +198,6 @@
android:layout_width="27dp"
android:layout_height="27dp"
android:layout_centerInParent="true"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:scaleType="centerCrop"
android:src="@mipmap/img_guardian_empty"
app:riv_oval="true" />