Skip to content

Instantly share code, notes, and snippets.

View AlexPrestonSB's full-sized avatar

Alex Preston AlexPrestonSB

View GitHub Profile
private class ChatAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private static final int VIEW_TYPE_MESSAGE_SENT = 1;
private static final int VIEW_TYPE_MESSAGE_RECEIVED = 2;
private ArrayList<BaseMessage> mMessageList;
private OpenChannel mChannel;
ChatAdapter(OpenChannel channel) {
mMessageList = new ArrayList<>();
mChannel = channel;
<?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:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/activity_vertical_margin">
<TextView
<?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:map="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/text_gchat_map_date_other"
android:layout_width="wrap_content"
class GroupChannelChatAdapter(context: Context, listener: OnItemClickListener) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var messages: MutableList<BaseMessage>
private var context: Context
private var listener: OnItemClickListener
init {
messages = ArrayList()
this.context = context
class GroupChannelChatActivity : AppCompatActivity(), GroupChannelChatView, GroupChannelChatAdapter.OnItemClickListener {
private val EXTRA_CHANNEL_URL = "EXTRA_CHANNEL_URL"
@Inject
lateinit var presenter: GroupChannelChatPresenterImpl
private lateinit var recyclerView: RecyclerView
private lateinit var adapter: GroupChannelChatAdapter
class GroupChannelChatPresenterImpl @Inject constructor(private val preferenceHelper: AppPreferenceHelper) :
GroupChannelChatPresenter {
private lateinit var view: GroupChannelChatView
private lateinit var channelUrl: String
private lateinit var message: String
private var channel: GroupChannel? = null
private lateinit var context: Context
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.sendbird.sdk:sendbird-android-sdk:3.0.139'
compile 'com.github.bumptech.glide:glide:3.7.0'
@AlexPrestonSB
AlexPrestonSB / UserMessage.java
Created August 7, 2020 21:22
Sending a User Message.
//User Message
List<String> translationTargetLanguages = new ArrayList<>();
translationTargetLanguages.add("fr"); // French
translationTargetLanguages.add("de"); // German
UserMessageParams params = new UserMessageParams()
.setMessage(TEXT_MESSAGE)
.setCustomType(CUSTOM_TYPE)
.setData(DATA)
.setTranslationTargetLanguages(translationTargetLanguages)
@AlexPrestonSB
AlexPrestonSB / FailedMessage.java
Created August 7, 2020 21:27
Event for when a message fails to send.
@Override
public void onFailedMessageEvent(MessageCollection collection, final List<BaseMessage> messages, final MessageEventAction action, final FailedMessageEventActionReason reason) {
if (getActivity() == null) {
return;
}
}
@AlexPrestonSB
AlexPrestonSB / ReceiverMarkAsRead.java
Created August 7, 2020 21:36
Marking a message as read
//Receiver Side
// Call the 'markAsRead()' when the current user views unread messages in a group channel.
groupChannel.markAsRead();
...