Skip to content

Instantly share code, notes, and snippets.

View rommel-sunga's full-sized avatar

Rommel Sunga rommel-sunga

View GitHub Profile
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
SendBird.init("192F73AB-EED6-465B-9B77-1F34406B5658", this);
SendBirdDesk.init();
SendBird.connect("test_user_1", new SendBird.ConnectHandler() {
@Override
package com.example.simplechatsb;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
package com.example.simplechatsb;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
@Override
public int getItemCount() {
return mList.size();
}
@Override
public void onBindViewHolder(GroupChannelListViewHolder holder, int position) {
holder.channelUrl = mList.get(position).getUrl();
holder.channelUrlTextView.setText(holder.channelUrl);
final String channelUrl = holder.channelUrl;
holder.joinChannelButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v ) {
Context context = v.getContext();
@rommel-sunga
rommel-sunga / GroupChannelListAdapter.java
Created March 4, 2019 22:28
GroupChannelListViewHolder
public class GroupChannelListViewHolder extends RecyclerView.ViewHolder{
public TextView channelUrlTextView;
public Button joinChannelButton;
private String channelUrl;
public GroupChannelListViewHolder(LinearLayout v) {
super(v);
channelUrlTextView = itemView.findViewById(R.id.channel_url_text_view);
joinChannelButton = itemView.findViewById(R.id.join_channel_button);
}
public class GroupChannelListAdapter extends RecyclerView.Adapter<GroupChannelListAdapter.GroupChannelListViewHolder> {
private List<GroupChannel> mList;
private String mChannelType;
public GroupChannelListAdapter(List<GroupChannel> list, String channelType) {
mList = list;
mChannelType = channelType;
}
@rommel-sunga
rommel-sunga / ChannelListActivity.java
Created March 4, 2019 22:25
Complete contents of ChannelListActivity.java
package com.example.simplechatsb;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import com.sendbird.android.GroupChannel;
import com.sendbird.android.GroupChannelListQuery;
@rommel-sunga
rommel-sunga / ChannelListActivity.java
Created March 4, 2019 22:24
connect_sendbird() and init_sendbird()
protected void connect_sendbird() {
SendBird.connect(USER_ID, new SendBird.ConnectHandler() {
@Override
public void onConnected(User user, SendBirdException e) {
if (e != null) { // Error.
return;
}
}
});
}
@rommel-sunga
rommel-sunga / ChannelListActivity.java
Created March 4, 2019 22:23
populate_group_channel_list() and populate_open_channel_list()
protected void populate_group_channel_list(List<GroupChannel> list) {
RecyclerView rvGroupChannelList = findViewById(R.id.channelListRecyclerView);
GroupChannelListAdapter adapter = new GroupChannelListAdapter(list, CHANNEL_TYPE);
rvGroupChannelList.setAdapter(adapter);
rvGroupChannelList.setLayoutManager(new LinearLayoutManager(this));
}
protected void populate_open_channel_list(List<OpenChannel> list) {
RecyclerView rvOpenChannelList = findViewById(R.id.channelListRecyclerView);