Skip to content

Commit 51296bf

Browse files
guangyaoguangyao
authored andcommitted
2 parents f0da463 + 9fac9bb commit 51296bf

File tree

14 files changed

+405
-4
lines changed

14 files changed

+405
-4
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package cn.jiguang.imui.commons.models;
2+
3+
/**
4+
* Created by dowin on 2017/10/23.
5+
*/
6+
7+
public interface ICard extends IExtend {
8+
9+
String getCardType();
10+
11+
String getName();
12+
13+
String getImgPath();
14+
15+
String getSessionId();
16+
}

android/messagelist/src/main/java/cn/jiguang/imui/commons/models/IMessage.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ enum MessageType {
4444
SEND_ACCOUNT_NOTICE,
4545
RECEIVE_ACCOUNT_NOTICE,
4646

47+
SEND_CARD,
48+
RECEIVE_CARD,
49+
4750
RED_PACKET_OPEN,
4851
NOTIFICATION,
4952
TIP,

android/messagelist/src/main/java/cn/jiguang/imui/messages/MsgListAdapter.java

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import cn.jiguang.imui.messages.viewholder.AccountNoticeViewHolder;
2828
import cn.jiguang.imui.messages.viewholder.BankTransferViewHolder;
2929
import cn.jiguang.imui.messages.viewholder.BaseMessageViewHolder;
30+
import cn.jiguang.imui.messages.viewholder.CardViewHolder;
3031
import cn.jiguang.imui.messages.viewholder.CustonViewHolder;
3132
import cn.jiguang.imui.messages.viewholder.EventViewHolder;
3233
import cn.jiguang.imui.messages.viewholder.LinkViewHolder;
@@ -87,6 +88,9 @@ public class MsgListAdapter<MESSAGE extends IMessage> extends RecyclerView.Adapt
8788
private final int TYPE_SEND_ACCOUNT_NOTICE = 22;
8889
private final int TYPE_RECEIVER_ACCOUNT_NOTICE = 23;
8990

91+
private final int TYPE_SEND_CARD = 24;
92+
private final int TYPE_RECEIVER_CARD = 25;
93+
9094
private Context mContext;
9195
private Activity mActivity;
9296
private String mSenderId;
@@ -234,6 +238,11 @@ public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
234238
return getHolder(parent, mHolders.mSendAccountNoticeLayout, mHolders.mSendAccountNoticeHolder, true);
235239
case TYPE_RECEIVER_ACCOUNT_NOTICE:
236240
return getHolder(parent, mHolders.mReceiveAccountNoticeLayout, mHolders.mReceiveAccountNoticeHolder, false);
241+
242+
case TYPE_SEND_CARD:
243+
return getHolder(parent, mHolders.mSendCardLayout, mHolders.mSendCardHolder, true);
244+
case TYPE_RECEIVER_CARD:
245+
return getHolder(parent, mHolders.mReceiveCardLayout, mHolders.mReceiveCardHolder, false);
237246
case TYPE_SEND_LOCATION:
238247
return getHolder(parent, mHolders.mSendLocationLayout, mHolders.mSendLocationHolder, true);
239248
case TYPE_RECEIVER_LOCATION:
@@ -297,6 +306,11 @@ public int getItemViewType(int position) {
297306
return TYPE_SEND_ACCOUNT_NOTICE;
298307
case RECEIVE_ACCOUNT_NOTICE:
299308
return TYPE_RECEIVER_ACCOUNT_NOTICE;
309+
310+
case SEND_CARD:
311+
return TYPE_SEND_CARD;
312+
case RECEIVE_CARD:
313+
return TYPE_RECEIVER_CARD;
300314
case SEND_LINK:
301315
return TYPE_SEND_LINK;
302316
case RECEIVE_LINK:
@@ -870,6 +884,9 @@ public static class HoldersConfig {
870884
private Class<? extends BaseMessageViewHolder<? extends IMessage>> mSendRedPacketHolder;
871885
private Class<? extends BaseMessageViewHolder<? extends IMessage>> mReceiveRedPacketHolder;
872886

887+
private Class<? extends BaseMessageViewHolder<? extends IMessage>> mSendCardHolder;
888+
private Class<? extends BaseMessageViewHolder<? extends IMessage>> mReceiveCardHolder;
889+
873890
private Class<? extends BaseMessageViewHolder<? extends IMessage>> mSendLocationHolder;
874891
private Class<? extends BaseMessageViewHolder<? extends IMessage>> mReceiveLocationHolder;
875892

@@ -899,6 +916,9 @@ public static class HoldersConfig {
899916
private int mSendRedPacketLayout;
900917
private int mReceiveRedPacketLayout;
901918

919+
private int mSendCardLayout;
920+
private int mReceiveCardLayout;
921+
902922
private int mSendBankTransferLayout;
903923
private int mReceiveBankTransferLayout;
904924

@@ -927,6 +947,9 @@ public HoldersConfig() {
927947
mSendRedPacketHolder = DefaultRedPacketViewHolder.class;
928948
mReceiveRedPacketHolder = DefaultRedPacketViewHolder.class;
929949

950+
mSendCardHolder = DefaultCardViewHolder.class;
951+
mReceiveCardHolder = DefaultCardViewHolder.class;
952+
930953
mSendBankTransferHolder = DefaultBankTransferViewHolder.class;
931954
mReceiveBankTransferHolder = DefaultBankTransferViewHolder.class;
932955

@@ -958,6 +981,9 @@ public HoldersConfig() {
958981
mSendRedPacketLayout = R.layout.item_send_red_packet;
959982
mReceiveRedPacketLayout = R.layout.item_receive_red_packet;
960983

984+
mSendCardLayout = R.layout.item_send_card;
985+
mReceiveCardLayout = R.layout.item_receive_card;
986+
961987
mSendBankTransferLayout = R.layout.item_send_bank_transfer;
962988
mReceiveBankTransferLayout = R.layout.item_receive_bank_transfer;
963989

@@ -1263,6 +1289,12 @@ public DefaultAccountNoticeViewHolder(RecyclerView.Adapter adapter, View itemVie
12631289
}
12641290
}
12651291

1292+
private static class DefaultCardViewHolder extends CardViewHolder<IMessage>{
1293+
1294+
public DefaultCardViewHolder(RecyclerView.Adapter adapter, View itemView, boolean isSender) {
1295+
super(adapter, itemView, isSender);
1296+
}
1297+
}
12661298
private static class DefaultRedPacketViewHolder extends RedPacketViewHolder<IMessage> {
12671299

12681300
public DefaultRedPacketViewHolder(RecyclerView.Adapter adapter, View itemView, boolean isSender) {
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package cn.jiguang.imui.messages.viewholder;
2+
3+
import android.support.v7.widget.RecyclerView;
4+
import android.text.TextUtils;
5+
import android.view.View;
6+
import android.widget.ImageView;
7+
import android.widget.TextView;
8+
9+
import cn.jiguang.imui.R;
10+
import cn.jiguang.imui.commons.models.ICard;
11+
import cn.jiguang.imui.commons.models.IMessage;
12+
import cn.jiguang.imui.messages.MessageListStyle;
13+
14+
/**
15+
* Created by dowin on 2017/10/23.
16+
*/
17+
18+
public class CardViewHolder<MESSAGE extends IMessage> extends AvatarViewHolder<MESSAGE> {
19+
20+
private ImageView image;
21+
private TextView name;
22+
private TextView cardType;
23+
private TextView sessionId;
24+
25+
public CardViewHolder(RecyclerView.Adapter adapter, View itemView, boolean isSender) {
26+
super(adapter, itemView, isSender);
27+
28+
image = (ImageView) itemView.findViewById(R.id.card_icon);
29+
name = (TextView) itemView.findViewById(R.id.card_name);
30+
cardType = (TextView) itemView.findViewById(R.id.card_type);
31+
sessionId = (TextView) itemView.findViewById(R.id.card_id);
32+
}
33+
34+
@Override
35+
public void onBind(final MESSAGE message) {
36+
super.onBind(message);
37+
ICard card = getExtend(message);
38+
if (card != null) {
39+
if(!TextUtils.isEmpty(card.getImgPath())) {
40+
mImageLoader.loadAvatarImage(image, card.getImgPath());
41+
}
42+
name.setText(card.getName());
43+
cardType.setText(card.getCardType());
44+
sessionId.setText(card.getSessionId());
45+
}
46+
47+
}
48+
49+
@Override
50+
public void applyStyle(MessageListStyle style) {
51+
super.applyStyle(style);
52+
}
53+
}

android/messagelist/src/main/java/cn/jiguang/imui/messages/viewholder/PhotoViewHolder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ public void applyStyle(MessageListStyle style) {
6363

6464
mPhotoIv.setMinimumWidth(DisplayUtil.dp2px(style.mContext,100));
6565
mPhotoIv.setMinimumHeight(DisplayUtil.dp2px(style.mContext,100));
66-
mPhotoIv.setScaleType(ImageView.ScaleType.FIT_END);
66+
// mPhotoIv.setScaleType(ImageView.ScaleType.CENTER_CROP);
6767
// if (mIsSender) {
6868
// mPhotoIv.setBackground(style.getSendPhotoMsgBg());
6969
// } else {
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
style="@style/aurora_msgitem_receive_style">
4+
5+
6+
<TextView
7+
android:id="@+id/aurora_tv_msgitem_date"
8+
style="@style/aurora_msgitem_date_style" />
9+
10+
<RelativeLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:layout_marginTop="4dp">
14+
15+
<include layout="@layout/item_head_left"/>
16+
17+
<TextView
18+
android:id="@+id/aurora_tv_msgitem_display_name"
19+
style="@style/aurora_msgitem_display_name_style"
20+
android:layout_width="wrap_content"
21+
android:layout_height="wrap_content"
22+
android:layout_toRightOf="@id/aurora_iv_msgitem_avatar"
23+
android:text="123" />
24+
25+
<LinearLayout
26+
android:layout_marginTop="@dimen/aurora_message_padding_top"
27+
android:id="@+id/item_layout"
28+
android:clickable="false"
29+
android:layout_marginLeft="@dimen/aurora_avatar_padding"
30+
android:layout_marginRight="@dimen/aurora_width_msg_avatar"
31+
android:layout_centerVertical="true"
32+
android:layout_below="@id/aurora_tv_msgitem_display_name"
33+
android:layout_toRightOf="@id/aurora_iv_msgitem_avatar"
34+
android:layout_width="match_parent"
35+
android:layout_height="wrap_content"
36+
android:background="@drawable/link_bg"
37+
android:orientation="vertical">
38+
39+
<RelativeLayout
40+
android:id="@+id/layout_top"
41+
android:layout_width="match_parent"
42+
android:layout_height="match_parent"
43+
android:duplicateParentState="true">
44+
45+
<ImageView
46+
android:id="@+id/card_icon"
47+
android:layout_margin="@dimen/red_packet_image_margin"
48+
android:src="@drawable/aurora_headicon_default"
49+
android:layout_width="48dp"
50+
android:layout_height="48dp" />
51+
<TextView
52+
android:id="@+id/card_name"
53+
android:layout_toRightOf="@+id/card_icon"
54+
android:layout_marginTop="@dimen/red_packet_top"
55+
android:textSize="@dimen/red_packet_comments_size"
56+
android:text="恭喜发财,大吉大利"
57+
android:lines="1"
58+
android:ellipsize="end"
59+
android:textColor="@color/black"
60+
android:layout_width="match_parent"
61+
android:layout_height="wrap_content" />
62+
<TextView
63+
android:id="@+id/card_id"
64+
android:layout_marginTop="3dp"
65+
android:layout_toRightOf="@+id/card_icon"
66+
android:layout_below="@+id/card_name"
67+
android:text="领取红包"
68+
android:textColor="@color/black"
69+
android:textSize="@dimen/red_packet_text_size"
70+
android:layout_width="match_parent"
71+
android:layout_height="wrap_content" />
72+
</RelativeLayout>
73+
<View
74+
android:layout_width="match_parent"
75+
android:layout_height="1px"
76+
android:background="@color/link_card" />
77+
<TextView
78+
android:id="@+id/card_type"
79+
android:background="@drawable/red_packet_bottom"
80+
android:padding="5dp"
81+
android:textSize="@dimen/red_packet_tag_size"
82+
android:textColor="@color/red_packet_tag"
83+
android:layout_width="match_parent"
84+
android:layout_height="wrap_content"
85+
android:text="红包" />
86+
</LinearLayout>
87+
</RelativeLayout>
88+
</LinearLayout>
Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
style="@style/aurora_msgitem_send_style">
4+
5+
6+
<TextView
7+
android:id="@+id/aurora_tv_msgitem_date"
8+
style="@style/aurora_msgitem_date_style"/>
9+
10+
<LinearLayout
11+
android:layout_width="match_parent"
12+
android:layout_height="wrap_content"
13+
android:layout_marginTop="5dp"
14+
android:gravity="right"
15+
android:orientation="horizontal">
16+
17+
<RelativeLayout
18+
android:layout_width="wrap_content"
19+
android:layout_height="wrap_content">
20+
<ImageButton
21+
android:id="@+id/aurora_ib_msgitem_resend"
22+
android:layout_width="20dp"
23+
android:layout_height="20dp"
24+
android:layout_gravity="center_vertical"
25+
android:layout_marginRight="5dp"
26+
android:background="@drawable/aurora_send_msg_error"
27+
android:clickable="true"
28+
android:scaleType="fitCenter"
29+
android:visibility="invisible" />
30+
31+
<ProgressBar
32+
android:id="@+id/aurora_pb_msgitem_sending"
33+
android:layout_width="20dp"
34+
android:layout_height="20dp"
35+
android:layout_gravity="center_vertical"
36+
android:layout_marginRight="3dp"
37+
android:visibility="visible"/>
38+
</RelativeLayout>
39+
40+
41+
<LinearLayout
42+
android:id="@+id/item_layout"
43+
android:clickable="false"
44+
android:layout_marginRight="@dimen/aurora_avatar_padding"
45+
android:layout_centerVertical="true"
46+
android:layout_below="@id/aurora_tv_msgitem_display_name"
47+
android:layout_toRightOf="@id/aurora_iv_msgitem_avatar"
48+
android:layout_width="match_parent"
49+
android:layout_height="wrap_content"
50+
android:background="@drawable/link_bg"
51+
android:orientation="vertical">
52+
53+
<RelativeLayout
54+
android:id="@+id/layout_top"
55+
android:clickable="true"
56+
android:layout_width="match_parent"
57+
android:layout_height="match_parent">
58+
59+
<ImageView
60+
android:id="@+id/card_icon"
61+
android:layout_margin="@dimen/red_packet_image_margin"
62+
android:src="@drawable/aurora_headicon_default"
63+
android:layout_width="48dp"
64+
android:layout_height="48dp" />
65+
<TextView
66+
android:id="@+id/card_name"
67+
android:layout_toRightOf="@+id/card_icon"
68+
android:layout_marginTop="@dimen/red_packet_top"
69+
android:textSize="@dimen/red_packet_comments_size"
70+
android:lines="1"
71+
android:ellipsize="end"
72+
android:text="恭喜发财,大吉大利"
73+
android:textColor="@color/black"
74+
android:layout_width="match_parent"
75+
android:layout_height="wrap_content" />
76+
<TextView
77+
android:id="@+id/card_id"
78+
android:layout_marginTop="6dp"
79+
android:layout_toRightOf="@+id/card_icon"
80+
android:layout_below="@+id/card_name"
81+
android:text="领取红包"
82+
android:textColor="@color/black"
83+
android:textSize="@dimen/red_packet_text_size"
84+
android:layout_width="match_parent"
85+
android:layout_height="wrap_content" />
86+
</RelativeLayout>
87+
<View
88+
android:layout_width="match_parent"
89+
android:layout_height="1px"
90+
android:background="@color/link_card" />
91+
<TextView
92+
android:id="@+id/card_type"
93+
android:background="@drawable/red_packet_bottom"
94+
android:padding="5dp"
95+
android:textSize="@dimen/red_packet_tag_size"
96+
android:textColor="@color/red_packet_tag"
97+
android:layout_width="match_parent"
98+
android:layout_height="wrap_content"
99+
android:text="红包" />
100+
</LinearLayout>
101+
102+
<include layout="@layout/item_head_right"/>
103+
104+
</LinearLayout>
105+
106+
</LinearLayout>

android/messagelist/src/main/res/values/colors.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@
2727
<color name="red_packet_text">#ffe4bf</color>
2828
<color name="red_packet_tag">#999999</color>
2929
<color name="link_pressed">#dcd9d9</color>
30+
<color name="link_card">#dcd9d9</color>
3031
</resources>

0 commit comments

Comments
 (0)