新增女神说相关UI

This commit is contained in:
zlzw 2023-03-23 14:26:52 +08:00
parent c2aba5da4b
commit f4d23c57df
13 changed files with 567 additions and 4 deletions

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<corners android:radius="11.67dp" />
<solid android:color="#E6000000" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,76 @@
package com.yunbao.live.adapter;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.adapter.OnItemClickListener;
import com.yunbao.live.R;
import java.util.List;
public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSayItemsAdapter.ItemsViewHolder> {
private Context mContext;
private List<String> list;
private int click = -1;
private OnItemClickListener onItemClickListener;
public LiveAnchorSayItemsAdapter(Context mContext) {
this.mContext = mContext;
}
public void setList(List<String> list) {
this.list = list;
notifyDataSetChanged();
}
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
this.onItemClickListener = onItemClickListener;
}
@NonNull
@Override
public ItemsViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
return new ItemsViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_anchor_say, parent, false));
}
@Override
public void onBindViewHolder(@NonNull ItemsViewHolder holder, int position) {
holder.setData(list.get(position), position);
}
@Override
public int getItemCount() {
return list.size();
}
public class ItemsViewHolder extends RecyclerView.ViewHolder {
private TextView textView;
public ItemsViewHolder(@NonNull View itemView) {
super(itemView);
textView = itemView.findViewById(R.id.anchor_say_text);
itemView.setOnClickListener(v -> {
click = getAbsoluteAdapterPosition();
if (onItemClickListener != null) {
onItemClickListener.onItemClick(click);
}
notifyDataSetChanged();
});
}
public void setData(String text, int position) {
textView.setText(text);
if (position == click) {
itemView.setBackgroundResource(R.drawable.bg_anchor_say_select);
} else {
itemView.setBackgroundResource(R.drawable.bg_anchor_say);
}
}
}
}

View File

@ -0,0 +1,126 @@
package com.yunbao.live.dialog;
import android.content.Context;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.lxj.xpopup.XPopup;
import com.yunbao.common.adapter.OnItemClickListener;
import com.yunbao.common.dialog.AbsDialogPopupWindow;
import com.yunbao.common.utils.ToastUtil;
import com.yunbao.live.R;
import com.yunbao.live.adapter.LiveAnchorSayItemsAdapter;
import java.util.ArrayList;
import java.util.List;
public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
RecyclerView list;
View anchorDemo;
LiveAnchorSayItemsAdapter adapter;
ImageView saySwitch;
TextView sayText;
EditText sayEdit;
public LiveAnchorSayPopDialog(@NonNull Context context) {
super(context);
}
@Override
public void buildDialog(XPopup.Builder builder) {
builder.autoFocusEditText(false);
builder.enableDrag(false);
builder.borderRadius(50);
}
@Override
public int bindLayoutId() {
return R.layout.dialog_anchor_say;
}
@Override
protected void onCreate() {
super.onCreate();
adapter = new LiveAnchorSayItemsAdapter(getContext());
anchorDemo = findViewById(R.id.anchor_say);
sayText = anchorDemo.findViewById(R.id.anchor_say_text);
list = findViewById(R.id.anchor_say_list);
saySwitch = findViewById(R.id.say_switch);
sayEdit = findViewById(R.id.anchor_say_edit);
list.setLayoutManager(new GridLayoutManager(getContext(), 3));
list.setAdapter(adapter);
adapter.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(int position) {
}
});
initData();
saySwitch.setOnClickListener(v -> {
if (saySwitch.getTag() == null) {
saySwitch.setTag("");
saySwitch.setImageResource(R.mipmap.special_icon_on);
anchorDemo.setVisibility(VISIBLE);
} else {
saySwitch.setTag(null);
saySwitch.setImageResource(R.mipmap.special_icon_off);
anchorDemo.setVisibility(INVISIBLE);
}
});
sayEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
StringBuilder sb = new StringBuilder();
int n = (s.length() + 3) / 4;
for (int i = 0; i < n; i++) {
if (i < (n - 1)) {
sb.append(s.toString().substring(i * 4, (i + 1) * 4)).append("\n");
} else {
sb.append(s.toString().substring(i * 4));
}
}
if(sb.length()==0){
sb.append("默认字符\n默认字符\n默认字符");
}
sayText.setText(sb.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
});
}
private void initData() {
List<String> data = new ArrayList<>();
for (int i = 0; i < 20; i++) {
data.add("data " + i);
}
adapter.setList(data);
}
}

View File

@ -37,6 +37,7 @@ import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout; import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
@ -334,6 +335,11 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
//全服通知 //全服通知
private ImageView customFullServiceNotify; private ImageView customFullServiceNotify;
//----主播说组件---//
private View mAnchorSay;
private ImageView mAnchorSayImage;
private TextView mAnchorSayText;
//----!主播说组件---//
public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) { public LiveRoomViewHolder(boolean isRys, int forActivity, Context context, ViewGroup parentView, GifImageView gifImageView, SVGAImageView svgaImageView, ViewGroup liveGiftPrizePoolContainer, WindowManager windowManager) {
super(context, parentView); super(context, parentView);
@ -676,6 +682,89 @@ public class LiveRoomViewHolder extends AbsViewHolder implements View.OnClickLis
@Override @Override
public void init() { public void init() {
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
mAnchorSay = findViewById(R.id.anchor_say_layout);
mAnchorSayImage = (ImageView) findViewById(R.id.anchor_say_icon);
mAnchorSayText = (TextView) findViewById(R.id.anchor_say_text);
mAnchorSayImage.setOnClickListener(v -> {
Animation animation;
if (mAnchorSayText.getVisibility() == View.VISIBLE) {
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_say_text_out);
} else {
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_say_text_in);
}
animation.setAnimationListener(new Animation.AnimationListener() {
boolean isShow = false;
@Override
public void onAnimationStart(Animation animation) {
if (mAnchorSayText.getVisibility() == View.GONE) {
mAnchorSayText.setVisibility(View.VISIBLE);
isShow = true;
}
}
@Override
public void onAnimationEnd(Animation animation) {
if (mAnchorSayText.getVisibility() == View.VISIBLE && !isShow) {
mAnchorSayText.setVisibility(View.GONE);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mAnchorSayText.startAnimation(animation);
});
mAnchorSayImage.setOnLongClickListener(new View.OnLongClickListener() {
@Override
public boolean onLongClick(View v) {
Animation animation;
if (mAnchorSay.getVisibility() == View.VISIBLE) {
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_say_text_out);
} else {
animation = AnimationUtils.loadAnimation(mContext, R.anim.view_live_anchor_say_text_in);
if(v==null){
mAnchorSayText.setVisibility(View.VISIBLE);
}
}
animation.setAnimationListener(new Animation.AnimationListener() {
boolean isShow = false;
@Override
public void onAnimationStart(Animation animation) {
if (mAnchorSay.getVisibility() == View.GONE) {
mAnchorSay.setVisibility(View.VISIBLE);
isShow = true;
}
}
@Override
public void onAnimationEnd(Animation animation) {
if (mAnchorSay.getVisibility() == View.VISIBLE && !isShow) {
mAnchorSay.setVisibility(View.GONE);
}
if(v!=null) {
new Handler(Looper.getMainLooper()).postDelayed(() -> {
onLongClick(null);
}, 2000);
}else{
mAnchorSayText.setVisibility(View.VISIBLE);
}
}
@Override
public void onAnimationRepeat(Animation animation) {
}
});
mAnchorSay.startAnimation(animation);
return false;
}
});
btnEvent = findViewById(R.id.btn_event); btnEvent = findViewById(R.id.btn_event);
fullScreen = (FullServiceNotificationView) findViewById(R.id.full_screen); fullScreen = (FullServiceNotificationView) findViewById(R.id.full_screen);
noble = (NobleNoticeView) findViewById(R.id.noble); noble = (NobleNoticeView) findViewById(R.id.noble);

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="-100%"
android:toXDelta="0" />
<alpha
android:duration="300"
android:fromAlpha="0"
android:toAlpha="1" />
</set>

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:android="http://schemas.android.com/apk/res/android">
<translate
android:duration="300"
android:fromXDelta="0"
android:toXDelta="-100%" />
<alpha
android:duration="300"
android:fromAlpha="1"
android:toAlpha="0" />
</set>

View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="166dp" android:height="162dp">
<shape android:shape="rectangle">
<solid android:color="#337792D0" />
<corners android:radius="8dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:width="166dp" android:height="162dp">
<shape android:shape="rectangle">
<stroke android:width="1dp" android:color="#ffffc621" />
<solid android:color="#337792D0" />
<corners android:radius="8dp" />
</shape>
</item>
</selector>

View File

@ -0,0 +1,148 @@
<?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:layout_width="match_parent"
android:layout_height="wrap_content">
<include
android:id="@+id/anchor_say"
layout="@layout/sim_live_room_anchor_say"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:visibility="invisible"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout2"
android:layout_width="match_parent"
android:layout_height="400dp"
android:layout_marginTop="20dp"
android:background="@drawable/background_e6000"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/anchor_say">
<LinearLayout
android:id="@+id/linearLayout2"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginTop="16dp"
android:orientation="horizontal"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:text="編輯女神說"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<ImageView
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginEnd="16dp"
app:srcCompat="@mipmap/live_close" />
</LinearLayout>
<View
android:id="@+id/divider"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="16dp"
android:background="#1affffff"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2" />
<EditText
android:id="@+id/anchor_say_edit"
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:autofillHints=""
android:background="@drawable/bg_item_random_pk_type_1"
android:ems="10"
android:hint="请輸入女神想說的話限12個字哦。"
android:inputType="textPersonName"
android:maxLength="12"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColorHint="#80FFFFFF"
android:textColor="#FFF"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider" />
<TextView
android:id="@+id/text2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:text="选择样式"
android:textColor="#FFFFFF"
android:textSize="12sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/anchor_say_edit" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/anchor_say_list"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
app:layout_constraintBottom_toTopOf="@+id/linearLayout3"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text2"
tools:layoutManager="GridLayoutManager"
tools:listitem="@layout/item_anchor_say"
tools:spanCount="3" />
<LinearLayout
android:id="@+id/linearLayout3"
android:layout_width="match_parent"
android:layout_height="60dp"
android:background="@color/black2"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="@+id/constraintLayout2"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_marginStart="16dp"
android:layout_weight="1"
android:gravity="center|start"
android:text="女神說開關"
android:textColor="#FFFFFF"
android:textSize="16sp" />
<ImageView
android:id="@+id/say_switch"
android:layout_width="40dp"
android:layout_height="24dp"
android:layout_gravity="center"
android:layout_marginEnd="16dp"
app:srcCompat="@mipmap/special_icon_off" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,20 @@
<?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"
android:layout_width="106dp"
android:layout_height="128dp"
android:layout_marginStart="5dp"
android:layout_marginEnd="5dp"
android:background="@drawable/bg_anchor_say"
android:layout_marginTop="10dp">
<include
layout="@layout/sim_live_room_anchor_say"
android:layout_width="67dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,35 @@
<?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:layout_width="wrap_content"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/anchor_say_icon"
android:layout_width="50dp"
android:layout_height="50dp"
android:background="@color/red"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/anchor_say_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@color/blue"
android:ellipsize="none"
android:inputType="textMultiLine"
android:text="中文测试\n中文测试\n中文测试"
android:gravity="center"
android:textColor="@color/white"
android:textSize="10sp"
android:maxEms="4"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/anchor_say_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1258,6 +1258,17 @@
</FrameLayout> </FrameLayout>
<include
android:id="@+id/anchor_say_layout"
layout="@layout/sim_live_room_anchor_say"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/live_video"
android:layout_marginStart="14dp"
android:layout_marginBottom="50dp"
android:background="@color/white" />
<ImageView <ImageView
android:id="@+id/icon_pk_top" android:id="@+id/icon_pk_top"
android:layout_width="110dp" android:layout_width="110dp"
@ -1266,7 +1277,7 @@
android:layout_centerHorizontal="true" android:layout_centerHorizontal="true"
android:layout_marginTop="40dp" android:layout_marginTop="40dp"
android:src="@mipmap/icon_rank_top_box" android:src="@mipmap/icon_rank_top_box"
android:visibility="gone" /> android:visibility="visible" />
<RelativeLayout <RelativeLayout
android:id="@+id/lt_pk_line" android:id="@+id/lt_pk_line"
@ -2307,7 +2318,7 @@
<com.yunbao.common.views.weight.NobleNoticeView <com.yunbao.common.views.weight.NobleNoticeView
android:id="@+id/noble" android:id="@+id/noble"
android:layout_width="match_parent" android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="60dp" /> android:layout_marginTop="60dp"
android:visibility="gone" />
</RelativeLayout> </RelativeLayout>

View File

@ -9,6 +9,7 @@ import android.widget.ImageView;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
import com.yunbao.common.utils.WordUtil; import com.yunbao.common.utils.WordUtil;
import com.yunbao.live.dialog.LiveAnchorSayPopDialog;
import com.yunbao.live.dialog.LiveRobotSettingDialogFragment; import com.yunbao.live.dialog.LiveRobotSettingDialogFragment;
import com.yunbao.main.R; import com.yunbao.main.R;
import com.yunbao.main.activity.MainActivity; import com.yunbao.main.activity.MainActivity;
@ -43,6 +44,11 @@ public class MainHomeViewHolder extends AbsMainHomeParentViewHolder {
ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy); ImgLoader.display(mContext, "https://downs.yaoulive.com/gif_trophy.gif", img_trophy);
img_trophy.setOnLongClickListener(v -> {
new LiveAnchorSayPopDialog(mContext).showDialog();
return false;
});
} }