update 聊天长按气泡
This commit is contained in:
parent
095574296f
commit
0706611df8
@ -1,5 +1,6 @@
|
||||
package com.shayu.onetoone.activity.fragments.home;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -9,6 +10,7 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.activity.fragments.BaseFragment;
|
||||
import com.shayu.onetoone.activity.HomepageRankingActivity;
|
||||
import com.shayu.onetoone.adapter.HomeRecommendListAdapter;
|
||||
import com.shayu.onetoone.bean.HomeItemBean;
|
||||
import com.shayu.onetoone.manager.OTONetManager;
|
||||
@ -33,8 +35,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
public void initView(View itemView) {
|
||||
recyclerView = itemView.findViewById(R.id.recyclerView);
|
||||
mRefreshLayout = itemView.findViewById(R.id.swipeRefreshLayout);
|
||||
top=itemView.findViewById(R.id.btn_top_list);
|
||||
adapter=new HomeRecommendListAdapter(getContext());
|
||||
top = itemView.findViewById(R.id.btn_top_list);
|
||||
adapter = new HomeRecommendListAdapter(getContext());
|
||||
recyclerView.setAdapter(adapter);
|
||||
mRefreshLayout.setNestedScrollingEnabled(false);
|
||||
mRefreshLayout.setRefreshHeader(new RongRefreshHeader(this.getContext()));
|
||||
@ -50,7 +52,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
}
|
||||
});
|
||||
top.setOnClickListener(view -> {
|
||||
recyclerView.scrollToPosition(0);
|
||||
// recyclerView.scrollToPosition(0);
|
||||
startActivity(new Intent(getContext(), HomepageRankingActivity.class));
|
||||
});
|
||||
initData();
|
||||
}
|
||||
@ -62,7 +65,8 @@ public class RecommendFragment extends BaseFragment {
|
||||
private void onConversationListRefresh(RefreshLayout refreshLayout) {
|
||||
initData();
|
||||
}
|
||||
private void initData(){
|
||||
|
||||
private void initData() {
|
||||
OTONetManager.getInstance(mContext)
|
||||
.getHomeRecommend(new HttpCallback<List<HomeItemBean>>() {
|
||||
@Override
|
||||
|
@ -1,6 +1,10 @@
|
||||
package com.shayu.onetoone.activity.fragments.message;
|
||||
|
||||
import static android.content.Context.CLIPBOARD_SERVICE;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@ -24,6 +28,7 @@ import com.shayu.onetoone.bean.MessageChatAuthContent;
|
||||
import com.shayu.onetoone.bean.MessageChatTipsContent;
|
||||
import com.shayu.onetoone.bean.UserBean;
|
||||
import com.shayu.onetoone.dialog.BottomListDialog;
|
||||
import com.shayu.onetoone.dialog.MsgChatClickDialog;
|
||||
import com.shayu.onetoone.dialog.TipsDialog;
|
||||
import com.shayu.onetoone.listener.OnCallStatusListener;
|
||||
import com.shayu.onetoone.listener.OnDialogClickListener;
|
||||
@ -432,21 +437,66 @@ public class ChatMessageFragment extends AbsConversationFragment {
|
||||
|
||||
@Override
|
||||
public boolean onViewLongClick(int clickType, UiMessage data) {
|
||||
View position = mLinearLayoutManager.findViewByPosition(((MsgChatMessageListAdapter)mAdapter).getPosition(data.getMessageId()));
|
||||
View position = mLinearLayoutManager.findViewByPosition(((MsgChatMessageListAdapter) mAdapter).getPosition(data.getMessageId()));
|
||||
boolean isMy = data.getMessage().getMessageDirection() == Message.MessageDirection.SEND;
|
||||
boolean isTextMessage = data.getMessage().getContent() instanceof TextMessage;
|
||||
String[] list;
|
||||
if (isTextMessage) {
|
||||
if (isMy) {
|
||||
list = new String[]{"複製", "刪除"};
|
||||
} else {
|
||||
list = new String[]{"複製"};
|
||||
}
|
||||
} else {
|
||||
if (isMy) {
|
||||
list = new String[]{"刪除"};
|
||||
} else {
|
||||
list = null;
|
||||
}
|
||||
}
|
||||
if (list == null) {
|
||||
return true;
|
||||
}
|
||||
new XPopup.Builder(getContext())
|
||||
.atView(position) // 依附于所点击的View,内部会自动判断在上方或者下方显示
|
||||
.asAttachList(new String[]{"分享", "编辑", "不带icon"},
|
||||
new int[]{R.mipmap.ic_launcher, R.mipmap.ic_launcher},
|
||||
new OnSelectListener() {
|
||||
.atView(position.findViewById(R.id.rc_content))
|
||||
.hasShadowBg(false)
|
||||
.positionByWindowCenter(true)
|
||||
.asCustom(new MsgChatClickDialog(getActivity())
|
||||
.setList(Arrays.asList(list))
|
||||
.setOnItemClickListener(new OnItemClickListener<String>() {
|
||||
@Override
|
||||
public void onSelect(int position, String text) {
|
||||
ToastUtil.show("click " + text);
|
||||
public void onItemClick(String bean, int position) {
|
||||
if (bean.equals("複製")) {
|
||||
copyText(data);
|
||||
} else {
|
||||
delete(data);
|
||||
}
|
||||
}
|
||||
})
|
||||
}))
|
||||
.show();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void copyText(UiMessage uiMessage) {
|
||||
ClipboardManager cm = (ClipboardManager) getContext().getSystemService(CLIPBOARD_SERVICE);
|
||||
ClipData clipData = ClipData.newPlainText("text", uiMessage.getContentSpannable());
|
||||
cm.setPrimaryClip(clipData);
|
||||
}
|
||||
|
||||
private void delete(UiMessage uiMessage) {
|
||||
IMCenter.getInstance().deleteMessages(Conversation.ConversationType.PRIVATE, targetId, new int[]{uiMessage.getMessageId()}, new RongIMClient.ResultCallback<Boolean>() {
|
||||
@Override
|
||||
public void onSuccess(Boolean aBoolean) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MessageListAdapter onResolveAdapter() {
|
||||
return new MsgChatMessageListAdapter(this);
|
||||
|
@ -1,15 +1,24 @@
|
||||
package com.shayu.onetoone.adapter;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import io.rong.imkit.conversation.MessageListAdapter;
|
||||
import io.rong.imkit.model.UiMessage;
|
||||
import io.rong.imkit.widget.adapter.IViewProviderListener;
|
||||
import io.rong.imkit.widget.adapter.ViewHolder;
|
||||
|
||||
public class MsgChatMessageListAdapter extends MessageListAdapter {
|
||||
public MsgChatMessageListAdapter(IViewProviderListener<UiMessage> listener) {
|
||||
super(listener);
|
||||
}
|
||||
//onCreateMessageContentViewH
|
||||
|
||||
public void onLongClick(int messageId) {
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return super.onCreateViewHolder(parent, viewType);
|
||||
}
|
||||
|
||||
public int getPosition(int messageId) {
|
||||
|
@ -0,0 +1,93 @@
|
||||
package com.shayu.onetoone.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.lxj.xpopup.core.AttachPopupView;
|
||||
import com.lxj.xpopup.core.BubbleAttachPopupView;
|
||||
import com.shayu.onetoone.R;
|
||||
import com.shayu.onetoone.event.MessageMsgBusEvent;
|
||||
import com.shayu.onetoone.manager.RouteManager;
|
||||
import com.yunbao.common.interfaces.OnItemClickListener;
|
||||
import com.yunbao.common.utils.Bus;
|
||||
import com.yunbao.common.utils.DpUtil;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 聊天界面长按气泡菜单
|
||||
*/
|
||||
public class MsgChatClickDialog extends AttachPopupView implements View.OnClickListener {
|
||||
LinearLayout rootView;
|
||||
List<String> list;
|
||||
OnItemClickListener<String> onItemClickListener;
|
||||
|
||||
public MsgChatClickDialog(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public MsgChatClickDialog setList(List<String> list) {
|
||||
this.list = list;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MsgChatClickDialog setOnItemClickListener(OnItemClickListener<String> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getImplLayoutId() {
|
||||
return R.layout.dialog_msg_chat_click;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isShowUpToTarget() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
super.onCreate();
|
||||
isShowUp = true;
|
||||
rootView = findViewById(R.id.rootView);
|
||||
rootView.setGravity(Gravity.CENTER);
|
||||
LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
params.gravity = Gravity.CENTER;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
String item = list.get(i);
|
||||
TextView textView = new TextView(getContext());
|
||||
textView.setText(item);
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setTag(i);
|
||||
textView.setTextColor(Color.WHITE);
|
||||
textView.setLayoutParams(params);
|
||||
textView.setOnClickListener(this);
|
||||
rootView.addView(textView,params);
|
||||
|
||||
TextView tmp = new TextView(getContext());
|
||||
tmp.setLayoutParams(params);
|
||||
tmp.setText(" | ");
|
||||
tmp.setGravity(Gravity.CENTER);
|
||||
tmp.setTextColor(Color.WHITE);
|
||||
rootView.addView(tmp,params);
|
||||
}
|
||||
rootView.removeViewAt(rootView.getChildCount()-1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(((TextView) v).getText().toString(), (Integer) v.getTag());
|
||||
}
|
||||
dismiss();
|
||||
}
|
||||
}
|
12
OneToOne/src/main/res/layout/dialog_msg_chat_click.xml
Normal file
12
OneToOne/src/main/res/layout/dialog_msg_chat_click.xml
Normal file
@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/rootView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_gravity="center"
|
||||
android:background="@mipmap/bg_chat_click"
|
||||
android:orientation="horizontal">
|
||||
|
||||
</LinearLayout>
|
161
OneToOne/src/main/res/layout/rc_message_item.xml
Normal file
161
OneToOne/src/main/res/layout/rc_message_item.xml
Normal file
@ -0,0 +1,161 @@
|
||||
<?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/rc_cl_content"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingTop="@dimen/rc_margin_size_10"
|
||||
android:paddingBottom="@dimen/rc_margin_size_10">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rc_time"
|
||||
style="@style/TextStyle.Alignment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingBottom="12dp"
|
||||
android:textColor="@color/rc_secondary_color"
|
||||
android:textSize="@dimen/rc_font_describe_size"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:text="7月29日 12:30" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rc_selected"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/rc_margin_size_8"
|
||||
android:layout_marginTop="10dp"
|
||||
android:src="@drawable/rc_selector_selected"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/ll_content" />
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/rc_left_portrait"
|
||||
android:layout_width="@dimen/rc_message_portrait_size"
|
||||
android:layout_height="@dimen/rc_message_portrait_size"
|
||||
android:layout_marginStart="@dimen/rc_margin_size_4"
|
||||
app:riv_oval="true"
|
||||
android:src="@color/rc_secondary_color"
|
||||
app:layout_constraintStart_toEndOf="@id/rc_selected"
|
||||
app:layout_constraintTop_toTopOf="@id/ll_content"
|
||||
app:layout_goneMarginStart="@dimen/rc_margin_size_12" />
|
||||
|
||||
<com.makeramen.roundedimageview.RoundedImageView
|
||||
android:id="@+id/rc_right_portrait"
|
||||
android:layout_width="@dimen/rc_message_portrait_size"
|
||||
app:riv_oval="true"
|
||||
android:layout_height="@dimen/rc_message_portrait_size"
|
||||
android:layout_marginEnd="@dimen/rc_margin_size_12"
|
||||
android:src="@color/rc_secondary_color"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintTop_toTopOf="@id/ll_content"
|
||||
app:layout_goneMarginTop="@dimen/rc_margin_size_20" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_content"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="@dimen/rc_margin_size_8"
|
||||
android:layout_marginEnd="@dimen/rc_margin_size_8"
|
||||
android:orientation="vertical"
|
||||
app:layout_constraintEnd_toStartOf="@id/rc_right_portrait"
|
||||
app:layout_constraintStart_toEndOf="@id/rc_left_portrait"
|
||||
app:layout_constraintTop_toBottomOf="@id/rc_time">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rc_title"
|
||||
style="@style/TextStyle.Alignment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:ellipsize="end"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/rc_secondary_color"
|
||||
android:textSize="@dimen/rc_font_text_third_size" />
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/rc_layout"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/rc_progress"
|
||||
style="?android:attr/progressBarStyle"
|
||||
android:layout_width="13dp"
|
||||
android:layout_height="13dp"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="11dp"
|
||||
android:indeterminateDrawable="@drawable/rc_progress_sending_style"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rc_warning"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="8dp"
|
||||
android:src="@drawable/rc_ic_warning"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rc_read_receipt"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:src="@drawable/rc_read_receipt"
|
||||
android:visibility="gone" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/rc_read_receipt_new"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginEnd="4dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rc_read_receipt_request"
|
||||
style="@style/TextStyle.Alignment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:layout_marginTop="13dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:drawableStart="@drawable/rc_read_receipt_request_button"
|
||||
android:textColor="@color/rc_read_receipt_status"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/rc_read_receipt_status"
|
||||
style="@style/TextStyle.Alignment"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_marginBottom="5dp"
|
||||
android:text="@string/rc_read_receipt_status"
|
||||
android:textColor="@color/rc_read_receipt_status"
|
||||
android:textSize="12sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/rc_content"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:id="@+id/rc_v_edit"
|
||||
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_toTopOf="parent" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_chat_click.9.png
Normal file
BIN
OneToOne/src/main/res/mipmap-xxhdpi/bg_chat_click.9.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
Loading…
x
Reference in New Issue
Block a user