diff --git a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java index f9d1dc950..cf01a8fe7 100644 --- a/common/src/main/java/com/yunbao/common/http/PDLiveApi.java +++ b/common/src/main/java/com/yunbao/common/http/PDLiveApi.java @@ -588,6 +588,7 @@ public interface PDLiveApi { Observable> setLivePreviewInfo( @Query("liveuid") String liveUid, @Query("isShow") int isShow, + @Query("title") String title , @Query("content") String content, @Query("styleImage") String styleImage ); diff --git a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java index 4ec5d30f3..82619870e 100644 --- a/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java +++ b/common/src/main/java/com/yunbao/common/http/live/LiveNetManager.java @@ -1286,10 +1286,11 @@ public class LiveNetManager { */ public void setLivePreviewInfo(String liveUid, int isShow, + String title, String content, String styleImage, HttpCallback callback) { API.get().pdLiveApi(mContext) - .setLivePreviewInfo(liveUid, isShow, content, styleImage) + .setLivePreviewInfo(liveUid, isShow,title, content, styleImage) .subscribeOn(Schedulers.io()) .observeOn(AndroidSchedulers.mainThread()) .subscribe(listResponseModel -> { diff --git a/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java b/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java index 6f439d662..4b4438ad3 100644 --- a/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java +++ b/live/src/main/java/com/yunbao/live/adapter/LiveAnchorSayItemsAdapter.java @@ -1,6 +1,7 @@ package com.yunbao.live.adapter; import android.content.Context; +import android.text.TextUtils; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -8,6 +9,7 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import androidx.recyclerview.widget.RecyclerView; import com.yunbao.common.glide.ImgLoader; @@ -20,7 +22,7 @@ import java.util.List; public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter { private Context mContext; private List list; - private int click = -1; + private int click = 0; private OnItemClickListener onItemClickListener; public LiveAnchorSayItemsAdapter(Context mContext) { @@ -45,12 +47,17 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter click()); textView.setOnClickListener(v -> click()); icon.setOnClickListener(v -> click()); @@ -69,15 +76,26 @@ public class LiveAnchorSayItemsAdapter extends RecyclerView.Adapter 0) { + if (onItemClickListener != null) { + onItemClickListener.onItemClick(list.get(click), click); + } + } else { + if (onItemClickListener != null) { + onItemClickListener.onItemClick("", 0); + } } notifyDataSetChanged(); } 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) { itemView.setBackgroundResource(R.drawable.bg_anchor_say_select); } else { diff --git a/live/src/main/java/com/yunbao/live/dialog/LiveAnchorSayPopDialog.java b/live/src/main/java/com/yunbao/live/dialog/LiveAnchorSayPopDialog.java index 5e3670ff4..0d340e0a4 100644 --- a/live/src/main/java/com/yunbao/live/dialog/LiveAnchorSayPopDialog.java +++ b/live/src/main/java/com/yunbao/live/dialog/LiveAnchorSayPopDialog.java @@ -39,8 +39,12 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow { ImageView saySwitch; ImageView close; ImageView sayBg; + + TextView sayTitleTv; TextView sayText; + EditText sayEdit; + EditText titleEdit; String mLiveUid; String url; LiveAnchorSayModel sayModel; @@ -70,7 +74,7 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow { @Override protected void onDismiss() { super.onDismiss(); - setSayData(url, sayEdit.getText().toString()); + setSayData(url, titleEdit.getText().toString(), sayEdit.getText().toString()); } @Override @@ -83,12 +87,17 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow { super.onCreate(); adapter = new LiveAnchorSayItemsAdapter(getContext()); 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); saySwitch = findViewById(R.id.say_switch); sayEdit = findViewById(R.id.anchor_say_edit); + titleEdit = findViewById(R.id.titleEdit); close = findViewById(R.id.close); - sayBg = anchorDemo.findViewById(R.id.anchor_say_icon); + list.setLayoutManager(new GridLayoutManager(getContext(), 3)); list.setAdapter(adapter); adapter.setOnItemClickListener(new OnItemClickListener() { @@ -121,51 +130,56 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow { @Override public void onTextChanged(CharSequence s, int start, int before, int count) { sayModel.getLivePreview().setContent(s.toString()); - sayText.setText(getText(s.toString())); + sayText.setText(s.toString()); } @Override 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 -> { dismiss(); }); } - private void setSayData(String url, String edit) { - if(sayModel==null||sayModel.getLivePreview()==null){ + private void setSayData(String url, String title, String edit) { + if (sayModel == null || sayModel.getLivePreview() == null) { return; } + Log.i("女神说", "setSayData: " + url + " " + title + " " + edit); LiveNetManager.get(getContext()) .setLivePreviewInfo( mLiveUid, sayModel.getLivePreview().getIsShow(), + title, edit, url, new HttpCallback() { @Override public void onSuccess(String data) { Log.i("女神说", "onSuccess: " + data); - // ToastUtil.showDebug(WordUtil.isZh() ? "成功" : "success"); + // ToastUtil.showDebug(WordUtil.isZh() ? "成功" : "success"); } @Override @@ -187,13 +201,14 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow { public void onSuccess(LiveAnchorSayModel data) { sayModel = data; List urls = new ArrayList<>(data.getStyle()); - adapter.setList(urls); + // adapter.setList(urls); LiveAnchorSayModel.LivePreview preview = data.getLivePreview(); if (preview != null) { sayText.setText(preview.getContent()); + titleEdit.setText(preview.getTitle()); sayEdit.setText(preview.getContent()); url = preview.getStyleImage(); - ImgLoader.display(getContext(), preview.getStyleImage(), sayBg); + // ImgLoader.display(getContext(), preview.getStyleImage(), sayBg); if (preview.getIsShow() == 1) { saySwitch.setTag(""); saySwitch.setImageResource(R.mipmap.special_icon_on); @@ -210,7 +225,7 @@ public class LiveAnchorSayPopDialog extends AbsDialogPopupWindow { }); } - public interface OnDismissListener{ + public interface OnDismissListener { void onDismiss(); } diff --git a/live/src/main/res/layout/dialog_anchor_say.xml b/live/src/main/res/layout/dialog_anchor_say.xml index 94ebe87a1..531a4c7a2 100644 --- a/live/src/main/res/layout/dialog_anchor_say.xml +++ b/live/src/main/res/layout/dialog_anchor_say.xml @@ -7,18 +7,19 @@ + app:layout_constraintTop_toTopOf="parent" + tools:visibility="visible" /> + + + + + + + + app:layout_constraintTop_toBottomOf="@+id/contentTv" /> + android:id="@+id/sayBg" + android:layout_height="wrap_content"> + + + app:layout_constraintBottom_toBottomOf="parent" + android:layout_marginBottom="4dp" + tools:text="欢迎大家来到我的直播间欢迎大家来到我的直播间欢迎大家来到我的直播休息" /> + + \ No newline at end of file diff --git a/live/src/main/res/layout/view_live_room.xml b/live/src/main/res/layout/view_live_room.xml index b19164351..3df61433c 100644 --- a/live/src/main/res/layout/view_live_room.xml +++ b/live/src/main/res/layout/view_live_room.xml @@ -1778,8 +1778,7 @@ android:layout_height="wrap_content" android:layout_alignBottom="@+id/live_video" android:layout_marginStart="12dp" - android:visibility="invisible" - toolsvisible="visible"/> + android:visibility="invisible" /> + tools:visibility="visible" /> + + tools:visibility="visible" /> +