Skip to main content

Overview

The MyTeam activity provides sales managers with a complete view of their team members. It features a swipeable list interface where managers can access salesperson details or initiate personal chats.
This activity is accessible only to users with the Manager role and displays salespersons assigned to the logged-in manager.

Class Definition

MyTeam.java
package project.avishkar.salesmanagement.MyTeam;

import android.support.v7.app.AppCompatActivity;
import com.baoyz.swipemenulistview.SwipeMenuListView;
import com.google.firebase.database.FirebaseDatabase;

public class MyTeam extends AppCompatActivity {
    private SwipeMenuListView listView;
    private MyTeamAdapter myTeamAdapter;
    private ProgressBar spinner;
    private String managerName;
}

UI Components

listView
SwipeMenuListView
Custom ListView with swipe-to-reveal menu actions
myTeamAdapter
MyTeamAdapter
Adapter for binding salesperson data to the list
spinner
ProgressBar
Loading indicator displayed while fetching team data
managerName
String
Name of the current manager, used to filter team members

Lifecycle Methods

onCreate

Initializes the activity and loads the manager’s team from Firebase. Flow:
1

Get Manager ID

Retrieves the current user’s ID from SessionManager
SessionManager sm = new SessionManager(getApplicationContext());
HashMap<String, String> details = sm.getUserDetails();
final String id = details.get("id");
2

Fetch Manager Details

Queries Firebase to get the manager’s name using their ID
DatabaseReference databaseReference = 
    FirebaseDatabase.getInstance().getReference("Manager");
// Find manager by ID and retrieve name
3

Load Team Members

Fetches all salespersons whose managerName matches the current manager
DatabaseReference databaseReference1 = 
    FirebaseDatabase.getInstance().getReference("Salesperson");
// Filter salespersons by managerName
4

Setup Swipe Menu

Configures the swipe menu with “Details” and “Message” actions

Swipe Menu Actions

The SwipeMenuListView provides two actions when swiping left on a team member:

1. Details Action

Color: Gray (rgb(0xC9, 0xC9, 0xCE))
Width: 90dp
Function: Shows a dialog with complete salesperson information
SwipeMenuItem detailsItem = new SwipeMenuItem(getApplicationContext());
detailsItem.setBackground(new ColorDrawable(Color.rgb(0xC9, 0xC9, 0xCE)));
detailsItem.setWidth(dp2px(90));
detailsItem.setTitle("Details");
detailsItem.setTitleSize(18);
detailsItem.setTitleColor(Color.WHITE);
Details Dialog Fields:
  • Name
  • Phone number
  • Email address
  • Organization name
  • Profile picture (loaded via ImageSetter)

2. Message Action

Color: Red (rgb(0xF9, 0x3F, 0x25))
Width: 90dp
Icon: R.drawable.ic_message
Function: Opens personal chat with the selected salesperson
SwipeMenuItem messageItem = new SwipeMenuItem(getApplicationContext());
messageItem.setBackground(new ColorDrawable(Color.rgb(0xF9, 0x3F, 0x25)));
messageItem.setWidth(dp2px(90));
messageItem.setIcon(R.drawable.ic_message);
When clicked, launches PersonalChatActivityManager:
Intent intent = new Intent(getApplicationContext(), PersonalChatActivityManager.class);
intent.putExtra("SalespersonName", list.get(position).getName());
intent.putExtra("ManagerName", managerName);
startActivity(intent);

Data Loading Process

// 1. Query Manager collection
FirebaseDatabase.getInstance().getReference("Manager")
    .addListenerForSingleValueEvent(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // Find manager by ID
            for(DataSnapshot snapshot : dataSnapshot.getChildren()) {
                if(snapshot.getKey().equals(id)) {
                    managerName = snapshot.getValue(SalesManager.class).getName();
                    
                    // 2. Query Salesperson collection
                    FirebaseDatabase.getInstance().getReference("Salesperson")
                        .addListenerForSingleValueEvent(new ValueEventListener() {
                            @Override
                            public void onDataChange(DataSnapshot dataSnapshot) {
                                // Filter by managerName
                                for(DataSnapshot snapshot1 : dataSnapshot.getChildren()) {
                                    if(snapshot1.getValue(SalesPerson.class)
                                        .getManagerName().equals(managerName)) {
                                        list.add(snapshot1.getValue(SalesPerson.class));
                                    }
                                }
                                // 3. Setup UI
                                myTeamAdapter = new MyTeamAdapter(getApplicationContext(), list);
                                listView.setAdapter(myTeamAdapter);
                                spinner.setVisibility(View.GONE);
                            }
                        });
                }
            }
        }
    });

Dialog Layout

The details dialog uses the layout: R.layout.dialog_box_myteam_details Components:
  • name (TextView) - Salesperson’s full name
  • mobile (TextView) - Phone number
  • emailid (TextView) - Email address
  • organisation (TextView) - Company/organization name
  • user_pic (ImageView) - Profile picture
  • progressBar6 (ProgressBar) - Data loading spinner
  • progressBar10 (ProgressBar) - Image loading spinner

Adapter Integration

The activity uses MyTeamAdapter to render the list of salespersons:
myTeamAdapter = new MyTeamAdapter(getApplicationContext(), list);
listView.setAdapter(myTeamAdapter);
The adapter binds each SalesPerson object to a list item view.

Animation

The swipe menu uses a bounce interpolator for smooth closing animation:
listView.setCloseInterpolator(new BounceInterpolator());
Accessed from: ManagerMain activity via navigation drawer
Launches: PersonalChatActivityManager (when message action clicked)

Dependencies

SwipeMenuListView

Third-party library for swipeable list items
implementation 'com.baoyz.swipemenulistview:library:1.3.0'

Firebase Database

Real-time database for team data

MyTeamAdapter

List adapter for rendering team members

SessionManager

Retrieves current manager’s session

ImageSetter

Loads profile pictures in dialog

Source Reference

File: ~/workspace/source/app/src/main/java/project/avishkar/salesmanagement/MyTeam/MyTeam.java
This activity implements the “Team Management” feature listed in the manager capabilities, allowing managers to view team profiles and initiate direct communication.

Build docs developers (and LLMs) love