Skip to content

Instantly share code, notes, and snippets.

@swahaniroy
swahaniroy / login.js
Created July 22, 2021 11:50
Login screen for already-registered users
public class LoginActivity extends AppCompatActivity {
private TextInputEditText mobile;
private MaterialButton loginBtn;
private MaterialButton signupBtn;
private ProgressBar progressBar;
@Override
protected void onCreate(Bundle savedInstanceState) {
@swahaniroy
swahaniroy / conversation.js
Created July 22, 2021 11:55
Setting up the Conversation Screeen
public class ConversationsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conversations);
}
}
@swahaniroy
swahaniroy / conversationlist.js
Created July 22, 2021 11:57
Setting up the Conversation Screen
<fragment
android:id="@+id/conversationList"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.cometchat.pro.uikit.ui_components.chats.CometChatConversationList" />
@swahaniroy
swahaniroy / chatbutton.js
Created July 22, 2021 12:14
Conversation Screen button for the user to click and initiate a chat
<com.google.android.material.floatingactionbutton.FloatingActionButton
android:id="@+id/fab"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_add"
@swahaniroy
swahaniroy / routing.js
Last active July 22, 2021 12:43
Routing function
public void newChatTapped(View view) {
startActivity(new Intent(ConversationsActivity.this, SelectContactActivity.class));
}
@swahaniroy
swahaniroy / displaylist.js
Created July 22, 2021 12:18
Displaying a list of all registered users in the app
public class SelectContactActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_select_contact);
}
}
@swahaniroy
swahaniroy / userlist.js
Created July 22, 2021 12:22
Here's how you'll get a fully working list of users
<fragment
android:id="@+id/userList"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="com.cometchat.pro.uikit.ui_components.users.user_list.CometChatUserList" />
@swahaniroy
swahaniroy / conversationslist.js
Created July 22, 2021 12:40
Routing an user from Conversations List Screen to Chat Screen
CometChatConversationList.setItemClickListener(new OnItemClickListener<Conversation>() {
@Override
public void OnItemClick(Conversation var, int position) {
User user = (User)var.getConversationWith();
Intent intent = new Intent(ConversationsActivity.this, CometChatMessageListActivity.class);
intent.putExtra(UIKitConstants.IntentStrings.UID, user.getUid());
intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar());
intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus());
intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName());
@swahaniroy
swahaniroy / userselection.js
Created July 22, 2021 12:42
Routing an user from User Selection Screen to Chat Screen
CometChatUserList.setItemClickListener(new OnItemClickListener<User>() {
@Override
public void OnItemClick(User user, int position) {
Intent intent = new Intent(SelectContactActivity.this, CometChatMessageListActivity.class);
intent.putExtra(UIKitConstants.IntentStrings.UID, user.getUid());
intent.putExtra(UIKitConstants.IntentStrings.AVATAR, user.getAvatar());
intent.putExtra(UIKitConstants.IntentStrings.STATUS, user.getStatus());
intent.putExtra(UIKitConstants.IntentStrings.NAME, user.getName());
@swahaniroy
swahaniroy / main.js
Created August 5, 2021 11:35
Initializing CometChat
import { enableProdMode } from '@angular/core';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app/app.module';
import { environment } from './environments/environment';
import { CometChat } from "@cometchat-pro/chat";
import { COMETCHAT_CONSTANTS } from "./CONSTS";
if (environment.production) {