[Modify]夺宝精灵消息修改
This commit is contained in:
@@ -22,6 +22,7 @@ import com.yizhuan.erban.ui.im.avtivity.NimP2PMessageActivity;
|
|||||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderAudioParty;
|
||||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderChatHint;
|
||||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderContent;
|
||||||
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderFairy;
|
||||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderGift;
|
||||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderHello;
|
||||||
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLevel;
|
import com.yizhuan.erban.ui.im.chat.MsgViewHolderLevel;
|
||||||
@@ -42,6 +43,7 @@ import com.yizhuan.xchat_android_core.im.custom.bean.CarAttachment;
|
|||||||
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
|
import com.yizhuan.xchat_android_core.im.custom.bean.CarveUpGoldThirdLevelAttachment;
|
||||||
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
|
import com.yizhuan.xchat_android_core.im.custom.bean.ChatHintAttachment;
|
||||||
import com.yizhuan.xchat_android_core.im.custom.bean.CpInviteAttachment;
|
import com.yizhuan.xchat_android_core.im.custom.bean.CpInviteAttachment;
|
||||||
|
import com.yizhuan.xchat_android_core.im.custom.bean.FairySendAttachment;
|
||||||
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
|
import com.yizhuan.xchat_android_core.im.custom.bean.GiftAttachment;
|
||||||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
|
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingFamilyAttachment;
|
||||||
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingMiniWorldAttachment;
|
import com.yizhuan.xchat_android_core.im.custom.bean.InAppSharingMiniWorldAttachment;
|
||||||
@@ -166,6 +168,7 @@ public class ImInitHelper {
|
|||||||
NimUIKit.registerMsgItemViewHolder(SkillMsgAttachment.class, MsgViewHolderSkill.class);
|
NimUIKit.registerMsgItemViewHolder(SkillMsgAttachment.class, MsgViewHolderSkill.class);
|
||||||
//CP
|
//CP
|
||||||
NimUIKit.registerMsgItemViewHolder(CpInviteAttachment.class, MsgViewHolderText.class);
|
NimUIKit.registerMsgItemViewHolder(CpInviteAttachment.class, MsgViewHolderText.class);
|
||||||
|
NimUIKit.registerMsgItemViewHolder(FairySendAttachment.class, MsgViewHolderFairy.class);
|
||||||
NimUIKit.setSessionListener(listener);
|
NimUIKit.setSessionListener(listener);
|
||||||
NimUIKit.setContactEventListener(listener1);
|
NimUIKit.setContactEventListener(listener1);
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,99 @@
|
|||||||
|
package com.yizhuan.erban.ui.im.chat;
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.View;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import com.netease.nim.uikit.business.session.viewholder.MsgViewHolderBase;
|
||||||
|
import com.netease.nim.uikit.common.ui.recyclerview.adapter.BaseMultiItemFetchLoadAdapter;
|
||||||
|
import com.yizhuan.erban.R;
|
||||||
|
import com.yizhuan.erban.treasurefairy.dialog.MyFairySendDialog;
|
||||||
|
import com.yizhuan.erban.ui.utils.ImageLoadUtils;
|
||||||
|
import com.yizhuan.xchat_android_core.auth.AuthModel;
|
||||||
|
import com.yizhuan.xchat_android_core.gift.bean.SimpleUserInfo;
|
||||||
|
import com.yizhuan.xchat_android_core.im.custom.bean.CustomAttachment;
|
||||||
|
import com.yizhuan.xchat_android_core.im.custom.bean.FairySendAttachment;
|
||||||
|
import com.yizhuan.xchat_android_core.manager.IMNetEaseManager;
|
||||||
|
import com.yizhuan.xchat_android_core.treasurefairy.FairyInfo;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by chenran on 2018/1/2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
public class MsgViewHolderFairy extends MsgViewHolderBase implements View.OnClickListener {
|
||||||
|
private final static String IS_SEND = "afafagag";
|
||||||
|
private TextView tvContent;
|
||||||
|
private ImageView ivFairyIcon;
|
||||||
|
private View flIconBg;
|
||||||
|
private View tvView;
|
||||||
|
|
||||||
|
public MsgViewHolderFairy(BaseMultiItemFetchLoadAdapter adapter) {
|
||||||
|
super(adapter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int getContentResId() {
|
||||||
|
return R.layout.layout_msg_view_holder_fairy;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void inflateContentView() {
|
||||||
|
tvContent = findViewById(R.id.tv_content);
|
||||||
|
ivFairyIcon = findViewById(R.id.iv_fairy_icon);
|
||||||
|
flIconBg = findViewById(R.id.fl_icon_bg);
|
||||||
|
tvView = findViewById(R.id.tv_view);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void bindContentView() {
|
||||||
|
FairySendAttachment attachment = (FairySendAttachment) message.getAttachment();
|
||||||
|
|
||||||
|
tvContent.setText(attachment.getMsgContent());
|
||||||
|
ImageLoadUtils.loadImage(context, attachment.getElfPicUrl(), ivFairyIcon);
|
||||||
|
if (isReceivedMessage()) {
|
||||||
|
flIconBg.setBackgroundResource(R.drawable.shape_white_8dp_round);
|
||||||
|
} else {
|
||||||
|
flIconBg.setBackgroundResource(R.drawable.shape_f5f4fa_8dp_round);
|
||||||
|
}
|
||||||
|
Map<String, Object> localExtension = message.getLocalExtension();
|
||||||
|
boolean isSend = false;
|
||||||
|
if (localExtension != null && localExtension.containsKey(IS_SEND)) {
|
||||||
|
isSend = (boolean) localExtension.get(IS_SEND);
|
||||||
|
}
|
||||||
|
boolean isAskFor = attachment.getSecond() == CustomAttachment.CUSTOM_MSG_SUB_FAIRY_ASK_FOR;
|
||||||
|
|
||||||
|
if (!isSend && isAskFor && attachment.getUid() != AuthModel.get().getCurrentUid()) {
|
||||||
|
tvView.setVisibility(View.VISIBLE);
|
||||||
|
contentContainer.setOnClickListener(this);
|
||||||
|
} else {
|
||||||
|
tvView.setVisibility(View.GONE);
|
||||||
|
contentContainer.setOnClickListener(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressLint("CheckResult")
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
FairySendAttachment attachment = (FairySendAttachment) message.getAttachment();
|
||||||
|
SimpleUserInfo userInfo = new SimpleUserInfo(attachment.getNick(), attachment.getUid(), 0, "", "");
|
||||||
|
FairyInfo fairyInfo = new FairyInfo(attachment.getElfId(), 1, 1, attachment.getElfName(), attachment.getElfPicUrl(), 0);
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putSerializable("userInfo", userInfo);
|
||||||
|
bundle.putSerializable("fairyInfo", fairyInfo);
|
||||||
|
bundle.putBoolean("isSend", true);
|
||||||
|
MyFairySendDialog sendDialog = MyFairySendDialog.Companion.newInstance(bundle, userInfo);
|
||||||
|
sendDialog.setOnSendListener(() -> {
|
||||||
|
Map<String, Object> localExtension = message.getLocalExtension();
|
||||||
|
if (localExtension == null) localExtension = new HashMap<>();
|
||||||
|
localExtension.put(IS_SEND, true);
|
||||||
|
message.setLocalExtension(localExtension);
|
||||||
|
IMNetEaseManager.get().updateMessageToLocal(message);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
sendDialog.show(context);
|
||||||
|
}
|
||||||
|
}
|
8
app/src/main/res/drawable/shape_f5f4fa_8dp_round.xml
Normal file
8
app/src/main/res/drawable/shape_f5f4fa_8dp_round.xml
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="rectangle">
|
||||||
|
|
||||||
|
<solid android:color="#F5F4FA" />
|
||||||
|
|
||||||
|
<corners android:radius="8dp" />
|
||||||
|
</shape>
|
52
app/src/main/res/layout/layout_msg_view_holder_fairy.xml
Normal file
52
app/src/main/res/layout/layout_msg_view_holder_fairy.xml
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/layout_container"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<FrameLayout
|
||||||
|
android:id="@+id/fl_icon_bg"
|
||||||
|
android:layout_width="62dp"
|
||||||
|
android:layout_height="62dp"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:background="@drawable/shape_white_8dp_round">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_fairy_icon"
|
||||||
|
android:layout_width="55dp"
|
||||||
|
android:layout_height="55dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@drawable/default_cover" />
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_vertical"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_content"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textColor="#ff171a58"
|
||||||
|
android:textSize="13sp"
|
||||||
|
tools:text="对方赠送了你一张“小火龙”精灵卡" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_view"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:text="点击查看>>"
|
||||||
|
android:textColor="#5FCCE4"
|
||||||
|
android:textSize="14dp" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
Reference in New Issue
Block a user