女神说编辑完成

This commit is contained in:
ningwenqiang 2024-09-18 14:09:21 +08:00
parent 7356431414
commit 330cf1faa2
8 changed files with 157 additions and 58 deletions

View File

@ -588,6 +588,7 @@ public interface PDLiveApi {
Observable<ResponseModel<String>> setLivePreviewInfo( Observable<ResponseModel<String>> setLivePreviewInfo(
@Query("liveuid") String liveUid, @Query("liveuid") String liveUid,
@Query("isShow") int isShow, @Query("isShow") int isShow,
@Query("title") String title ,
@Query("content") String content, @Query("content") String content,
@Query("styleImage") String styleImage @Query("styleImage") String styleImage
); );

View File

@ -1286,10 +1286,11 @@ public class LiveNetManager {
*/ */
public void setLivePreviewInfo(String liveUid, public void setLivePreviewInfo(String liveUid,
int isShow, int isShow,
String title,
String content, String content,
String styleImage, HttpCallback<String> callback) { String styleImage, HttpCallback<String> callback) {
API.get().pdLiveApi(mContext) API.get().pdLiveApi(mContext)
.setLivePreviewInfo(liveUid, isShow, content, styleImage) .setLivePreviewInfo(liveUid, isShow,title, content, styleImage)
.subscribeOn(Schedulers.io()) .subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread()) .observeOn(AndroidSchedulers.mainThread())
.subscribe(listResponseModel -> { .subscribe(listResponseModel -> {

View File

@ -1,6 +1,7 @@
package com.yunbao.live.adapter; package com.yunbao.live.adapter;
import android.content.Context; import android.content.Context;
import android.text.TextUtils;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
@ -8,6 +9,7 @@ import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView; import androidx.recyclerview.widget.RecyclerView;
import com.yunbao.common.glide.ImgLoader; import com.yunbao.common.glide.ImgLoader;
@ -20,7 +22,7 @@ import java.util.List;
public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSayItemsAdapter.ItemsViewHolder> { public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSayItemsAdapter.ItemsViewHolder> {
private Context mContext; private Context mContext;
private List<String> list; private List<String> list;
private int click = -1; private int click = 0;
private OnItemClickListener<String> onItemClickListener; private OnItemClickListener<String> onItemClickListener;
public LiveAnchorSayItemsAdapter(Context mContext) { public LiveAnchorSayItemsAdapter(Context mContext) {
@ -45,12 +47,17 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSa
@Override @Override
public void onBindViewHolder(@NonNull ItemsViewHolder holder, int position) { public void onBindViewHolder(@NonNull ItemsViewHolder holder, int position) {
holder.setData(list.get(position), position); if (position == 0) {
holder.setData("", 0);
return;
} else {
holder.setData(list.get(position - 1), position);
}
} }
@Override @Override
public int getItemCount() { public int getItemCount() {
return list.size(); return list.size() + 1;
} }
public class ItemsViewHolder extends RecyclerView.ViewHolder { public class ItemsViewHolder extends RecyclerView.ViewHolder {
@ -59,8 +66,8 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSa
public ItemsViewHolder(@NonNull View itemView) { public ItemsViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
textView = itemView.findViewById(R.id.anchor_say_text); textView = itemView.findViewById(R.id.contentTv);
icon = itemView.findViewById(R.id.anchor_say_icon); icon = itemView.findViewById(R.id.anchorSayBg);
itemView.setOnClickListener(v -> click()); itemView.setOnClickListener(v -> click());
textView.setOnClickListener(v -> click()); textView.setOnClickListener(v -> click());
icon.setOnClickListener(v -> click()); icon.setOnClickListener(v -> click());
@ -69,15 +76,26 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter<LiveAnchorSa
private void click() { private void click() {
click = getAbsoluteAdapterPosition(); click = getAbsoluteAdapterPosition();
if (onItemClickListener != null) { if (click > 0) {
onItemClickListener.onItemClick(list.get(click), click); if (onItemClickListener != null) {
onItemClickListener.onItemClick(list.get(click), click);
}
} else {
if (onItemClickListener != null) {
onItemClickListener.onItemClick("", 0);
}
} }
notifyDataSetChanged(); notifyDataSetChanged();
} }
public void setData(String text, int position) { public void setData(String text, int position) {
// textView.setText("已输入的\n内容已输\n入的内容\n已输入的");
ImgLoader.display(mContext, text, icon); // textView.setText("已输入的\n内容已输\n入的内容\n已输入的");
if (TextUtils.isEmpty(text)) {
icon.setImageDrawable(ContextCompat.getDrawable(mContext, R.drawable.bg_live_room_say));
} else {
ImgLoader.display(mContext, text, icon);
}
if (position == click) { if (position == click) {
itemView.setBackgroundResource(R.drawable.bg_anchor_say_select); itemView.setBackgroundResource(R.drawable.bg_anchor_say_select);
} else { } else {

View File

@ -39,8 +39,12 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
ImageView saySwitch; ImageView saySwitch;
ImageView close; ImageView close;
ImageView sayBg; ImageView sayBg;
TextView sayTitleTv;
TextView sayText; TextView sayText;
EditText sayEdit; EditText sayEdit;
EditText titleEdit;
String mLiveUid; String mLiveUid;
String url; String url;
LiveAnchorSayModel sayModel; LiveAnchorSayModel sayModel;
@ -70,7 +74,7 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
@Override @Override
protected void onDismiss() { protected void onDismiss() {
super.onDismiss(); super.onDismiss();
setSayData(url, sayEdit.getText().toString()); setSayData(url, titleEdit.getText().toString(), sayEdit.getText().toString());
} }
@Override @Override
@ -83,12 +87,17 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
super.onCreate(); super.onCreate();
adapter = new LiveAnchorSayItemsAdapter(getContext()); adapter = new LiveAnchorSayItemsAdapter(getContext());
anchorDemo = findViewById(R.id.anchor_say); anchorDemo = findViewById(R.id.anchor_say);
sayText = anchorDemo.findViewById(R.id.anchor_say_text);
sayTitleTv = anchorDemo.findViewById(R.id.titleTv);
sayText = anchorDemo.findViewById(R.id.contentTv);
sayBg = anchorDemo.findViewById(R.id.anchorSayBg);
list = findViewById(R.id.anchor_say_list); list = findViewById(R.id.anchor_say_list);
saySwitch = findViewById(R.id.say_switch); saySwitch = findViewById(R.id.say_switch);
sayEdit = findViewById(R.id.anchor_say_edit); sayEdit = findViewById(R.id.anchor_say_edit);
titleEdit = findViewById(R.id.titleEdit);
close = findViewById(R.id.close); close = findViewById(R.id.close);
sayBg = anchorDemo.findViewById(R.id.anchor_say_icon);
list.setLayoutManager(new GridLayoutManager(getContext(), 3)); list.setLayoutManager(new GridLayoutManager(getContext(), 3));
list.setAdapter(adapter); list.setAdapter(adapter);
adapter.setOnItemClickListener(new OnItemClickListener<String>() { adapter.setOnItemClickListener(new OnItemClickListener<String>() {
@ -121,51 +130,56 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
@Override @Override
public void onTextChanged(CharSequence s, int start, int before, int count) { public void onTextChanged(CharSequence s, int start, int before, int count) {
sayModel.getLivePreview().setContent(s.toString()); sayModel.getLivePreview().setContent(s.toString());
sayText.setText(getText(s.toString())); sayText.setText(s.toString());
} }
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
} }
});
titleEdit.addTextChangedListener(new TextWatcher() {
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
public String getText(String content) {
int t = 4;
float len = (float) content.length() / t;
StringBuilder sb = new StringBuilder();
sb.append("\n");
for (int i = 0; i < len; i++) {
if (len - i < 1) {
sb.append(content.substring(i * t));
} else {
sb.append(content.substring(i * t, i * t + t)).append("\n");
}
}
return sb.toString();
} }
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
sayModel.getLivePreview().setTitle(s.toString());
sayTitleTv.setText(s.toString());
}
@Override
public void afterTextChanged(Editable s) {
}
}); });
close.setOnClickListener(v -> { close.setOnClickListener(v -> {
dismiss(); dismiss();
}); });
} }
private void setSayData(String url, String edit) { private void setSayData(String url, String title, String edit) {
if(sayModel==null||sayModel.getLivePreview()==null){ if (sayModel == null || sayModel.getLivePreview() == null) {
return; return;
} }
Log.i("女神说", "setSayData: " + url + " " + title + " " + edit);
LiveNetManager.get(getContext()) LiveNetManager.get(getContext())
.setLivePreviewInfo( .setLivePreviewInfo(
mLiveUid, mLiveUid,
sayModel.getLivePreview().getIsShow(), sayModel.getLivePreview().getIsShow(),
title,
edit, edit,
url, url,
new HttpCallback<String>() { new HttpCallback<String>() {
@Override @Override
public void onSuccess(String data) { public void onSuccess(String data) {
Log.i("女神说", "onSuccess: " + data); Log.i("女神说", "onSuccess: " + data);
// ToastUtil.showDebug(WordUtil.isZh() ? "成功" : "success"); // ToastUtil.showDebug(WordUtil.isZh() ? "成功" : "success");
} }
@Override @Override
@ -187,13 +201,14 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
public void onSuccess(LiveAnchorSayModel data) { public void onSuccess(LiveAnchorSayModel data) {
sayModel = data; sayModel = data;
List<String> urls = new ArrayList<>(data.getStyle()); List<String> urls = new ArrayList<>(data.getStyle());
adapter.setList(urls); // adapter.setList(urls);
LiveAnchorSayModel.LivePreview preview = data.getLivePreview(); LiveAnchorSayModel.LivePreview preview = data.getLivePreview();
if (preview != null) { if (preview != null) {
sayText.setText(preview.getContent()); sayText.setText(preview.getContent());
titleEdit.setText(preview.getTitle());
sayEdit.setText(preview.getContent()); sayEdit.setText(preview.getContent());
url = preview.getStyleImage(); url = preview.getStyleImage();
ImgLoader.display(getContext(), preview.getStyleImage(), sayBg); // ImgLoader.display(getContext(), preview.getStyleImage(), sayBg);
if (preview.getIsShow() == 1) { if (preview.getIsShow() == 1) {
saySwitch.setTag(""); saySwitch.setTag("");
saySwitch.setImageResource(R.mipmap.special_icon_on); saySwitch.setImageResource(R.mipmap.special_icon_on);
@ -210,7 +225,7 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow {
}); });
} }
public interface OnDismissListener{ public interface OnDismissListener {
void onDismiss(); void onDismiss();
} }

View File

@ -7,18 +7,19 @@
<include <include
android:id="@+id/anchor_say" android:id="@+id/anchor_say"
layout="@layout/sim_live_room_anchor_say" layout="@layout/sim_live_room_anchor_say1"
android:layout_width="67dp" android:layout_width="96dp"
android:layout_height="88dp" android:layout_height="wrap_content"
android:layout_marginStart="16dp" android:layout_marginStart="16dp"
android:visibility="invisible" android:visibility="invisible"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<androidx.constraintlayout.widget.ConstraintLayout <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayout2" android:id="@+id/constraintLayout2"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="400dp" android:layout_height="500dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:background="@drawable/background_e6000" android:background="@drawable/background_e6000"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
@ -65,6 +66,53 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/linearLayout2" /> app:layout_constraintTop_toBottomOf="@+id/linearLayout2" />
<TextView
android:id="@+id/titleTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="6dp"
android:text="標題"
android:textColor="@color/white"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider" />
<EditText
android:id="@+id/titleEdit"
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="@string/live_anchor_say_edit_hint"
android:inputType="textPersonName"
android:maxLength="30"
android:paddingStart="16dp"
android:paddingEnd="16dp"
android:textColor="#FFF"
android:textColorHint="#80FFFFFF"
android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleTv" />
<TextView
android:id="@+id/contentTv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginTop="6dp"
android:text="内容"
android:textColor="@color/white"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/titleEdit" />
<EditText <EditText
android:id="@+id/anchor_say_edit" android:id="@+id/anchor_say_edit"
android:layout_width="0dp" android:layout_width="0dp"
@ -77,15 +125,14 @@
android:ems="10" android:ems="10"
android:hint="@string/live_anchor_say_edit_hint" android:hint="@string/live_anchor_say_edit_hint"
android:inputType="textPersonName" android:inputType="textPersonName"
android:maxLength="16"
android:paddingStart="16dp" android:paddingStart="16dp"
android:paddingEnd="16dp" android:paddingEnd="16dp"
android:textColorHint="#80FFFFFF"
android:textColor="#FFF" android:textColor="#FFF"
android:textColorHint="#80FFFFFF"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider" /> app:layout_constraintTop_toBottomOf="@+id/contentTv" />
<TextView <TextView
android:id="@+id/text2" android:id="@+id/text2"
@ -111,7 +158,7 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text2" app:layout_constraintTop_toBottomOf="@+id/text2"
tools:layoutManager="GridLayoutManager" tools:layoutManager="GridLayoutManager"
tools:listitem="@layout/item_anchor_say" tools:listitem="@layout/sim_live_room_anchor_say1"
tools:spanCount="3" /> tools:spanCount="3" />
<LinearLayout <LinearLayout

View File

@ -10,7 +10,7 @@
<include <include
layout="@layout/sim_live_room_anchor_say" layout="@layout/sim_live_room_anchor_say1"
android:layout_width="67dp" android:layout_width="67dp"
android:layout_height="88dp" android:layout_height="88dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"

View File

@ -3,9 +3,18 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="96dp" android:layout_width="96dp"
android:layout_height="wrap_content" android:id="@+id/sayBg"
android:background="@drawable/bg_live_room_say" android:layout_height="wrap_content">
android:minHeight="90dp">
<ImageView
android:id="@+id/anchorSayBg"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/bg_live_room_say"
app:layout_constraintBottom_toBottomOf="parent" />
<TextView <TextView
android:id="@+id/titleTv" android:id="@+id/titleTv"
@ -33,11 +42,16 @@
android:paddingEnd="10dp" android:paddingEnd="10dp"
android:paddingBottom="6dp" android:paddingBottom="6dp"
android:textColor="#ffffffff" android:textColor="#ffffffff"
android:textSize="9sp" android:textSize="10sp"
android:ellipsize="end"
android:maxLines="5"
android:minLines="3"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/titleTv" app:layout_constraintTop_toBottomOf="@id/titleTv"
tools:text="欢迎大家来到我的直播间欢迎大家来到我的直播间欢迎大家来到我的直播休息13242" /> app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginBottom="4dp"
tools:text="欢迎大家来到我的直播间欢迎大家来到我的直播间欢迎大家来到我的直播休息" />
<ImageView <ImageView
@ -51,4 +65,6 @@
app:layout_constraintEnd_toEndOf="parent" /> app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -1778,8 +1778,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignBottom="@+id/live_video" android:layout_alignBottom="@+id/live_video"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:visibility="invisible" android:visibility="invisible" />
toolsvisible="visible"/>
<ImageView <ImageView
android:id="@+id/icon_pk_top" android:id="@+id/icon_pk_top"
@ -2570,21 +2569,23 @@
android:layout_gravity="end" android:layout_gravity="end"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"/> tools:visibility="visible" />
<TextView <TextView
android:id="@+id/zhengguTv" android:id="@+id/zhengguTv"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/trick_up"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:paddingStart="8dp"
android:background="@drawable/bc_zheng_gu_left"
android:textColor="@color/white"
android:layout_gravity="end" android:layout_gravity="end"
android:layout_marginBottom="5dp" android:layout_marginBottom="5dp"
android:background="@drawable/bc_zheng_gu_left"
android:paddingStart="8dp"
android:paddingTop="3dp"
android:paddingBottom="3dp"
android:text="@string/trick_up"
android:textColor="@color/white"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible"/> tools:visibility="visible" />
<ImageView <ImageView
android:id="@+id/prank_group_turntable_icon" android:id="@+id/prank_group_turntable_icon"
android:layout_width="44dp" android:layout_width="44dp"