Overview
The Chat API provides real-time messaging functionality using Firebase Realtime Database, enabling seamless communication between managers and salespersons in the Sales Management App.ChatRoom
Activity that manages the chat room interface for viewing and sending messages. Package:project.avishkar.salesmanagement.Chat
Key Features
- Real-time message synchronization
- Firebase integration for persistent messaging
- RecyclerView-based message display
- Automatic message list updates
Properties
Displays the list of chat messages
Adapter for rendering messages in the RecyclerView
Button to send messages
Input field for composing messages
Name of the salesperson in the chat
Manager’s unique identifier for the chat room
Methods
onCreate()
Initializes the chat room activity and sets up Firebase listeners.The timestamp is calculated using
System.currentTimeMillis() / 1000 - 19800 to adjust for timezone offset.PersonalChatActivityManager
Activity for managers to engage in one-on-one chat with salespersons. Package:project.avishkar.salesmanagement.Chat
Key Features
- Personal messaging between manager and salesperson
- Smooth scrolling to latest messages
- Real-time message updates
- Session management integration
Properties
Displays the message list
Adapter for message rendering
Name of the salesperson
Name of the manager
Sanitized manager name (whitespace removed)
Sanitized salesperson name (whitespace removed)
Implementation Details
The activity automatically scrolls to the latest message using
recyclerView.smoothScrollToPosition(mMessages.size()-1)PersonalChatActivitySalesperson
Activity for salespersons to chat with their assigned manager. Package:project.avishkar.salesmanagement.Chat
Key Features
- Salesperson-side personal messaging
- Firebase real-time synchronization
- Message validation
- Session-aware messaging
Properties
Displays the conversation messages
Handles message list rendering
Triggers message sending
Text input for message composition
Firebase reference to ChatsTable
Message Structure
Messages are stored using the BaseMessage model:Validation
The activity includes message validation:Firebase Structure
The chat system uses two main Firebase paths:- ChatRoom: For group chat rooms identified by manager number
- ChatsTable: For personal one-on-one conversations identified by
ManagerName-SalespersonName
All chat activities use
SessionManager to retrieve current user details including ID and role.