Skip to content

Instantly share code, notes, and snippets.

interface PreviousMessageListQuery {
hasMore: boolean;
isLoading: boolean;
limit: number;
reverse: boolean;
messageTypeFilter: 0 | 1 | 2 | 3; // 0: ALL, 1: USER, 2: FILE, 3: ADMIN
customTypeFilter: string;
senderUserIdsFilter: Array<string>;
load(limit: number, reverse: boolean, callback: messageListCallback): void;
public class MessageListActivity extends AppCompatActivity {
private RecyclerView mMessageRecycler;
private MessageListAdapter mMessageAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message_list);
mMessageRecycler = (RecyclerView) findViewById(R.id.reyclerview_message_list);
public class MessageListAdapter extends RecyclerView.Adapter {
private static final int VIEW_TYPE_MESSAGE_SENT = 1;
private static final int VIEW_TYPE_MESSAGE_RECEIVED = 2;
private Context mContext;
private List<BaseMessage> mMessageList;
public MessageListAdapter(Context context, List<BaseMessage> messageList) {
mContext = context;
mMessageList = messageList;
private class ReceivedMessageHolder extends RecyclerView.ViewHolder {
TextView messageText, timeText, nameText;
ImageView profileImage;
ReceivedMessageHolder(View itemView) {
super(itemView);
messageText = (TextView) itemView.findViewById(R.id.text_message_body);
timeText = (TextView) itemView.findViewById(R.id.text_message_time);
nameText = (TextView) itemView.findViewById(R.id.text_message_name);
profileImage = (ImageView) itemView.findViewById(R.id.image_message_profile);
public class MessageListAdapter extends RecyclerView.Adapter {
private Context mContext;
private List<BaseMessage> mMessageList;
public MessageListAdapter(Context context, List<BaseMessage> messageList) {
mContext = context;
mMessageList = messageList;
}
}
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp">
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp">
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<!-- View background color -->
<solid
android:color="#FF6E00" >
</solid>
<!-- The radius makes the corners rounded -->
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.sendbird.chattutorial.MessageListActivity">